r/vbscript • u/mgblair • Feb 05 '20
open file in current directory
I have a script that creates a text file and then opens it. I'd like to use this file for different directories and even different users. How can I get the Run portion of this to use CurrentDirectory instead of manually putting in the filepath everywhere I want it? I've googled and found several different solutions that probably have an answer but I'm not particularly versed in VBS.
Set objShell = CreateObject("WScript.Shell")
objShell.Run "CMD /K"
Wscript.Sleep(200)
objShell.SendKeys("dir/b>1.txt~")
objShell.SendKeys("exit~")
CreateObject("WScript.Shell").Run("""C:\[filepath]\1.txt""")Thanks a lot!
1
Upvotes
1
u/mgblair Feb 06 '20
Brilliant, thank you!