Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

runas - start batch file from within vb.net as admin

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...