Win32_Process.Create -- not starting process

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Feb 15 09:27:32 EST 2006


[abcd]

|    Ok, well I verified that my python script and batch script are
| working properly.  In fact, if I double click on the batch 
| script (when its on Computer B), it starts the python script and the
script runs
| fine with no problem.

That's all very well, and it does confirm that there's no
obvious error in the file, but by running the batch script
*on* the computer it's on, you're running it in a particular
environment / context etc. That environment isn't (necessarily)
the same when you're running it across WMI.

All I'm saying is that remotely executed jobs tend to be
sensitive to environment issues which one is usually
unconcerned about. This is as true for cron jobs or
ssh-initiated execution on Unix as it is for WMI or
service-driven execution under Windows.

| However when I try to execute the batch script from computer A
| using WMI it doesnt start.  I say that because the python script that
| gets executed writes a status message to a file, and that does not
| occur as well as Python.exe does not show up in the task manager, even
| though Win32_Process.Create returns a PID and a 0 for the return code.
| So, if I try the same process a second time...it works.  python.exe is
| running, status message is written to a file, etc.  Is there some sort
| of initialization that needs to be done?

Ok. That's certainly peculiar. I assume that the pid / zero-return
is because the batch script itself is run; it's only the python
script which isn't. Which doesn't explain why it runs the second
time.

Some obvious test cases:

1) If you have the batch script write something out to file by itself,
does that happen? (eg SET > c:\temp.txt). Note - make sure the log
file destination is absolute, ie c:\temp.txt, not just temp.txt.

<test.cmd>
SET > c:\temp\test.txt
</test.cmd>

2) If you bypass the batch altogether, does that work, eg

<code>
import wmi
c = wmi.WMI ()
c.Win32_Process.Create (CommandLine=r"c:\python24\python
c:\temp\test.py")
</code>

If this isn't getting you anywhere, could you post up
or send me privately your batch and python scripts?

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list