ychi1987 Posted October 3, 2011 Share Posted October 3, 2011 Hi All. Im sorry because my english is not well. I want a scrip that auto kill process runing in usb, and auto unplug usb. Can anyone give me some idea ) Tks a lot ^^ Link to comment Share on other sites More sharing options...
rcmaehl Posted October 3, 2011 Share Posted October 3, 2011 As far as I know there is no Windows equivalent of lsof which means the only way to kill the process running on a usb is if you know the process name. My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
Ramzes Posted October 3, 2011 Share Posted October 3, 2011 (edited) @ychi1987 'I want a script' - it isn't script request forum. You can ask for advice but not for full script. To get process path you should try use this:Func _ProcessGetLocation($iPID) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If $aProc[0] = 0 Then Return SetError(1, 0, '') Local $vStruct = DllStructCreate('int[1024]') DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0) Local $aReturn = DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048) If StringLen($aReturn[3]) = 0 Then Return SetError(2, 0, '') Return $aReturn[3] EndFunc To get an array of currently running processes you should use:$Process = ProcessList() And write For... Next loop which checks each process path. If process is from USB then kill it using ProcessClose. Edited October 3, 2011 by Ramzes Sorry for my bad English but nobody is perfect. [font=arial, helvetica, sans-serif]Ramzes[/font] 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