Win32_Process.Create -- not starting process

A

abcd

I am using Python to create a process on another computer. Both
computers are on the same domain with admin privileges.

On computer B I have a batch script which starts a python script. From
computer A I am doing the following:

import wmi
w = wmi.WMI("1.2.3.4")
p = w.new("Win32_Process")
pid, retVal = p.Create(CommandLine="C:\\a_script.bat")
print pid, retVal

The output I get is, 1218 0 ....0 = "Successful Completion"
.....however the python script that is called from the batch script
never seems to run or at least only for a split second. Sometimes I
see python.exe appear in the task manager on computer B for a split
second then it goes away. So I went to computer B and double clicked
on the batch script, and sure enough a command opened up and the python
script was running...and stayed running...no problem. I should
mention, that sometimes it will execute the batch script and the Python
script will run and stay running. That has only happened after trying
to do "p.Create(CommandLine....)" more than once, but not every time I
try.

Any ideas why its not working for me remotely....or why its random?
These are win xp machines with no firewalls running.
 
E

EShames

I am using Python to create a process on another computer. Both
computers are on the same domain with admin privileges.

On computer B I have a batch script which starts a python script. From
computer A I am doing the following:

import wmi
w = wmi.WMI("1.2.3.4")
p = w.new("Win32_Process")
pid, retVal = p.Create(CommandLine="C:\\a_script.bat")
print pid, retVal

The output I get is, 1218 0 ....0 = "Successful Completion"
.....however the python script that is called from the batch script
never seems to run or at least only for a split second. Sometimes I
see python.exe appear in the task manager on computer B for a split
second then it goes away. So I went to computer B and double clicked
on the batch script, and sure enough a command opened up and the python
script was running...and stayed running...no problem. I should
mention, that sometimes it will execute the batch script and the Python
script will run and stay running. That has only happened after trying
to do "p.Create(CommandLine....)" more than once, but not every time I
try.

Any ideas why its not working for me remotely....or why its random?
These are win xp machines with no firewalls running.

Troubleshooting context issues seems the right track. Consider:

-Start a_script.bat using %windir%\system32\runas.exe ([/noprofile |
/profile] [/env] [/netonly] Play with parameters to set and explore
context issues.

-Use the (well respected) psexec.exe from Sysinternals to confirm
remote execution using another means.

-Also from Sysinternals get and use ProcessExplorer, FileMon, TDIMon
and TCPMon

Other (possibly insulting to mention, please forgive) win batch
troubleshooting steps:
-REM out "@echo off" if any.

-Place a strategic "pause" in the batch to hold the command window open.

-Direct output from commands in the bat to a file "set >
c:\temp\bat_out1.txt" then look at the creator, owner, etc.


Prophylactic measures & things that effect the user context behavior:
-Check "launch folder windows in a seperate process" in
Explorer/Tools/Folder Options/View or you will not be able to run
explorer.exe as an alternate user.
-Uncheck "use simple file sharing" in same as above.


FWIW Getting runas to to fire cmd.exe, then a .bat can be tricky, I use
this to wrap runas, maybe it will help:
<rnas.bat>
:: Wrapper for runas.exe
:: If called with a parameter use it as target, otherwise start cmd.exe
:: !Note: /savecred is is convenient, but not very secure!
:: LAST EDIT EBS 2006-02-10

::mad:echo off

:: !Change _USER to domain and user to run as!
set _USER=domain\user

if %1! == ! (
%SYSTEMROOT%/system32/runas.exe /savecred /noprofile /user:%_USER%
"cmd.exe cd /D c:\\\_utils\"
goto END
) else (
%SYSTEMROOT%/system32/runas.exe /savecred /user:%_USER% "%~f1"
)

:END
::DIAGNOSTIC
pause
exit
</rnas.bat>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top