Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables 我需要帮助创建一个VBscript,可以从一个可变位置运行bat文件_Variables_Vbscript_Scripting_Environment Variables - Fatal编程技术网

Variables 我需要帮助创建一个VBscript,可以从一个可变位置运行bat文件

Variables 我需要帮助创建一个VBscript,可以从一个可变位置运行bat文件,variables,vbscript,scripting,environment-variables,Variables,Vbscript,Scripting,Environment Variables,我试图创建一个由两部分组成的脚本。脚本的第一部分将搜索应用程序的安装路径,并将其另存为变量strValue。剧本的这一部分效果很好。我希望脚本的下一部分从存储在strValue中的位置启动批处理文件。这是让我绊倒的部分。我觉得我把事情弄得比实际需要的复杂得多。请告知 以下是我目前的脚本: Option Explicit Dim strComputer, oReg, strKeyPath, strValueName, strValue, WshShell, ObjEnv, objExec,

我试图创建一个由两部分组成的脚本。脚本的第一部分将搜索应用程序的安装路径,并将其另存为变量strValue。剧本的这一部分效果很好。我希望脚本的下一部分从存储在strValue中的位置启动批处理文件。这是让我绊倒的部分。我觉得我把事情弄得比实际需要的复杂得多。请告知

以下是我目前的脚本:

Option Explicit

Dim strComputer, oReg, strKeyPath, strValueName, strValue, WshShell, ObjEnv, objExec,     strFolderPath, 


Const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Greenshot_is1"
strValueName = "InstallLocation"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

'Uncomment the following line to verify the install location is chosen properly
Wscript.Echo "Current Install Location: " & strValue
'
''''''''''''''''''''''''''''''''''''''''''''''''
'run batch file from strValue location

假设
strValue
包含批处理文件的完整路径,可以使用以下方法:

strValue
周围的双引号用于处理带有空格的路径

如果
strValue
只包含没有文件名的路径,则可以如下构造完整路径:

CreateObject("WScript.Shell").Run """" & strValue & "\batchfile.bat""", 0, True

我需要将batchfile.bat附加到strvalues,非常感谢您的帮助。非常感谢。
CreateObject("WScript.Shell").Run """" & strValue & "\batchfile.bat""", 0, True