Is it possible to set the process name with pythonw?

0

1

I am using a piece of software written in Python and am using the Task Scheduler in WHS2011 to run it as a background process. Unfortunately it appears as "pythonw.exe" in the task list. It doesn't cause me a massive problem, but it would be nice if I could tell it what process name to use.

Is this possible via the command line to pythonw.exe?

Antony Scott

Posted 2012-05-22T21:53:15.713

Reputation: 407

Answers

2

No, it is not currently possible to set the task manager image name via a command line switch to pythonw.exe. Issue 5672 and others cover discussions about doing so.

There are some projects focused on making this possible from within your python program, like py-setproctitle. I haven't played around with them.

The Java solution is to create a launcher, either one that embeds all the Java code with the bootstrap interpreter into one exe or one that acts like java(w).exe and points to your Java classes. There are similar projects to do the same for Python like py2exe.

A simpler way to change the image name and "make your own launcher" is to make a copy of pythonw.exe named whatever you like, eg. mytask.exe. I have tested this with the copy/renamed exe in the PythonNN directory and in other directories and it runs fine and changes the Image Name in Task Manager. I haven't tested it from Task Scheduler in WHS2011.

jla

Posted 2012-05-22T21:53:15.713

Reputation: 134

1

You can find py2exe here.

– jla – 2012-08-24T23:23:58.270

0

No. Unlike ps in Unix, the "Image Name" field in Task Manager and other process management programs always contains the executable's name.

To get around this, you could create a symlink myapp.exe in the Python directory, and point to pythonw.exe.

user1686

Posted 2012-05-22T21:53:15.713

Reputation: 283 655

1this doesn't change the name in the "Image Name" column, it still says "pythonw.exe". oh well. – Antony Scott – 2012-05-23T08:11:59.350

I'm not quite sure why this answer got an upvote when it clearly doesn't work! – Antony Scott – 2012-05-23T08:21:40.053