create hidden txt file with vbs

佐手、 提交于 2019-12-06 07:17:26

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!