I'm coding a new VBS script, which should create a TXT file in the Documents directory. While with other inputs I used %USERNAME% for the User Name of the PC, the command "CreateTextFile" seems to want the real directory, without including any variables like %USERNAME%.
I'm kinda of new to this so I can't figure it out.
That's what I tried:
Dim objFS, objFile
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFile = objFS.CreateTextFile("C:\Users\%USERNAME%\Documents\Demo.txt", true)
objFile.WriteLine("some sample text")
It should understand %USERNAME% as the UserName of the PC, but doesn't.
What I get as result is the program saying he can't find the directory C:\Users\%USERNAME%\Documents.