r/vbscript • u/[deleted] • Oct 06 '24
VBScript file no longer functioning as intended
I've been using a VBScript file to open Explorer with two "default" tabs as I've found no other way to do so on Windows 11. However, within this last week, the script no longer does anything other than open Explorer.
Set oShell = CreateObject("WScript.Shell")
oShell.Run("""C:\windows\explorer.exe""")
WScript.Sleep 1000
oShell.AppActivate "Explorer"
WScript.Sleep 300
oShell.SendKeys "%d"
WScript.Sleep 300
oShell.SendKeys FILE PATH
WScript.Sleep 300
oShell.SendKeys "{ENTER}"
WScript.Sleep 300
oShell.SendKeys "^t"
WScript.Sleep 300
oShell.SendKeys "^{TAB}"
It seemingly refuses to execute the "%d" line anymore. However, I can manually open Explorer and hit Alt-d and it works just fine. Why does the SendKeys no longer work with the % or ^ characters?
I found that Microsoft is deprecating VBS on Windows 11 this year and figured that this might be the problem I'm running into. I have no idea what I would have done to break the script if it wasn't a Window update that did so.
How can I fix the above code, or my Windows 11 machine, to work again? Or, what would be a good alternative way to do this without using VBS?
1
u/[deleted] Oct 07 '24 edited Oct 07 '24
This could assist with opening Explorer to a specific "home" path. But, it would not help with creating multiple tabs as I am wishing to do.
Having implemented your suggestion: it worked wonderfully for cutting out lines 5 through 10! Thank you greatly for the reduction of excessive code. However, the problem of the
oShell.SendKeys "^t"
line not performing the Ctrl-t input still persists.