gseller Posted June 24, 2009 Share Posted June 24, 2009 Hey All, Been a while since I posted anything so Here is a small USB Monitor I put together with most corporate worlds turning off autorun feature which is a good thing. I hate having to go to my gomputer each time I slap in a flashdrive. This small script can be running in background and sees the drive and alerts you then opens the root folder. This way no autorun stuff is invoked but you get quick access to your drive. ;#NoTrayIcon $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colEvents = $objWMIService.ExecNotificationQuery _ ("Select * From __InstanceOperationEvent Within 5 Where " _ & "TargetInstance isa 'Win32_LogicalDisk'") While 1 $objEvent = $colEvents.NextEvent If $objEvent.TargetInstance.DriveType = 2 Then Select Case $objEvent.Path_.Class()="__InstanceCreationEvent" SplashTextOn( "", "DRIVE: " & $objEvent.TargetInstance.DeviceId & " INSERTED, OPENING ROOT FOLDER."& @CR, 300, 75, -1, -1,17 ) Sleep(2000) SplashOff() $val = ShellExecute("", "", $objEvent.TargetInstance.DeviceId, "open") Case $objEvent.Path_.Class()="__InstanceDeletionEvent" SplashTextOn( "", "DRIVE: " & $objEvent.TargetInstance.DeviceId & " HAS BEEN REMOVED."& @CR, 300, 75, -1, -1,17 ) Sleep(2000) SplashOff() EndSelect EndIf WEnd Sort and sweet. Hope it is handy for someone... Link to comment Share on other sites More sharing options...
PeterAtkin Posted January 14, 2010 Share Posted January 14, 2010 (edited) Awsome thanks this is just what i was looking for your a life saver.. Edited January 14, 2010 by PeterAtkin [topic='115020'] AD Domain Logon Script[/topic] Link to comment Share on other sites More sharing options...
rajeshontheweb Posted January 17, 2010 Share Posted January 17, 2010 (edited) its nice, but one suggestion, i would like the use of $val = Run("explorer.exe /e ," & $objEvent.TargetInstance.DeviceId ) rather than open verb because in many a case, if the autorun virus has already infected the pc, then u would end up with this. Edited January 17, 2010 by rajeshontheweb Started late is much better than having never started it!!!!Failure is another step towards success. I've been messing around with: Adding Entry to 'Hosts'File Information Lister (Logger)Yet Another AutoIT Error Handler Yet Another AutoIT Error Handler & Debugger Control your App's TaskBar Button YCurrency Ticker (Latest Release : 16 Apr 2009)_WinInetInternetCheckConnection UDF Symantec Definitions Lister UDF _GetLocalIPAddresses UDF UDF to get Special Folder Information WMI_NetworkAdapterConfiguration2Array WMI_CDRomDriveCapabilities _ScriptExists - Check if your au3 script is running!! Uninstaller UDF Get Version for your application (at script level or compiled stage) Uninstaller Pro - faster alternative to windows application removal applet Link to comment Share on other sites More sharing options...
dmob Posted January 18, 2010 Share Posted January 18, 2010 Wonderful, this is useful; I have also turned off autorun in my cafe so this will save time for me and my customers. Thanks for sharing. 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