EDN Admin
Well-known member
Hi, I need to run a bat file in Windows 7 as adminsitrator. If I run it manually as administrator from a cmd window, it works, but launched from my application, it doesn´t work. Because of that I need my application runs that bat file in an elevated mode.
This code, seen in similar posts, doesn´t work:
<p style="margin:0in 0in 0pt; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Try
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Dim<span style="font-family:Courier New; font-size:10pt procInfo
<span style="color:blue As <span style="color:blue New ProcessStartInfo()
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.UseShellExecute =
<span style="color:blue True
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.FileName =
<span style="color:#a31515 "CMD.bat"
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.WorkingDirectory =
<span style="color:#a31515 ""
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.Verb =
<span style="color:#a31515 "runas"
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt Process.Start(procInfo)
<p style="margin:0in 0in 0pt; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Catch<span style="font-family:Courier New; font-size:10pt ex
<span style="color:blue As Exception
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt MessageBox.Show(ex.Message.ToString())
<p style="margin:0in 0in 10pt <span style="color:blue; line-height:115%; font-family:Courier New; font-size:10pt End<span style="line-height:115%; font-family:Courier New; font-size:10pt
<span style="color:blue Try
<p style="margin:0in 0in 10pt Thank you very much.<span style="line-height:115%; font-family:Courier New; font-size:10pt <span style="color:blue
View the full article
This code, seen in similar posts, doesn´t work:
<p style="margin:0in 0in 0pt; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Try
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Dim<span style="font-family:Courier New; font-size:10pt procInfo
<span style="color:blue As <span style="color:blue New ProcessStartInfo()
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.UseShellExecute =
<span style="color:blue True
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.FileName =
<span style="color:#a31515 "CMD.bat"
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.WorkingDirectory =
<span style="color:#a31515 ""
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt procInfo.Verb =
<span style="color:#a31515 "runas"
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt Process.Start(procInfo)
<p style="margin:0in 0in 0pt; line-height:normal <span style="color:blue; font-family:Courier New; font-size:10pt Catch<span style="font-family:Courier New; font-size:10pt ex
<span style="color:blue As Exception
<p style="margin:0in 0in 0pt 0.5in; line-height:normal <span style="font-family:Courier New; font-size:10pt MessageBox.Show(ex.Message.ToString())
<p style="margin:0in 0in 10pt <span style="color:blue; line-height:115%; font-family:Courier New; font-size:10pt End<span style="line-height:115%; font-family:Courier New; font-size:10pt
<span style="color:blue Try
<p style="margin:0in 0in 10pt Thank you very much.<span style="line-height:115%; font-family:Courier New; font-size:10pt <span style="color:blue
View the full article