我目前有一个vbscript,可以在目录中创建一个txt文件并打开它,但是id想要创建该文件,以便隐藏该文件, 简而言之,我有这段代码:
Set objFSO=CreateObject("Scripting.FileSystemObject")
outFile="C:\Users\User\Desktop\New map"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test line 1" & vbCrLf
objFile.Write "test line 2" & vbCrLf
objFile.Close
CreateObject("WScript.Shell").Run("""C:\Users\User\Desktop\New map""")
答案 0 :(得分:1)
您可以这样设置属性
Const cHidden = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
outFile = "C:\Users\User\Desktop\New map"
Set objFile = objFSO.CreateTextFile(outFile, True)
objFile.Write "test line 1" & vbCrLf
objFile.Write "test line 2" & vbCrLf
objFile.Close
Set mapFile = objFSO.GetFile(outFile)
mapFile.Attributes = cHidden
CreateObject("WScript.Shell").Run Chr(34) & outFile & Chr(34)
快速参考-> https://www.thevbprogrammer.com/ch06/06-09-fso.htm https://ss64.com/vb/filesystemobject.html