1.

Solve : Script I stumbled upon...?

Answer»

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?


Code: [Select]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
I guess I should describe what it does - it runs my batch file and hides the annoying flashing console
Is WSL Windows Subsystem for Linux?

https://en.wikipedia.org/wiki/Windows_Subsystem_for_LinuxNo 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

I haven't any idea what parameter is being passed

Could the parameter be setting some condition to exist for XFCE?
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.Quote from: Quantos on April 30, 2019, 02:44:22 PM

<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?

Quote from: Quantos on April 30, 2019, 02:44:22 PM
<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.Quote from: Salmon Trout on April 30, 2019, 02:52:20 PM
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


Discussion

No Comment Found