仅用一个脚本将文件添加到HKEY_CURRENT_USER Autorun和HKEY_LOCAL_MACHINE

时间:2018-08-01 15:59:17

标签: vbscript

我有这个VBScript:

On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
myKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\example"
WshShell.RegWrite myKey, "C:\Program Files (x86)\example.exe", "REG_SZ"
Set WshShell = Nothing

添加

  

“ C:\ Program Files(x86)\ example.exe”

到启动注册表

  

“ HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \ example”

现在我也想添加

  

“ C:\ Program Files(x86)\ example.exe”

到启动注册表

  

“ HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ Run \ example”

如何仅用一个VBScript做到这一点?

我试图只修改以下代码:

On Error Resume Next
Set WshShell = CreateObject("WScript.Shell")
myKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run\example"
WshShell.RegWrite myKey, "C:\Program Files (x86)\example.exe", "REG_SZ"
Set WshShell = Nothing

,以便将程序添加到HKEY_LOCAL_MACHINE,然后将其粘贴到下面,但这没用。

1 个答案:

答案 0 :(得分:0)

    Dim wshShell
    Dim myKey

    Set wshShell = CreateObject("WScript.Shell")
    myKey = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\example"

    wshShell.RegWrite myKey, "C:\Program Files (x86)\example.exe", "REG_SZ"