1 Previous Next 

Start a process


To start a process is easy.

Be aware to set an import to system.diagnosics



Untitled 1

       'The arguments are only for the sample at the bottom.

        'All samples are apart pieces therefore by copying you get now 

        'errors because the p is to often declared.

 

        'Word

        Dim p As New Process

        Dim pi As New ProcessStartInfo

        pi.Verb = "print"

        pi.WindowStyle = ProcessWindowStyle.Hidden

        pi.FileName = "C:\filename.doc"

        pi.UseShellExecute = True

        p.StartInfo = pi

        p.Start()

 

        'Notepad

        Dim p As New Process

        Dim pi As New ProcessStartInfo

        pi.arguments = "c:\windows\win.ini"

        pi.FileName = "notepad.exe"

        p.startinfo = pi

        p.Start()

 

        'Internet Explorere

        Dim p As New Process

        Dim pi As New ProcessStartInfo

        pi.FileName = "http://msdn.microsoft.com"

        p.StartInfo = pi

        p.Start()

 

        'Registry

        Dim p As New Process

        Dim pi As ProcessStartInfo = New ProcessStartInfo

        pi.FileName = "regedit"

        pi.Arguments = "/S C:\yourRegFile.reg"

        p.StartInfo = pi

        p.Start()

 

        'Get the contents of a page

        Dim p As New Process

        Dim pi As New ProcessStartInfo

        pi.UseShellExecute = False

        pi.RedirectStandardOutput = True

        pi.Arguments = "www.google.com"

        pi.WorkingDirectory = "C:\windows\system32"

 

        'this for nt* computers 

        pi.FileName = "ping"

        p.StartInfo = pi

        p.StartInfo = pi

        p.Start()

        Dim sr As IO.StreamReader = p.StandardOutput

        Dim sb As New System.Text.StringBuilder("")

        Dim input As Integer = sr.Read

        Do Until input = -1

            sb.Append(ChrW(input))

            input = sr.Read

        Loop

        MessageBox.Show(sb.ToString)

 

        'with arguments

        If args.Length > 0 Then

            If args(0).ToUpper = "\S" Then

                MessageBox.Show(args(1))

            End If

        Else

            Dim p As New Process

            Dim pi As New ProcessStartInfo

            pi.Arguments = "\S Hello"

            pi.FileName = "KD"

            p.StartInfo = pi

            p.Start()

        End If

 




1 Previous Next