Hi there..
I get this error when trying to invoke a remote process on a client.
I am sending the remote command via the Win32_Process.Create method using a ManagementObject
I think that this is due to the fact that the EXE resides on the network and that I am performing a 'Double Hop' with my credentials.
1st Hop (credentials passed) - connect into remote WMI namespace
2nd Hop (credentials not passed) - invoke the EXE from a share.
Can anyone help out here? the code that I am using is as below:
I get this error when trying to invoke a remote process on a client.
I am sending the remote command via the Win32_Process.Create method using a ManagementObject
I think that this is due to the fact that the EXE resides on the network and that I am performing a 'Double Hop' with my credentials.
1st Hop (credentials passed) - connect into remote WMI namespace
2nd Hop (credentials not passed) - invoke the EXE from a share.
Can anyone help out here? the code that I am using is as below:
Code:
Dim coptions As New ConnectionOptions
Dim scope As New ManagementScope(New ManagementPath("\\" & Host & "\root\cimv2"), coptions)
coptions.Authentication = AuthenticationLevel.Default
coptions.EnablePrivileges = True
coptions.Impersonation = ImpersonationLevel.Impersonate
coptions.Username = "Domain\Username"
coptions.Password = "myPassword"
scope.Options = coptions
'Command at this stage is something like \\server\share\exename.exe /silent
Try
scope.Connect()
Dim processPath As New ManagementPath("Win32_Process")
Dim processClass As New ManagementClass(scope, processPath, New ObjectGetOptions(context))
Dim inParams As ManagementBaseObject = processClass.GetMethodParameters("Create")
Command = Mid(Command, 1, Len(Command) - 1)
inParams("Commandline") = "cmd /c " & QUOTE & Command & QUOTE
Console.WriteLine(inParams("CommandLine"))
Dim outParams As ManagementBaseObject = processClass.InvokeMethod("Create", inParams, Nothing)
Console.WriteLine(outParams("ReturnValue"))
Catch e As Exception
Console.WriteLine("Failed to connect: " + e.Message)
End Try