I'm trying to run a VBScript with wscript using the elevated user and not showing any window.
So I have the following myscript.vbs file and to run it, in cmd.exe, I call wscript myscript.vbs
Set Shell = CreateObject("Shell.Application")
Shell.ShellExecute "cmd.exe", "/c netsh interface ip set address name=Ethernet static 192.168.1.5 255.255.255.0 0.0.0.0 && echo helloworld > file.txt", , "runas", 0
The script is then going to run multiple commands on cmd.exe (but asking for elevation just once), as showing above. That actually works.
However it fails if the network interface name have a space, Ethernet 1 instead of Ethernet.
How can I deal with this?
This is my first ever VBScript, please forgive me if I'm doing something unusual.