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
然后,我要在这个路径下的子目录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
...全文
相关推荐
VBS读写文件及创建、删除文件
VBS读写文件及创建、删除文件
VBS读写及创建、删除文件
VBS读写文件以及创建文件后在删除该文件
VBS复制一个文件夹到本地,并在桌面建立快捷方式
从网络共享中复制文件夹到本地,并建立快捷方式, 特别适合不需要绿色版软件在网络中的安装。
vbs表白文件
vbs 表白文件,里面有我微博的一个说话表白的还有一个是不同意无限循环,大家还是去我微博找吧。本来打算设置1积分的,忘了改了。结果现在改不了了
VBS脚本大全
VBS脚本常用代码整理,VBS是基于Visual Basic的脚本语言。VBS的全称是:Microsoft Visual Basic Script Edition。(微软公司可视化BASIC脚本版)


