; reboot an nt system
.386
.model flat,stdcall
option casemap:none
;----------------------------------------------------------------
; with ReqNTPrivilege call, we ask for the 'SeShutdownPrivilege'
; note string names of possible privilege are in windows.inc
;----------------------------------------------------------------
invoke ReqNTPrivilege, SADD("SeShutdownPrivilege")
.if eax == FALSE
invoke MessageBox,NULL,addr msg_NotPL,addr AppName,MB_OK
invoke ExitProcess,NULL
.endif
invoke ExitWindowsEx, EWX_REBOOT , 0 ; For Reboot, use EWX_REBOOT
invoke ExitProcess,NULL
What are the possible consequences if I use the EWX-FORCE here. There is a printer program in memory that is delaying the reboot process.
Thanks.
AFAIK, the file/output will be re-spooled/re-started upon re-boot.
Regards, P1 :8)
Quote from: P1 on January 09, 2006, 10:59:55 PM
AFAIK, the file/output will be re-spooled/re-started upon re-boot.
Regards, P1 :8)
This isn't quite working. Do I need to combine it with EWX_REBOOT and if so, how would I do it.
invoke ExitWindowsEx, EWX_FORCE, 0 ; For Reboot, use EWX_REBOOT
invoke ExitProcess,NULL
Thanks.
skywalker,
Here's mine. You will need to add variables. I also had a timeout MessageBox in my program, just in case someone was using the computer at the appointed re-boot time.
Regards, P1 :8)
Clipped from working Code:
;Exit_Reboot:
invoke GetCurrentProcess
invoke OpenProcessToken,eax,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,ADDR hToken
invoke LookupPrivilegeValue,NULL,addr szShut,addr tkp.Privileges[0].Luid
mov tkp.PrivilegeCount,1
mov tkp.Privileges[0].Attributes,SE_PRIVILEGE_ENABLED
invoke AdjustTokenPrivileges,hToken,FALSE, ADDR tkp, 0, NULL, 0
invoke ExitWindowsEx,EWX_REBOOT or EWX_FORCE,0
Quote from: P1 on January 10, 2006, 03:52:57 PM
skywalker,
Here's mine. You will need to add variables. I also had a timeout MessageBox in my program, just in case someone was using the computer at the appointed re-boot time.
Regards, P1 :8)
Clipped from working Code:
;Exit_Reboot:
invoke GetCurrentProcess
invoke OpenProcessToken,eax,TOKEN_ADJUST_PRIVILEGES+TOKEN_QUERY,ADDR hToken
invoke LookupPrivilegeValue,NULL,addr szShut,addr tkp.Privileges[0].Luid
mov tkp.PrivilegeCount,1
mov tkp.Privileges[0].Attributes,SE_PRIVILEGE_ENABLED
invoke AdjustTokenPrivileges,hToken,FALSE, ADDR tkp, 0, NULL, 0
invoke ExitWindowsEx,EWX_REBOOT or EWX_FORCE,0
Thanks.
I just used your last invoke statement above. It rebooted a lot quicker and had no effect on a paused print job
either.