fsUK Posted March 27, 2007 Share Posted March 27, 2007 Ive got the following code: CODE $listDrives=DriveGetDrive( "REMOVABLE" ) If NOT @error Then $chk=True Else $chk=False EndIf msgbox (30000,"Removable Device Detected","Removable Device Detected Please Remove") I want to run it as a user logs off of shuts down. To do this i will need to pause the shutdown/logoff until the program finishes. How do i do this? Thanks Link to comment Share on other sites More sharing options...
PaulIA Posted March 27, 2007 Share Posted March 27, 2007 Ive got the following code:CODE$listDrives=DriveGetDrive( "REMOVABLE" ) If NOT @error Then $chk=True Else $chk=False EndIfmsgbox (30000,"Removable Device Detected","Removable Device Detected Please Remove")I want to run it as a user logs off of shuts down. To do this i will need to pause the shutdown/logoff until the program finishes. How do i do this?ThanksAFAIK you can't abort the shutdown or log off sequence. You can delay the shutdown by refusing to terminate your program when asked (which is really rude), but XP will complain that you're not responding and kill you anyway after a brief delay. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Siddhartha Posted March 27, 2007 Share Posted March 27, 2007 lol or, if ur doing this as a prank and feel like corrupting someone's system after many uses, then use the shutdown command... Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted March 27, 2007 Share Posted March 27, 2007 theres an api call that tells windows to abort the shutdown() command, i tried it, and it didn't work for me.. btw how is aborting shutdown() command equivalent to malware.. does it physically stop someone from pulling the plug?? ;Opt("TrayIconHide", 1) $WM_QUERYENDSESSION = 0x0011 GUIRegisterMsg($WM_QUERYENDSESSION, "Cancel_Shutdown") GUICreate("PreventShutdownGUI") GUISetSTate(@SW_HIDE) Global $b_ShutdownInitiated = False While 1 If $b_ShutdownInitiated = True then ;Do stuff here ;do some more stuff here ;DoTheShutDownStuff();maybe do some more stuff here ;Shutdown();Maybe you want to shutdown the computer when done Exit;otherwise, you just exit this script EndIf sleep(10) WEnd Func Cancel_Shutdown($hWndGUI, $MsgID, $WParam, $LParam) ;~ run(@ScriptDir & "\killpgm.exe") $b_ShutdownInitiated = True Return 0 EndFunc Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
fsUK Posted March 28, 2007 Author Share Posted March 28, 2007 (edited) I dont want to abort the shutdown completely. The idea is that this program runs when the user shutsdown/logs off and detects if there is a USB memory or removeable storage still attached. If there is you get a message reminding you to remove it before leaveing. After 30 sec the message times out and the program finishes and log off/shutdown continues. People are very forgetful and are always leaving their USB flash drives pluged in to the network computer they've been using. This is just a way to reduce the number that get handed in as lost/found. How do i get the program to refuse to terminate? That might be the best way. Edited March 28, 2007 by fsUK Link to comment Share on other sites More sharing options...
SadBunny Posted March 28, 2007 Share Posted March 28, 2007 I dont want to abort the shutdown completely.The idea is that this program runs when the user shutsdown/logs off and detects if there is a USB memory or removeable storage still attached. If there is you get a message reminding you to remove it before leaveing. After 30 sec the message times out and the program finishes and log off/shutdown continues.People are very forgetful and are always leaving their USB flash drives pluged in to the network computer they've been using. This is just a way to reduce the number that get handed in as lost/found.How do i get the program to refuse to terminate? That might be the best way.Wouldn't it be more elegant to use windows logoff scripts? Scripts (Startup/Shutdown): Use this extension to specify the scripts that run when you start and shut down the computer. To configure the computer startup and shutdown scripts, start the Group Policy snap-in, expand Computer Configuration, expand Windows Settings, click Scripts (Startup/Shutdown), and then in the right pane, double-click the script that you want to configure. These scripts run on the Local System account. Scripts (Logon/Logoff): Use this extension to specify the scripts that run when a user logs on or logs off the computer. To configure the user logon and logoff scripts, start the Group Policy snap-in, expand User Configuration, expand Windows Settings, click Scripts (Logon/Logoff), and then in the right pane double-click the script that you want to configure. These scripts run on the User account and not on the Administrator account.(Source: http://support.microsoft.com/kb/198642) Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
EndFunc Posted March 29, 2007 Share Posted March 29, 2007 Wouldn't it be more elegant to use windows logoff scripts? (Source: http://support.microsoft.com/kb/198642) Windows XP natively has a shutdown command that you can give a timer to. From a command line, example Shutdown -r -t 30 That will count down 30 seconds then reboot. Put that in a autoit line and you should be able to do what you want. Something like Run(@ComSpec & " /c " & 'Shutdown -r -t 30', "", @SW_HIDE) EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
SadBunny Posted March 29, 2007 Share Posted March 29, 2007 Windows XP natively has a shutdown command that you can give a timer to. From a command line, example Shutdown -r -t 30 That will count down 30 seconds then reboot. Put that in a autoit line and you should be able to do what you want. Something like Run(@ComSpec & " /c " & 'Shutdown -r -t 30', "", @SW_HIDE) I know that... Didn't know you wanted it to be powerful enough to withstand a shutdown -r command. Good luck anyways, I wouldn't know how to break that... Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
EndFunc Posted March 29, 2007 Share Posted March 29, 2007 I know that... Didn't know you wanted it to be powerful enough to withstand a shutdown -r command. Good luck anyways, I wouldn't know how to break that...It's not me that wanted it, I actually meant that post for FsUK. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
tAKTelapis Posted March 29, 2007 Share Posted March 29, 2007 Symantec antivirus can detect a floppy disk on the drive, and refuse access to windows to shutdown if one is found as for running it in the logoff/shutdown scripts via group policy, .exe files do not count sorry. providing you can detect a shutdown in progress, you could always attempt to stop it with: Run(@ComSpec & " /c " & 'Shutdown -a', "", @SW_HIDE) that is the command to abort a shutdown, you could use a VB file to call your .exe on shutdown (though i dare say you would get a "failed to start as the system is shutting down" message ) eitherway, if it detects a drive, it should abort the shutdown. and then after its 30 second timeout, re-invoke the shutdown process. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now