Run Batch file as administrator - Windows 7 - Command “Run As” from network file system

荒凉一梦 提交于 2019-12-05 04:32:00

It's a little bit tricky but it can be done.

First you have to know (from the batch file) if the user is an administrator. If it is then you can simply go on with installation. If it's not you can run another cmd.exe instance to run the batch file as administrator (using the runas command).

To detect if the user is an administrator take a look to this post: http://www.tomshardware.co.uk/forum/169421-36-determine-batch-file-user-administrator (there is the full code to elevate the batch itself too).

Not the same thing.

There's a difference between elevating your own scope of permissions and just running within your scope if you are in the administrators group.

Simply using runas /user:username@domain.com program.exe seems not to be the same as right-clicking then selecting "Run as Administrator".

Rustam

There is a way to do this in PowerShell:

PS> Start-Process powershell -Verb runAs
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!