tom
tom

Reputation: 507

Process name change at runtime (C++)

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.

Upvotes: 5

Views: 8269

Answers (3)

Joe B
Joe B

Reputation: 1

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.

Upvotes: 7

Josh Weatherly
Josh Weatherly

Reputation: 1730

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

Upvotes: 1

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43110

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.

Upvotes: 1

Related Questions