Suggestion for a spawning a remote process

  • Thread starter andrew_webby at hotmail
  • Start date
A

andrew_webby at hotmail

Hi

I'm working on an app that I will use to target and install patches
remotely for testing purposes (and also to get a bit more experience
of VB.Net). Given that MS supply their patches as .EXE's, it doesn't
look like I can use Win32_Product to install them (MSI only
apparently).

Am wondering what the best way to go about the spawning and monitoring
of this installation might be?

Thoughts I'd had so far include:

Schedule the job remotely, then keep checking the process list to see
when it's finished. (Untidy)

Schedule remotely, monitor the event log for information (won't work -
can't monitor events remotely, can only keep reading them..)

Was hoping the Process component would help (Start, onExited), but it
won't spawn remotely either.

Any suggestions for a decent way to go about kicking off an EXE
remotely (of course, I have all access permissions needed as domain
admin) and monitoring to see when it finishes?

I've a feeling this is one of those questions whose answer is
blindingly obvious, so I'm expecting a flash of inspiration seconds
after I hit "post".. :)

TIA

AW
 
A

andrew_webby at hotmail

Hi

I'm working on an app that I will use to target and install patches
remotely for testing purposes (and also to get a bit more experience
of VB.Net). Given that MS supply their patches as .EXE's, it doesn't
look like I can use Win32_Product to install them (MSI only
apparently).

Am wondering what the best way to go about the spawning and monitoring
of this installation might be?

Thoughts I'd had so far include:

Schedule the job remotely, then keep checking the process list to see
when it's finished. (Untidy)

Schedule remotely, monitor the event log for information (won't work -
can't monitor events remotely, can only keep reading them..)

Was hoping the Process component would help (Start, onExited), but it
won't spawn remotely either.

Any suggestions for a decent way to go about kicking off an EXE
remotely (of course, I have all access permissions needed as domain
admin) and monitoring to see when it finishes?

I've a feeling this is one of those questions whose answer is
blindingly obvious, so I'm expecting a flash of inspiration seconds
after I hit "post".. :)

And it did come. Damnit. Here's the solution I got towards. "pc"
should be a "." if spawning on your local machine.

Function runRemote(ByVal pc As String) as Boolean
Dim options = New ConnectionOptions
options.EnablePrivileges = True
options.Authentication = AuthenticationLevel.Call
options.Impersonation = ImpersonationLevel.Impersonate

Dim scope = New ManagementScope("\\" + pc + "\root\cimv2")
scope.Connect()

Dim processClass = New ManagementClass("Win32_Process")
processClass.Scope = scope

Dim inParams = processClass.GetMethodParameters("Create")

Dim startup = New ManagementClass("WIN32_ProcessStartup")
startup.Scope = scope

inParams("CommandLine") = "\\server\share\app /switches"
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams,
Nothing)

runRemote = (outParams("ReturnValue") = 0)
Debug.WriteLine("CreateProcess returned :" +
outParams("ReturnValue").ToString())
Debug.WriteLine("ProcID is " &
outParams("ProcessID").ToString)
End Function

With this in mind, does anyone have a good reference on how to
translate the above (which is easy in WMI) into it's .NET equivalent,
as I'm very familiar with WMI and VBS, but translating the above into
..NET involved a hell of a lot of reading and googling yesterday. I
couldn't have reached that without the newsgroups postings or some
article that explains the translation process.

Anyone?
 
A

andrew_webby at hotmail

[email protected] (andrew_webby at hotmail) wrote in message news: said:
inParams("CommandLine") = "\\server\share\app /switches"
inParams("ProcessStartupInformation") = startup
Dim outParams = processClass.InvokeMethod("Create", inParams,
<snip>

Argh. I found out that when starting a process remotely that connects
to a network share, it doesn't work. Get's "Access is denied". It's
definitely not a permissions either on NTFS or the network share in
question.

I checked this with a "cmd /c dir \\server\share>>c:\log.log 2>&1" and
the error it throws back is "Access is denied". I also tried a WHOAMI
as the process and it shows the remote procedure is running as "me".
So, it appears that although "I" am running the process remotely, I
don't have all my permissions.

Can someone help with a spot of advice here? It seems like I'm
sandboxed to the machine I'm trying to run the process from, but
that's a showstopper as of course the patches I'm remotely installing
won't be on their local machines to start with. Copying them there
first is not a possibility due to network topology.

I really hope there's a workaround to this, or if it's a known issue
or whatever.

Thanks in advance

AW
 

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

Top