Skip to main content

Start Process on Remote Machine in VB.Net

In this article we will use WMI Provider for Start a "Process on Remote Machine". You can use CreateProcess procedure, this procedure has verious parameters:
  • Computer Name
  • Process Name
  • UserName
  • Password
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 Management.ManagementScope("\\" & strComputer & "\root\cimv2")
            Else
                msc = New 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

Some Useful Links
http://msdn.microsoft.com/en-us/library/system.management.invokemethodoptions.aspx
http://msdn.microsoft.com/en-us/library/Aa389388

Popular posts from this blog

Ping Network Computer in VB.Net

"Ping" is very basic utility for every network programmer. Here we will discuss ping a computer in Network using VB.Net. We have two methods for pinging a computer. Method 1: Here we will use VB.Net NetworkInformation NameSpace. Public Sub PingStatus(ByVal strComputer As String) Dim pingSender As Ping = New Ping() Dim options As PingOptions = New PingOptions() options.DontFragment = True 'Create a buffer of 32 bytes of data to be transmitted Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Dim buffer As Byte() = Encoding.ASCII.GetBytes(data) Dim timeout As Integer = 120 Dim reply As PingReply = pingSender.Send(strComputer, timeout, buffer, options) If (reply.Status = IPStatus.Success) Then MessageBox.Show("Ping Successed.") Else MessageBox.Show("Ping Faild.") End If End Sub Method 2: Here we are using .Net inbuil

GridView Paging and Sorting

Introduction Paging and Sorting are most commonly used features of ASP.Net GridView. And it is very easy to implement in GridView with small lines of code. Here I am going to demonstrate how to use Paging and Sorting in GridView for better use of data display.