我创建了包含自定义内容的新文件。但它没有运行。 (保存文件名" CustomerList.hta")
请帮我解决。
<script language="VBScript">
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Dim tfolder, tname, tfile
Const TemporaryFolder = 2
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
Set tfile = tfolder.CreateTextFile("Customers.txt")
Set outFile = tfile
outFile.WriteLine "This first line"
outFile.WriteLine "The full path file is: " & tfile
outFile.WriteLine "This is last line"
outFile.Close
</script>
答案 0 :(得分:0)
重构为:
'<script language="VBScript">
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Dim tfolder, tname, tfile
Const TemporaryFolder = 2
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
'Set tfile = tfolder.CreateTextFile("Customers.txt")
sFSpec = fso.BuildPath(tfolder, "Customers.txt")
WScript.Echo sFSpec
'Set tfile = fso.CreateTextFile("Customers.txt")
Set tfile = fso.CreateTextFile(sFSpec)
Set outFile = tfile
outFile.WriteLine "This first line"
'outFile.WriteLine "The full path file is: " & tfile
outFile.WriteLine "The full path file is: " & sFSpec
outFile.WriteLine "This is last line"
outFile.Close
'</script>
输出:
cscript 46349646.vbs
C:\Users\eh\AppData\Local\Temp\Customers.txt
type C:\Users\eh\AppData\Local\Temp\Customers.txt
This first line
The full path file is: C:\Users\eh\AppData\Local\Temp\Customers.txt
This is last line
使用文档(不是一厢情愿的想法)来确定谁可以做什么。
答案 1 :(得分:0)