Jump to content











Photo
* * * * * 1 votes

ShutdownPE


  • Please log in to reply
95 replies to this topic

#26 Corum

Corum
  • Members
  • 6 posts
  • Location:Kiev
  •  
    Ukraine

Posted 29 March 2010 - 06:01 PM

I wrote little program (code from MSDN ) but it works only in the full Windows XP and doesn't in the LiveXP (any errors messages):

#include "stdafx.h"#include "windows.h"#include <iostream>using namespace std;#pragma comment(lib, "user32.lib")#pragma comment(lib, "advapi32.lib")BOOL _tmain(int argc, _TCHAR* argv[]){	HANDLE hToken; 	TOKEN_PRIVILEGES tkp;	UINT action;	if (argc > 2)		return FALSE;	if (wcscmp(argv[1], L"/r") == 0)		action = EWX_REBOOT;	else		if (wcscmp(argv[1], L"/s") == 0)			action = EWX_SHUTDOWN;		else			return FALSE;	// Get a token for this process. 	if (!OpenProcessToken(GetCurrentProcess(), 		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))	{		cout << "Open process token failed"<<endl;		return FALSE; 	}	// Get the LUID for the shutdown privilege. 	LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, 		&tkp.Privileges[0].Luid); 	tkp.PrivilegeCount = 1;  // one privilege to set    	tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 	// Get the shutdown privilege for this process. 	AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, 		(PTOKEN_PRIVILEGES)NULL, 0); 	if (GetLastError() != ERROR_SUCCESS)	{		cout << "Set privileges failed."<<endl;		return FALSE; 	}	// Shut down the system and force all applications to close. 	if (!ExitWindowsEx(action | EWX_FORCE, 		SHTDN_REASON_MAJOR_OPERATINGSYSTEM |		SHTDN_REASON_MINOR_UPGRADE |		SHTDN_REASON_FLAG_PLANNED))	{		cout << "ExitWindowsEx failed." <<endl;		return FALSE; 	}	//shutdown was successful	return TRUE;}

Attached Files



#27 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 29 March 2010 - 11:09 PM

That's correct. ExitWindowsEx does not work in PE. In PE you have to call the kernel NtShutdownSystem function in ntdll.dll

#28 Corum

Corum
  • Members
  • 6 posts
  • Location:Kiev
  •  
    Ukraine

Posted 30 March 2010 - 01:39 PM

That's correct. ExitWindowsEx does not work in PE. In PE you have to call the kernel NtShutdownSystem function in ntdll.dll

Thank you, NtShutdownSystem function from NTDLL.DLL works :)

#29 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 30 March 2010 - 01:56 PM

Can I shutdown or reboot LiveXP using ShutdownPE.exe from batch file?
I did not find information about it in the Readme file and using help keywords from the command line.
Please, write command line parameters for shutdown and reboot, if they are :)

I started coding up the command line options but I don't think they made it into the current release, they will be in next release for sure though.

#30 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 04 April 2010 - 12:11 AM

Hi homes32,

heads up, check post 90 , post 91 , post 92

:dubbio:

#31 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 04 April 2010 - 09:55 PM

Using new shutdown was giving me an error when shutdown was clicked something about my CD door was not closed and could not read CD


did you have eject cd/dvd option checked? and was this a windows error message or an error message from ShutdownPE?
If used from non XP based builds ShutdownPE uses the exact same method of shutdown as old shortcuts.
ShellExecute&#40;@SystemDir & &#34;\Wpeutil.exe&#34;, &#34;shutdown&#34;, @SystemDir, &#34;&#34;, @SW_HIDE&#41;


#32 PaPeuser

PaPeuser

    Silver Member

  • Advanced user
  • 787 posts
  •  
    United States

Posted 04 April 2010 - 10:02 PM

did you have eject cd/dvd option checked? and was this a windows error message or an error message from ShutdownPE?
If used from non XP based builds ShutdownPE uses the exact same method of shutdown as old shortcuts.

ShellExecute&#40;@SystemDir & &#34;\Wpeutil.exe&#34;, &#34;shutdown&#34;, @SystemDir, &#34;&#34;, @SW_HIDE&#41;


I do not think problem was with your shutdown script,,, as of the new project update your script appears to work fine,

Thank you .....

#33 paraglider

paraglider

    Gold Member

  • .script developer
  • 1743 posts
  • Location:NC,USA
  •  
    United States

Posted 04 April 2010 - 10:04 PM

shutdownpe is working fine for me using latest build with win 7 x86 as the source.

#34 PaPeuser

PaPeuser

    Silver Member

  • Advanced user
  • 787 posts
  •  
    United States

Posted 04 April 2010 - 10:22 PM

Win7 x64 it does not work,
I have a desktop icon i click and i do get the (lock,shutdown, restart),, but shutdown and restart do not do anything.

wait sorry a late message
The drive is not ready for use; its door maybe open, Please check drive A: and make sure that a disk is inserted and the drive door is closed.

i clicked try again and waited ,, a quick message came up and computer rebooted.. it just took a loooooong time

#35 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 04 April 2010 - 11:51 PM

Win7 x64 it does not work,
I have a desktop icon i click and i do get the (lock,shutdown, restart),, but shutdown and restart do not do anything.

wait sorry a late message
The drive is not ready for use; its door maybe open, Please check drive A: and make sure that a disk is inserted and the drive door is closed.

i clicked try again and waited ,, a quick message came up and computer rebooted.. it just took a loooooong time

is drive A: a valid drive? what drive is your USB mounted as? the only thing I can think is it could possibly have something to do with the file buffer flushing??

#36 PaPeuser

PaPeuser

    Silver Member

  • Advanced user
  • 787 posts
  •  
    United States

Posted 05 April 2010 - 12:19 AM

HI homes32 :whistling:

This may not be a ShutdownPE script problem, since it works on x86
All the trouble JFX and Lancelot have had with shortcuts and drive letters,, I would wait

Both shutdowns (the original) and (yours as an option) are included in latest package.

Win7 still needs testing it is very close but not perfect,

You asked
is drive A: a valid drive? --YES
what drive is your USB mounted as? --USB2 (Y:)

Thinking about it i dont know of many projects that are perfect......

#37 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 05 April 2010 - 01:11 AM

HI homes32 :whistling:

This may not be a ShutdownPE script problem, since it works on x86
All the trouble JFX and Lancelot have had with shortcuts and drive letters,, I would wait

Both shutdowns (the original) and (yours as an option) are included in latest package.

Win7 still needs testing it is very close but not perfect,

You asked
is drive A: a valid drive? --YES
what drive is your USB mounted as? --USB2 (Y:)

Ok I'll hold off for now. let me know if you find anything else.

Thinking about it i dont know of many projects that are perfect......

if they were all perfect they wouldn't be any fun to work on! :blowup:

#38 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 05 April 2010 - 01:45 AM

Hi PaPeuser,

shutdownpe and %cddrive% thingy have no relation with eachother. shutdownpe always runs from ram.
I doubth issue you report have a relation you booting x64 on ufd to test (I guess) and shutdownpe clearing cache of ufd during shutdown......

**I assume you copy content of 7PE_SE_x64.ISO to ufd ( \sources\boot.wim , \Programs\ , ......) and make test with booting this.

but your latest writings gives an idea to me. can you test following.

* extract default Win7PE_SE_04_04_2010.7z
* add following to addons
http://lancelot.winb.....2-Device Y.7z
* open winbuilder
* enable shutdownpe
* hit enable button on "2-Device Y.script"
* make your build
* copy and boot from ufd

shutdownpe --> shutdown, result ?

#39 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 15 April 2010 - 02:29 AM

Script Version 7 released.

this release is mainly to update ShutdownPE.exe to version 1.3.0 adding command line options.


Changes

  • ShutdownPE.exe updated to version 1.3.0 see 1st post for changelog
  • Lock button configuration now has option to use ClearLock as the locker program.

have fun. as usual your feedback is appreciated!

-Homes32

#40 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 15 April 2010 - 06:59 PM

Hi homes32,

[Custom]
LockProgram=ClearLock.exe
does not work ;) , better it works doesn't it ;)

and a request, can we have enviromental variable support, maybe someone (not me) may need
ex:
[Custom]
LockProgram=%ProgramFiles%\blabla\bulubulu.exe

anyway, I use hardcoded path and all works nicely. ;) ;)

edit:
a bit out of subject, can you explain %systemdir% here
If,%pCheckBox_DT%,Equal,True,Add_Shortcut,Desktop,,"%SystemRoot%\System32\ShutdownPE.exe",Shutdown,"%SystemDir%\System32"

#41 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 17 April 2010 - 02:57 AM

[Custom]
LockProgram=ClearLock.exe
does not work ;) , better it works doesn't it ;)

it works for me. do you have the clearlock script enabled???

and a request, can we have enviromental variable support, maybe someone (not me) may need
ex:
[Custom]
LockProgram=%ProgramFiles%\blabla\bulubulu.exe

I'll have to look into that a bit further as it may require some voodoo ;)

edit:
a bit out of subject, can you explain %systemdir% here
If,%pCheckBox_DT%,Equal,True,Add_Shortcut,Desktop,,"%SystemRoot%\System32\ShutdownPE.exe",Shutdown,"%SystemDir%\System32"

its suppost to be %SystemRoot% its fixed now! :(

#42 Galapo

Galapo

    Platinum Member

  • .script developer
  • 3841 posts
  •  
    Australia

Posted 17 April 2010 - 03:16 AM

I'll have to look into that a bit further as it may require some voodoo ;)

Hi homes32

It's rather easy. Run this script and notice the different message box results:
$var = &#34;%ProgramFiles%&#34;

AutoItSetOption&#40;&#34;ExpandEnvStrings&#34;,1&#41;

MsgBox&#40;0,&#34;&#34;,$var&#41;

AutoItSetOption&#40;&#34;ExpandEnvStrings&#34;,0&#41;

MsgBox&#40;0,&#34;&#34;,$var&#41;

Regards,
Galapo.

#43 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 17 April 2010 - 03:36 AM

your right. that was quite easy! thanks! ;)

#44 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 17 April 2010 - 03:41 AM

its suppost to be %SystemRoot% its fixed now! ;)

I thought it was something I do not know about pe2/3 thingies, I am glad it is not ;) , thanks :(

it works for me. do you have the clearlock script enabled???

yep it was. Currently all working ;) I am pretty sure this happened. I will keep in mind to catch when happens again. :(


Can we say scripts (applications) ready ;) , any hint for your progress plans ?

#45 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 17 April 2010 - 04:16 AM

well, I believe ShutdownPE is ready for mainstream use. and I hope to have ClearLock "dressed up" in the next couple days here.

Perhaps then I could open a thread for each in the Downloads/App scripts area where they would be easier for members to find/download and keep these posts here in development for .exe specific development issues/discussion and have script specific issues to the new thread.

#46 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 17 April 2010 - 04:56 AM

updated! ;)

#47 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 20 April 2010 - 12:54 AM

Hi Homes32,

today for another case, I was having real hardware tests hence also tested shutdownpe (tested both v8 and v7 of script with same results)

Shutdown was slow probably due to the error, and in the end there comes a screen with:
(sorry not picture, I write on a paper with pencil :ranting2: )

Title: Windows - Drive Not Ready
Text: The drive is not ready for use ; its door may be open. Please check drive and make sure that a disk is inserted and that the drive door is closed.

I have 2 suspects in mind:
1) my floppy drive is enabled on bios, but I do not have a real floppy hardware, hence on LiveXP I have an unaccessable A:\
(ps: this was an accidantel bios setting, but maybe helped to find something)
(edit2: check here )
2) my raid0 disk(s).
3) ......

edit: no usb device connected during tests.

:ranting2:

#48 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 21 April 2010 - 01:08 AM

Hi Homes32,

today for another case, I was having real hardware tests hence also tested shutdownpe (tested both v8 and v7 of script with same results)

Shutdown was slow probably due to the error, and in the end there comes a screen with:
(sorry not picture, I write on a paper with pencil :ranting2: )

Title: Windows - Drive Not Ready
Text: The drive is not ready for use ; its door may be open. Please check drive and make sure that a disk is inserted and that the drive door is closed.

I have 2 suspects in mind:
1) my floppy drive is enabled on bios, but I do not have a real floppy hardware, hence on LiveXP I have an unaccessable A:\
(ps: this was an accidantel bios setting, but maybe helped to find something)
(edit2: check here )
2) my raid0 disk(s).
3) ......

edit: no usb device connected during tests.

;)


did you use the eject checkbox?

#49 Lancelot

Lancelot

    Frequent Member

  • .script developer
  • 5013 posts
  • Location:Turkiye/Izmir
  • Interests:*Mechanical stuff and Physics,
    *LiveXP, BartPE, SherpyaXPE,
    *Basketball and Looong Walking,
    *Buying outwear for my girlf (Reason: Girls are stupid about buying bad stuff to make themselves uglier :))
    *Girls (Lyric: Girl,...., You will be a womann, Soon)
    *Answering questions for "Meaning of life",
    *Helping people,

    Kung with LiveXP, Fu with Peter :)
  •  
    Turkey

Posted 21 April 2010 - 01:12 AM

did you use the eject checkbox?

absolutely no.

#50 homes32

homes32

    Gold Member

  • .script developer
  • 1035 posts
  • Location:Minnesota
  •  
    United States

Posted 21 April 2010 - 02:26 AM

absolutely no.

I have an Idea. I'll send you a PM with further info.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users