Computer Hope
Software => Computer programming => Topic started by: Quantos on April 30, 2019, 12:41:17 PM
-
I came across this script last week and tried it out for WSL, it works great - is there a downside to using it that anyone can see?
C:\wsl\bat-launcher.vbs
If WScript.Arguments.Count <= 0 Then
WScript.Quit
End If
bat = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & WScript.Arguments(0) & ".bat"
arg = ""
If WScript.Arguments.Count > 1 Then
arg = WScript.Arguments(1)
End If
CreateObject("WScript.Shell").Run """" & bat & """ """ & arg & """", 0, False
<edit> I guess I should describe what it does - it runs my batch file and hides the annoying flashing console </edit>
-
Is WSL Windows Subsystem for Linux?
https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux
-
No downside, at least in operation, as long as the batch script actually exists in the script folder. Did you write it yourself? What I write about it depends on your answer.
Another question - do you really need to pass a parameter to the batch script?
What do you mean by WSL?
I will say this pending your reply...
If you just want to run a named batch invisibly, and you don't need to pass a parameter to the batch. this is all you need
If it is called Myrun.vbs, use it like so - Myrun.vbs batname.bat
CreateObject("WScript.Shell").Run """" & wscript.arguments(0) & """", 0, False
-
Yes, Windows Subsystem for Linux
No, I didn't write it, like I said I just stumbled across it looking for information about Ubuntu installs on WSL
Yes, it seems to do what it says it does.
I don't know enough about scripting to know if it's actually safe to use though
<edit> I haven't any idea what parameter is being passed </edit>
<edit2> Could the parameter be setting some condition to exist for XFCE? </edit2>
-
It's safe, as long as you use it to run your own batch scripts. Script kiddies use the technique to run batch scripts without any betraying console window. As VBS scripts go, it's a bit crude. Like it was written by someone just starting out. It helpfully checks that you supplied some parameters, but silently quits if you didn't, and makes you supply the batch bare name and adds '.bat' to it, and decodes the script name to get its folder name, none of which is necessary. And all without checking if the batch actually exists.
-
<edit> I haven't any idea what parameter is being passed </edit>
<edit2> Could the parameter be setting some condition to exist for XFCE? </edit2>
More context needed. A link?
-
<edit2> Could the parameter be setting some condition to exist for XFCE? </edit2>
Strange not to do it in WSL. I have installed LXDE in my Ubuntu WSL, and use a VNC server to get an X desktop, but I didn't need batch files to do it.
-
More context needed. A link?
Oh sure, it took a few to find it - https://token2shell.com/howto/x410/creating-shortcut-for-wsl-gui-desktop/
That's where I found the script