Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Process name change at runtime (C++)

Tags:

c++

winapi

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.

like image 693
Tom Johnson Avatar asked Jun 25 '09 13:06

Tom Johnson


3 Answers

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.

like image 74
Joe B Avatar answered Sep 28 '22 09:09

Joe B


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

like image 43
Josh Weatherly Avatar answered Sep 28 '22 08:09

Josh Weatherly


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.

like image 42
Nick Dandoulakis Avatar answered Sep 28 '22 08:09

Nick Dandoulakis