i currently have a vbscript that creates a txt file in a directory and opens it, but id like to make it so that the file is hidden, currtly i have this code:
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""")
You can set the attribute like this
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)
Quick Reference --> https://www.thevbprogrammer.com/ch06/06-09-fso.htm https://ss64.com/vb/filesystemobject.html
来源:https://stackoverflow.com/questions/53635108/create-hidden-txt-file-with-vbs