Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The application failed to initialize properly (0xc0000142) ???

Status
Not open for further replies.

tEkHEd

IS-IT--Management
Jan 29, 2003
261
GB
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:

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top