c.haslam Posted August 21, 2008 Share Posted August 21, 2008 Please get me started on this one. I need to write a script that checks whether there are any USB memory sticks plugged in when the user does Start | Shut Down. If there are any, it should warn the user and not shut down....chris Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
TehWhale Posted August 21, 2008 Share Posted August 21, 2008 In my examples script listing, in my signature there is a .au3 file called: DoSomethingAtShutdown.au3 download that, thats how you can do something at shutdown. Now, to check if theres a memory stick inserted you would need to use DriveGetType or something simalir, or check if like you have a certain hidden file like: E:\hiddenfile.dat then you could use the: DoSomethingAtShutdown.au3, and then: If FileExists("E:\hiddenfile.dat") Then MsgBox(0, "Warning!", "Remove your memory stick now! then press OK!") Hope this helps! Let me know if you need any more help! Link to comment Share on other sites More sharing options...
zFrank Posted August 21, 2008 Share Posted August 21, 2008 use it to detect and check USB $DISK = DriveGetDrive("REMOVABLE") For $I = 1 To $DISK[0] $STATS = DriveStatus($DISK[$I]) If $STATS = "READY" Then MsgBox(0, "Warning!", "Remove your memory stick now! then press OK!") Else Next [font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php$Life = "Happy" If @Error Then $Life = "Risk" Link to comment Share on other sites More sharing options...
c.haslam Posted August 26, 2008 Author Share Posted August 26, 2008 Many thanks to both of you. I would be nice to have a way of aborting the shut down if there is a memory stick inserted. Any ideas? ...chris Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard Link to comment Share on other sites More sharing options...
dbzfanatic Posted August 26, 2008 Share Posted August 26, 2008 (edited) Try this. $DISK = DriveGetDrive("REMOVABLE") For $I = 1 To $DISK[0] $STATS = DriveStatus($DISK[$I]) If $STATS = "READY" Then Run(@ComSpec & "shutdown -a") MsgBox(0, "Warning!", "Remove your memory stick now! then press OK!") Else Next Not tested yet (I don't normally use @ComSpec so if I used it improperly someone please post the correct usage) but you should get the idea. Edited August 26, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
rasim Posted August 26, 2008 Share Posted August 26, 2008 c.haslamTry this:Global Const $WM_QUERYENDSESSION = 0x0011 Global $Msg = False GUICreate("Dummy", 1, 1) GUIRegisterMsg($WM_QUERYENDSESSION, "WM_QUERYENDSESSION") While 1 If $Msg Then $Msg = False MsgBox(0, "Warning!", "Remove your memory stick!") EndIf Sleep(100) WEnd Func WM_QUERYENDSESSION($hWndGUI, $MsgID, $WParam, $LParam) Local $DISK, $STATS, $i $DISK = DriveGetDrive("REMOVABLE") If @error Then Return True For $i = 1 To $DISK[0] $STATS = DriveStatus($DISK[$i]) If $STATS = "READY" Then $Msg = True Return 0 EndIf Next Return True EndFunc Link to comment Share on other sites More sharing options...
c.haslam Posted September 4, 2008 Author Share Posted September 4, 2008 Many thanks to all. I think I can see all that I need to do. ...chris Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard 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