start batch file from within vb.net as admin

Chris Wilson picture Chris Wilson · Jul 16, 2012 · Viewed 16.9k times · Source

In my application, I need to run a batch file as admin for it to function.
I'm using this so far but I cant remember how to use the runas feature which allows it to run with admin rights.

process.start("filelocation.bat")

Any help would be apreciated.

Answer

user1244772 picture user1244772 · Jul 16, 2012
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