Link to home
Start Free TrialLog in
Avatar of Kelly Martens
Kelly Martens

asked on

WMI Remote Server File Path To Execute Script in ASP.NET webservice

I am trying to use WMI to run a script on a remote server with a vb,net ASP.NET webservice. I connect fine to the server. But I know from a log entry that works locally that the log entry is not being recorded on the remote server so it is not executing. I think somehow the path to the file is in error. If anyone can help I would be very grateful. I don't think it is permissions as for now I have given access to 'Everybody' so I could rule that out.

'\\dev-sql-a\ShippingSystem\Wave
        CreateProcess("DEV-SQL-A", "C:\\ShippingSystem\\Wave\\Wave.vbs", "Domain\Username", "password")
        ' CreateProcess("DEV-SQL-A", "C:\ShippingSystem\Wave\Wave.vbs", "Domain\Username", "password")


<code>
Private Sub CreateProcess(ByVal strComputer As String, ByVal strProcess As String, ByVal UserName As String, ByVal Password As String)

        Dim processBatch As ManagementClass = New ManagementClass("Win32_Process")
        Dim inParams As ManagementBaseObject = processBatch.GetMethodParameters("Create")
        Dim msc As ManagementScope

        inParams("CurrentDirectory") = Nothing
        inParams("CommandLine") = strProcess
        Dim co As ConnectionOptions = New ConnectionOptions()
        co.Username = UserName
        co.Password = Password

        Try
            If (strComputer = System.Environment.MachineName) Then
                msc = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2")
            Else
                msc = New System.Management.ManagementScope("\\" & strComputer & "\root\cimv2", co)
            End If

            msc.Connect()
            processBatch.Scope = msc
            Dim meyhodoptions As InvokeMethodOptions = New InvokeMethodOptions(Nothing, System.TimeSpan.MaxValue)
            Dim outParamas As ManagementBaseObject = Nothing
            outParamas = processBatch.InvokeMethod("Create", inParams, Nothing)

        Catch ex As Exception

        End Try
    End Sub
<code/>
Avatar of Kyle Santos
Kyle Santos
Flag of United States of America image

Hi,

I am following up on your question.  Do you still need help?

If you solved the problem on your own, would you please post the solution here in case others have the same problem?

Regards,

Kyle Santos
Customer Relations
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.