如何提升 vbs 以删除注册表项 [英] How do I elevate vbs to delete a Registry key

查看:44
本文介绍了如何提升 vbs 以删除注册表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是错误的代码

WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\cFos\test\tvalue"

这是我的错误
错误:无法删除注册表项HKLM\SOFTWARE\test".
代码:800070005来源:WshShell.RegDelete

This is my error
Error: Unable to remove registry key "HKLM\SOFTWARE\test".
Code: 800070005 Source: WshShell.RegDelete

我认为我需要在 Win Vista/7/8 中禁用 UAC,但我想知道是否有办法以管理员身份直接运行 .vbs 文件.因为我需要分发它,人们可能不喜欢禁用他们的 UAC,如果我明确指示取消他们的防御,有些人甚至可能认为这是恶意的

I gather that I need to disable UAC in Win Vista/7/8 but I was wondering if there is a way to directly run the .vbs file as administrator. Because I need to distribute it and people might not like disabling their UAC and some might even think this is malicious if I give an explicit instruction to pull down their defense

推荐答案

使用下面的命令行创建一个新的快捷方式文件.

Create a new shortcut file using below command line.

runas /profile /user:administrator cscript myscript.vbs

或...

runas /profile /user:administrator cscript "C:\Script Collection\My Script.vbs"

然后您只需双击快捷方式文件即可使用管理员帐户执行脚本.

You can then simply double click the shortcut file to execute the script using Administrator account.

快捷方式每次都会提示输入管理员密码.如果您希望它完全自动化,请改用以下命令行.

The shortcut will prompt for Administrator password each time. If you want it to fully automate it, use below command line instead.

runas /profile /savecred /user:administrator cscript myscript.vbs

它会提示输入密码,但只有一次.下次运行它就不会再提示了.

It will prompt for the password, but only once. The next time you run it, it will not prompt it again.

这篇关于如何提升 vbs 以删除注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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