#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;}
ShutdownPE
#26
Posted 29 March 2010 - 06:01 PM
#27
Posted 29 March 2010 - 11:09 PM
#28
Posted 30 March 2010 - 01:39 PM
Thank you, NtShutdownSystem function from NTDLL.DLL worksThat's correct. ExitWindowsEx does not work in PE. In PE you have to call the kernel NtShutdownSystem function in ntdll.dll
#29
Posted 30 March 2010 - 01:56 PM
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.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
#31
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(@SystemDir & "\Wpeutil.exe", "shutdown", @SystemDir, "", @SW_HIDE)
#32
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(@SystemDir & "\Wpeutil.exe", "shutdown", @SystemDir, "", @SW_HIDE)
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
Posted 04 April 2010 - 10:04 PM
#34
Posted 04 April 2010 - 10:22 PM
I have a desktop icon i click and i do get the (lock,shutdown, restart),,
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
Posted 04 April 2010 - 11:51 PM
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??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
#36
Posted 05 April 2010 - 12:19 AM
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
Posted 05 April 2010 - 01:11 AM
Ok I'll hold off for now. let me know if you find anything else.HI homes32
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:)
if they were all perfect they wouldn't be any fun to work on!Thinking about it i dont know of many projects that are perfect......
#38
Posted 05 April 2010 - 01:45 AM
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
Posted 15 April 2010 - 02:29 AM
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
Posted 15 April 2010 - 06:59 PM
[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
Posted 17 April 2010 - 02:57 AM
it works for me. do you have the clearlock script enabled???[Custom]
LockProgram=ClearLock.exe
does not work , better it works doesn't it
I'll have to look into that a bit further as it may require some voodooand a request, can we have enviromental variable support, maybe someone (not me) may need
ex:
[Custom]
LockProgram=%ProgramFiles%\blabla\bulubulu.exe
its suppost to be %SystemRoot% its fixed now!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"
#42
Posted 17 April 2010 - 03:16 AM
Hi homes32I'll have to look into that a bit further as it may require some voodoo
It's rather easy. Run this script and notice the different message box results:
$var = "%ProgramFiles%" AutoItSetOption("ExpandEnvStrings",1) MsgBox(0,"",$var) AutoItSetOption("ExpandEnvStrings",0) MsgBox(0,"",$var)
Regards,
Galapo.
#43
Posted 17 April 2010 - 03:36 AM
#44
Posted 17 April 2010 - 03:41 AM
I thought it was something I do not know about pe2/3 thingies, I am glad it is not , thanksits suppost to be %SystemRoot% its fixed now!
yep it was. Currently all working I am pretty sure this happened. I will keep in mind to catch when happens again.it works for me. do you have the clearlock script enabled???
Can we say scripts (applications) ready , any hint for your progress plans ?
#45
Posted 17 April 2010 - 04:16 AM
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
Posted 17 April 2010 - 04:56 AM
#47
Posted 20 April 2010 - 12:54 AM
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 )
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.
#48
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 )
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
Posted 21 April 2010 - 01:12 AM
absolutely no.did you use the eject checkbox?
#50
Posted 21 April 2010 - 02:26 AM
I have an Idea. I'll send you a PM with further info.absolutely no.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users