tags:

views:

612

answers:

4

Is it possible to change the name(the one that apears under 'processes' in Task Manager) of a process at runtime in win32? I want the program to be able to change it's own name, not other program's. Help would be appreciated, preferably in C++. And to dispel any thoughts of viruses, no this isn't a virus, yes I know what I'm doing, it's for my own use.

A: 
Peter Ruderman
+1  A: 

I found code for doing that in VB. I believe it won't be too hard to convert it to C++ code.

A good book about low level stuff is Microsoft Windows Internals.

And I agree with Peter Ruderman

This is not something you should do.

Nick D
+1  A: 

I know you're asking for Win32, but under most *nixes, this can be accomplished by just changing argv[0]

Josh W.
ahhh simplicity :)
Tom
Sorry, what's argv? and a *nix?
tiddlydum
By *nix, I mean most of the various Unix variants, Linux, FreeBSD and the such. argv is the name of the variable used to hold the command line in a unix shell, it's an array of strings where argv[0] refers to the name the program
Josh W.
+3  A: 

I would like to submit what i believe IS a valid reason for changing the process name at runtime:

I have an exe that runs continuously on a server -- though it is not a service. Several instances of this process can run on the server. The process is a scheduling system. An instance of the process runs for each line that is being scheduled, monitored and controlled. Imagine a factory with 7 lines to be scheduled. Main Assembly line, 3 sub assembly lines, and 3 machining lines.

Rather than see sched.exe 7 times in task manager, it would be more helpful to see: sched-main sched-sub1 sched-sub2 sched-sub3 sched-mach1 sched-mach2 sched-mach3

This would be much more helpful to the Administrator ( the user in this situation should never see task manager). If one process is hung, the Administrator can easily know which one to kill and restart.

Joe B