在Win10上睡眠后删除注册表项值

时间:2018-05-22 09:47:47

标签: windows vbscript registry

我需要在程序启动后删除注册表值。所以,为了实现这个目的,我写了这个小脚本:

On Error Resume Next
Const HKEY_CURRENT_USER = &H80000001

Set wshShell = CreateObject("WScript.Shell")
strComputer = "."

Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\SQL Server Management Studio\14.0"
strValueName = "UserFeedbackOptIn"

wshShell.Run("""%PROGRAMFILES(x86)%\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe""")

wshShell.Sleep 3*60*1000
objRegistry.DeleteValue HKEY_CURRENT_USER, strKeyPath, strValueName
Set wshShell = Nothing

问题是 - " wshShell.Sleep"。经过一番调查后,我发现3分钟是完成这项任务的。

,仅适用于Win7。当在Win10上运行相同的脚本时,密钥不会被删除。而且我不知道为什么......非常感谢任何提示或想法。

0 个答案:

没有答案
相关问题