AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

List of Processes

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Libertytoad



Joined: 02 Apr 2006
Posts: 7

PostPosted: Sun Apr 02, 2006 5:47 pm    Post subject: List of Processes Reply with quote

Hi,

I just started using AHK and it's a great tool for small programs I can develop and write from my USB drive.

Something I'd like to see is the ability to get a list of the running Processes and perhaps the drive/location the process started from (if possible). Perhaps this could be done in a loop structure like the registry and file folder loops.

I have a situation where I want to shut down processes started from my USB drive, but don't want to shut down processes from the PC I am on. Perhaps this is an odd request, but I think others would find a list of processes useful--especially since processes with different PID's can have the same executable names.

Thanks for one of the best free tools I've seen in recent years.


Last edited by Libertytoad on Sun Apr 02, 2006 6:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5382
Location: /b/

PostPosted: Sun Apr 02, 2006 5:55 pm    Post subject: Re: List of Processes Reply with quote

Libertytoad wrote:
Something I'd like to see is the ability to get a list of the running Processes and perhaps the drive/location the process started from (if possible).
shimanov already created a script like this: process list+file names+command lines
_________________

Back to top
View user's profile Send private message Visit poster's website
Libertytoad



Joined: 02 Apr 2006
Posts: 7

PostPosted: Sun Apr 02, 2006 6:03 pm    Post subject: Reply with quote

Nice. Thanks.

This will do nicely until (fingers crossed) it gets built in to AHK.
Back to top
View user's profile Send private message
jordis



Joined: 30 Jul 2004
Posts: 79

PostPosted: Mon Apr 24, 2006 9:34 pm    Post subject: Reply with quote

Hi Libertytoad

In a similar manner, I was also looking for a way to identify the open processes/files in my USB stick in order to be able to close them before removing the USB stick.

Titan's suggestion (shimanov's script) is great, but it will only identify *processes* started from the USB drive, but not open files.
For example, if I open an Excel file from my USB drive, shimanov's script (and other tools I tried) will only list that process C:\Program Files\...\EXCEL.EXE is running, but *not* that it is locking a file from the USB drive. If you try to "unplug/eject hardware", it will say that it's not possible (since Excel is still locking the file from the USB drive).

Looking around I found Handle:
http://www.sysinternals.com/Utilities/Handle.html
This command-line tool will let you know which files are actually open, as well as processes.
Now, in my case, issuing
Code:
handle -a harddisk1
will list the open files/processes in my USB drive.
"harddisk1" may vary from one computer to another (depending on the already-installed drives)
In order to find out which harddisk is mapped to the USB drive, one could create a AHK script that whould issue:
Code:
handle -a AHKscriptname
where AHKscriptname would be the name of the script you're launching (be sure it's launched from the USB drive!)
Then parse the output (so now we would know which harddisk is mapped to our USB drive) and then issue another handle call to list the open processes/files in that harddisk
Finally, the script could parse the opened files, compile a list and tell users that they to close those files to be able to remove their USB stick

I hope you got the idea Wink

regards
jordi
Back to top
View user's profile Send private message
Libertytoad



Joined: 02 Apr 2006
Posts: 7

PostPosted: Mon Apr 24, 2006 11:23 pm    Post subject: Thanks Reply with quote

Jordi,

Thanks for the good info, I'll give it a try.

Regards,

Tom (aka LibertyToad)
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Tue Apr 25, 2006 7:27 am    Post subject: Reply with quote

Quote:
DriveGet
--------------------------------------------------------------------------------
Retrieves various types of information about the computer's drive(s).

DriveGet, OutputVar, Cmd [, Value]

Cmd:
List [, Type] : Sets OutputVar to be a string of letters, one character for each drive letter in the system. For example: ACDEZ. If Type is omitted, all drive types are retrieved. Otherwise, Type should be one of the following words to retrieve only a specific type of drive: CDROM, REMOVABLE, FIXED, NETWORK, RAMDISK, UNKNOWN.
That way you should be able to identify the USB-Drive (without to run a script from it in advance) and handover the relevant drive parameter to be "Handled".Good luck. Smile
Back to top
jordis



Joined: 30 Jul 2004
Posts: 79

PostPosted: Tue Apr 25, 2006 5:23 pm    Post subject: Reply with quote

Bobo
thanks for the idea, I didn't know this useful AHK command.

However, I didn't find any option that would tell me the info I need to pass to the Handle command: whether the USB drive is "harddisk1", "harddisk2", etc.
You see, this is an example output I get from Handle.exe.
Command issued:
Code:
handle -a harddisk1
Output:
Code:
Handle v3.11
Copyright (C) 1997-2005 Mark Russinovich
Sysinternals - www.sysinternals.com

System             pid: 8        C4: \Device\Harddisk1
PStart.exe         pid: 1056     18: \Device\Harddisk1\DP(1)0-0+9\PortableApps
EXCEL.EXE          pid: 2288    2E0: \Device\Harddisk1\DP(1)0-0+9\Excel_doc.xls
miranda32.exe      pid: 2452     18: \Device\Harddisk1\DP(1)0-0+9\PortableApps\Apps\PortableMiranda\miranda
strokeit.exe       pid: 2252     18: \Device\Harddisk1\DP(1)0-0+9\PortableApps\Apps\Strokeit

So, with the driveget AHK command I could know that the USB drive is H: or I: or J: and so on, but *not* that it is mapped to "Harddisk1"
I believe no AHK command would tell me this info, right?
regards
jordi
Back to top
View user's profile Send private message
evl



Joined: 24 Aug 2005
Posts: 1239

PostPosted: Tue Apr 25, 2006 7:02 pm    Post subject: Reply with quote

You could try looking in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum

I think that's where I found the info to detect when my usb headset was plugged in. Maybe it contains enough info to help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group