VBS在文件路径3中有空格

时间:2015-01-14 08:49:25

标签: vbscript

我有一个VBS,但文件的路径有一个如下空格,我试过把它放在""但它给出了错误,请帮忙。

Set Objshell=wscript.Createobject("Wscript.Shell")
Objshell.Run "Telnet"
wscript.sleep 100
Strday= left(date,2)
Strmonth = right(left(date,5),2)
StrYear = Right(date,4)
StrHr = Left(Time,2)
StrMin = Right(Left(time,5),2)
StrSec = Right(Time,2)
StrDate=Stryear & StrMonth & StrDay &"_"& StrHr & StrMin & StrSec
Wscript.sleep 1000
Objshell.sendkeys "set Logfile ""L:\09 Phones\Switch_Logs\""" & StrDate & ".txt"
Objshell.sendkeys "~"
Wscript.sleep 1000

它的

Objshell.sendkeys "set Logfile ""L:\09 Phones\Switch_Logs\""" & StrDate & ".txt"

请问我有问题。

1 个答案:

答案 0 :(得分:0)

clear text      :  set Logfile  "L:\09 Phones\Switch_Logs\xxxxxxxxxxxx.txt"
double quotes   :  set Logfile ""L:\09 Phones\Switch_Logs\xxxxxxxxxxxx.txt""
quote as string : "set Logfile ""L:\09 Phones\Switch_Logs\xxxxxxxxxxxx.txt"""
cut for variable: "set Logfile ""L:\09 Phones\Switch_Logs\"           ".txt"""
concatenate     : "set Logfile ""L:\09 Phones\Switch_Logs\"& StrDate &".txt"""

结果

objShell.sendKeys "set Logfile ""L:\09 Phones\Switch_Logs\"& StrDate &".txt"""