Sign in to follow this  
Followers 0
fsUK

Pause shutdown/logoff

10 posts in this topic

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

Share this post


Link to post
Share on other sites



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

AFAIK 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

Share this post


Link to post
Share on other sites

lol or, if ur doing this as a prank and feel like corrupting someone's system :whistle: after many uses, then use the shutdown command... :P

Share this post


Link to post
Share on other sites

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()

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by fsUK

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

:whistle:


EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0