批处理脚本管理员身份运行 [英] Batch Script to Run as Administrator

查看:1026
本文介绍了批处理脚本管理员身份运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个客户机/服务器检查程序,但它需要以管理员身份运行。
我想这是我的网络和用户的静默方式运行,而我不希望运行方式管理员提示。
有没有开始code,我可以放入批处理文件,使其自动以管理员身份运行/

I'm writing a client/server checking program but it needs to run as Administrator. I want this to run silently on my network and users, and I don't want the "Run as" Administrator" prompt. Is there any beginning code that I can place into the batch file to make it auto-run as Administrator/

推荐答案

NOPE - 本 - 创建一个快捷方式[ - >兼容性 - >运行此程序作为管理员。解决方案不起作用

NOPE - The - create a shortcut [ -> Compatibility -> "run this program as an administrator" ] solution does not work.

这个选项是灰色的在Windows 7即使UAC被禁用

This option is greyed out in Windows 7. Even with UAC disabled

-

NOPE - 在运行方式/ ENV /用户:域\\管理员

NOPE - The, "runas /env /user:domain\Administrator "

也是不够的,因为它会提示输入管理员用户输入密码。

is also not sufficient because it will prompt the user for the admin password.

-

YES - 禁用UAC - >使用任务计划程序创建作业

YES - Disable UAC -> Create a job using task scheduler

这为我工作:
根据创建任务调度工作,并使其运行与管理员权限的用户。
明确标注:使用最高权限运行
禁用UAC所以会有任何提示运行此任务

This worked for me: Create a job under task scheduler and make it run as a user with administrator permissions. Explicitly mark: "Run with highest privileges" Disable UAC so there will be no prompt to run this task

您可以让脚本使UAC事后通过编辑,如果你想注册表。
在我的情况下,这个脚本由创建Windows虚拟机,其中UAC映像中禁用的只跑了一次。

You can let the script enable UAC afterwards by editing the registry if you would want. In my case this script is ran only once by creation of a windows virtual machine, where UAC is disabled in the image.

还在期待为以管理员身份运行脚本,最好的办法,但无太多的麻烦。

Still looking forward for the best approach for a script run as admin without to much hassle.

这篇关于批处理脚本管理员身份运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆