0

I have randomly bumped into this as I can clearly see that PATH variable is not populated in the process that I'm now starting as a service on Windows 11, while the same exact script when started from cmd works perfectly fine.

That said I was not able to find any official confirmation of this odd behaviour.

Does anybody know if this is expected behaviour on Windows 11 (and perhaps earlier versions too)?

5
  • There are so many details you are leaving out here. Like running a script as a service under windows. What user account? How are you verifying that it isn't populated? Not a big deal to work with.. but important details. I will say that a normal process can't run without an environment block and that block defaults with being populated by the environment block of the parent. You probably can't SEE it's PATH environment variable. If you are using proc explroer, look at the loaded DLLs. How did those get loaded without a path? Commented Mar 21 at 20:10
  • Basically it's a BAT file with a command which looks like this "python %~dp0\myscript.py" and the script fails with "python" not found error. That said python is 100% is part of the PATH variable and that exact BAT file executes fine without issue from CMD Commented Mar 22 at 21:18
  • Why not add the entire path to pyhon to the command? AND Why run it from a batch file? Commented Mar 25 at 17:51
  • The workaround is clear and I did exactly as you said - hardcoded path to python, but I'm curious as to the absence of the variables is some known feature, I've dealt with Windows for over 20 years now and have not been aware of something like that Commented Mar 27 at 10:36
  • My only guess you probably have already exhausted. That python is in your USER path and that thingamajigger is being run as a different user thus not picking up the path. Thats all I gotz. :-P Have a good one. Commented Mar 27 at 12:25

0

You must log in to answer this question.

Browse other questions tagged .