vbs创建一个文件

jonesliu7618 CSDN会员 jonesliu7618 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我想要写一个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
...全文

相关推荐

评论 14
收藏 已收藏
分享
返回顶部
jonesliu7618 CSDN会员
JavaScript 87,984 成员 224,681 内容