0

I'm trying to make a vbscript that silently starts wsl for me.

This is what I have now:

Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "wsl -u root service dbus start" & Chr(34), 0
Set WinScriptHost = Nothing

If instead of a command with arguments, I just want to run a single executable (so only one word within the quotes) this structure works, but the above gives me The system cannot find the file specified at line 3. I'm guessing it's trying to execute and executable that's called the whole thing, instead of executing wsl and passing the parameters.

I tried using variable amount of quotes here and there, dropping the Chr(34) in favour of even more quotes etc, but nothing worked. How do I fix this?

3
  • The Chr(34) is completely unnecessary. If the command wsl is not being found check the PATH environment variable or just try running the command from a command prompt to see if you get the same error as running it with VBScript. Commented May 28, 2024 at 12:14
  • Does this answer your question? VBScript WScript.Shell Run() - The system cannot find the file specified Commented May 28, 2024 at 12:18
  • Alternative solution: Create a shortcut that launches WSL using this RunHidden tool. Commented May 28, 2024 at 15:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.