'================================================================== '指定パスで Regeditを(再)起動 'http://palm84.hatenablog.com/entry/20160212/1455265675 'http://www10.plala.or.jp/palm84/wsh.html 'http://www10.plala.or.jp/palm84/archives/wsh/Regedit2Path.vbs.txt 'https://eu7w9wsmf6a74xyjdfzl3q-on.drv.tw/archives/wsh/Regedit2Path.vbs.txt '================================================================== Option Explicit 'HKCR\.txt 'HKCU\Software\Microsoft\Windows\CurrentVersion\Run 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 'HKU\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Run 'HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit ' レジストリ LastKey へ指定キーを書き込み Const regLastKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit\LastKey" Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") Dim strRegKey strRegKey = myInput objShell.RegWrite regLastKey, strRegKey, "REG_SZ" ' regedit.exe が起動中なら終了させる Const strComputer = "." 'ホスト名(ローカル コンピュータ) Dim objWMIService, colProcessList,objProcess Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'regedit.exe'") For Each objProcess in colProcessList objProcess.Terminate() Next ' regedit.exe を起動 Set objWMIService = Nothing objShell.Run "regedit.exe", 1 Set objShell = Nothing '********************************************************* 'Function myInput '********************************************************* Function myInput() myInput = InputBox("パスを入力してください", "指定パスで Regeditを(再)起動") If IsEmpty(myInput) Then WScript.Quit If myInput = "" Then myInput End If myInput = Replace(myInput, "HKCU", "HKEY_CURRENT_USER") myInput = Replace(myInput, "HKLM", "HKEY_LOCAL_MACHINE") myInput = Replace(myInput, "HKU", "HKEY_USERS") myInput = Replace(myInput, "HKCR", "HKEY_CLASSES_ROOT") End Function