Problems Creating Process on Remote System with WSH

Le
woodchuckomega
Greetings all,
I am attempting to create a script that will create a process on a
remote system. The code that I have right now is as follows:

strComputer = "FrontDesk2"
Set objWMIService = GetObject("winmgmts:\" & strComputer &
"ootcimv2:Win32_Process")
errReturn = objWMIService.Create("file.exe", null, null, intProcessID)
If errReturn = 0 Then
Wscript.Echo "file.exe was started with a process ID of " &
intProcessID & "."
Else
Wscript.Echo "file.exe could not be started due to error " &
errReturn & "."
End If

This script was taken from Listing 14.10 on page 961 of the Windows
2000 Scripting Guide. As it stands now, this script works correctly
when the 'strComputer' variable is changed and applied to the local
computer. When attempting to manipulate the remote computer, the script
still outputs "file.exe was started with a process ID of ####" but the
application does not launch on the remote computer.

Examination of the Task Manager on the remote computer shows the
creation of a NTVDM.exe process every time the script is run. So since
the Dos Virtual Machine is being started, the script is at least able
to make contact with the remote computer. I assume therefore that I am
dealing with a permissions issue.

The original script in the book included the following code on line 2,
inside the GetObject statement:
"{impersonationLevel=impersonate}!\"
With this code included, the script was repeatedly generating 80041021
errors on that line, which various websites identify as a syntax error.
Removing that section of code eliminates the syntax error, but I'm
guessing its also what's causing the permissions problems that's not
letting the script run on the remote system.

Anyone have any ideas? Thanks :)
Vos réponses
Gagnez chaque mois un abonnement Premium avec GNT : Inscrivez-vous !
Trier par : date / pertinence
woodchuckomega
Le #475478
Modifying my own question as I continue to poke at it...

Looking at several other examples of code that I've found on Google
Groups, I've taken the original code for Line 2 from the scripting
book:

Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\" & strComputer &
"rootcimv2:Win32_Process")

And have modified it as such, so that it now appears as:

Set objWMIService GetObject("winmgmts:{impersonationLevel=impersonate}!\" & strComputer
& "rootcimv2:Win32_Process")

Doing this has had the following results:
-eliminated the 80041021 syntax error that I was getting
-Script still runs correctly when run on the local computer
-When targeted to the remote computer, the 'success' Windows Script
Host box is still displayed, a NTVDM.exe process is still created on
the remote system, and the desired process is still not created on the
remote system.

Thanls for any help.
Branden
Publicité
Poster une réponse
Anonyme