Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run batch file from VB.NET as administrator

Tags:

vb.net

runas

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.

like image 948
Chris Wilson Avatar asked Sep 21 '25 02:09

Chris Wilson


1 Answers

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
like image 51
user1244772 Avatar answered Sep 23 '25 10:09

user1244772