vb.netrunas

Run batch file from VB.NET as administrator


In my VB-NET application I need to run a batch file as administrator.

So far I use this code but can't remember how to use runas:

process.start("filelocation.bat")

Any help is apreciated.


Solution

  • Try
        Dim procInfo As New ProcessStartInfo()
        procInfo.UseShellExecute = True
        procInfo.FileName = (FileLocation)
        procInfo.WorkingDirectory = ""
        procInfo.Verb = "runas"
        Process.Start(procInfo)
    Catch ex As Exception
        MessageBox.Show(ex.Message.ToString())
    End Try