vbs创建一个文件
我想要写一个VBS脚本,首先从文件path.txt中读取到一个路径 ,比如读取到"C:\Program Files (x86)\System Protect Software\"
然后,我要在这个路径下的子目录ShutdownScript下创建一个文件remotecomputer.txt,并写入字串test
我的代码如下,但是为何老提示路径错误呢?是不是路径中有双引号呢?
pathname="path.txt"
Set fso1 = CreateObject("scripting.FileSystemObject")
if (fso1.fileexists(pathname)) then
set ts1=fso1.opentextfile(pathname,1,true)
end if
strpath=ts1.readline
ts1.Close
filename=strpath+"\ShutdownScript\remotecomputer.txt"
Set fso = CreateObject("scripting.FileSystemObject")
if (fso.fileexists(filename)) then
set ts=fso.opentextfile(filename,8,true)
ts.WriteLine ("test")
ts.Close
else
Set ts = fso.CreateTextFile(filename, True)
ts.WriteLine ("test")
ts.Close
end if