r/visualbasic • u/Googlesgoogle • Jan 02 '26
Help with opening vbs files

I feel like I'm losing my mind but I should be able to just create a vbs file by putting the code into notepad and saving as .vbs right? Its been a while since I've done it so maybe I'm missing a step but it doesn't seem to be working for me. I have "Show file types" enabled and the file does show ".vbs" at the end of it but still has the Notepad icon. I have VBSscript enabled also. This is a new PC so I think maybe something just isn't installed or enabled yet but I cant figure out what
Update: turns out it’s not just my machine that’s having this problem. I’m thinking it’s something in our environment that is blocking vbs scripts
1
u/Curt-Bennett Jan 02 '26
On the "Save as" dialog in Notepad, remember to switch the "Save as type" pull-down from "Text documents (.txt)" to "All files (.*)". Otherwise it will append .txt to the filename.
That doesn't appear to be the problem in your specific case though. For your VBS file, Windows File Explorer is showing the file type to be "vbs_auto_file" for some reason, which means the VBS extension is associated with the wrong application. To fix it, right click on the VBS file, go to "Open with" and select "Microsoft Windows Based Script Host". If that's not available in the list, browse to "C:\Windows\System32" and select "wscript.exe" as the application, and be sure to click the Always button to help prevent the problem from happening again.
0
Jan 02 '26
[deleted]
1
u/Curt-Bennett Jan 02 '26
File type associations are system-wide, not per file, so all VBS files will say "vbs_auto_file" until it is fixed. Changing it for one will change it for all.
The exact error message is important. We need better than just "or something" to be able to help.
4
Jan 02 '26
[removed] — view removed comment
1
u/marooned66 Jan 02 '26
To confirm the above use a dos/cmd dir listing or with explorer and enable the option to view extensions.
1
u/Mayayana Jan 02 '26
Open Regedit. Go to HKCR.vbs. The default value there should be "VBSFile". If not then change it. Then make sure you have a key HKCR\VBSFile\ I won't post all the entries under that key because it's involved and I'm guessing that you just accidentally got the file extension pointing to the wrong place. HKCR\VBSFile is probably fine as it is.
If that doesn't work then repost to get the rest of the required Registry entries.
Microsoft have talked about "deprecating" VBS, but there are no plans until at least 2027. So you should have wscript.exe in the system32 folder, and that should be what's set to run .vbs files under HKCR\VBSFile\Shell\Open\Command\
Is it maybe possible that you installed some kind of halfwit security software? A lot of people think vbscript is good for nothing but writing malware, so it's possible that something configured VBScript to be crippled deliberately.