0

Possible Duplicate:
start batch file from within vb.net as admin

I have created an application. I need to start a program using vb.net as administrator. I know you can use runas and I did this a couple of days ago but I really cant remember the code to run it as admin. Can you please help

I do not have their user or password. I just want it to bring up a box asking if they would like to give permission for this to happen.

Im not onabout my application been run as admin. im onabout starting another program from mine as admin..

process.start("C:\filename.bat")

Community
  • 1
  • 1
user1244772
  • 294
  • 4
  • 9
  • 22
  • See [start batch file from within vb.net as admin](http://stackoverflow.com/questions/11502696/start-batch-file-from-within-vb-net-as-admin). – GSerg Jul 16 '12 at 11:02
  • 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 – user1244772 Jul 16 '12 at 14:06

2 Answers2

1

I know this is a mention to another post, but you should check this blog: http://dukelupus.wordpress.com/2011/01/25/how-to-force-net-application-to-run-as-an-administrator-on-windows-7vista/

Update app.manifest:

Change this:

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

To this:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Xcalibur37
  • 2,305
  • 1
  • 17
  • 20
  • Im not onabout my application been run as admin. im onabout starting another program from mine as admin.. process.start("C:\filename.bat") – user1244772 Jul 16 '12 at 07:09
  • That will likely not be possible without being regulated by the operating system. However, if you run your local app as an admin, the context will transfer to any spawned applications hence fulfilling your requirement. – Xcalibur37 Jul 17 '12 at 00:28
  • The link to the SO article above is about the only other way. – Xcalibur37 Jul 17 '12 at 00:30
-1

If the program is already installed you can modify the program icon or shortcut.

Program icon: Right Click>Properties>Compatibility>Run this program as an administrator

Shortcut: Right Click>Properties>Shortcut>Advanced>Run as administrator

These instructions are for Windows 7. Might be slightly different for other versions of Windows.

SSS
  • 4,807
  • 1
  • 23
  • 44
  • Im not onabout my application been run as admin. im onabout starting another program from mine as admin.. process.start("C:\filename.bat") – user1244772 Jul 16 '12 at 07:09