我需要从用户(串)一个输入,并在cmd命令插入,
Set oShell = WScript.CreateObject("WScript.Shell")
Set LabelName = WScript.CreateObject("WScript.Shell")
LabelName = InputBox("Please Enter Label to check-out:", _
"Create File")
oShell.run "cmd /K ""c:\Program Files (x86)\Borland\StarTeam Cross-Platform Client 2008 R2\stcmd.exe"" co -p bla:bla123@123.com:7777/bla/ -is -eol on -o -rp D:\ST_test -cfgl 3.1.006"
输入的是“标签”,它应该插入,而不是“3.1.006”
我不能设法插入这个变量,它使插入标签,而不是价值
标签并不需要是一个shell对象,因为它只是一个字符串 。 然后将字符串连接到运行命令和你做。
Set oShell = WScript.CreateObject("WScript.Shell")
Dim LabelName
LabelName = InputBox("Please Enter Label to check-out:", _
"Create File")
oShell.run "cmd /K ""c:\Program Files (x86)\Borland\StarTeam Cross-Platform Client 2008 R2\stcmd.exe"" co -p bla:bla123@123.com:7777/bla/ -is -eol on -o -rp D:\ST_test -cfgl " & LabelName
以更结构化的方式建立你的命令 - 例如:
Option Explicit
Function qq(s) : qq = """" & s & """" : End Function
Dim sLabel : sLabel = "default label"
Dim oWAU : Set oWAU = WScript.Arguments.Unnamed
If 1 <= oWAU.Count Then sLabel = oWAU(0)
Dim sCmd : sCmd = Join(Array( _
"%comspec%" _
, "/K" _
, qq("c:\Program Files (x86)\Borland\StarTeam Cross-Platform Client 2008 R2\stcmd.exe") _
, "co" _
, "-p bla:bla123@123.com:7777/bla/" _
, "-is -eol on -o -rp" _
, qq(sLabel) _
))
WScript.Echo sCmd
并显示额外的变量SCMD。 固定(可能的)失误 -
ient 2008 R2\stcm
---------^^^
“关于第二个想法”加法 -
, qq(sLabel) _
==>
, qq("D:\ST_test") _
, "-cfgl" _
, sLabel _
和引用会容易得多。