0

First if all, let me say that I know this can be achieved using multiple files (vbs + bat + ps1 or vbs + ps1). What I am looking for is a single vbs file giving the same result.

I've cobbled up code shown below. It works but, shows PS console in the background. If I launch ps1 file via vbs, there is no console. How would I achieve this using single vbs file? I know there is an important part missing ',0, True', but wirh it present the form does not show up at all. Please advise

dim EncodedCommand
EncodedCommand = "YQBkAGQALQB0AHkAcABlACAALQBBAHMAcwBlAG0AYgBsAHkATgBhAG0AZQAgACcAUwB5AHMAdABlAG0ALgBXAGkAbgBkAG8AdwBzAC4ARgBvAHIAbQBzACcADQAKACQAbQBhAGkAbgAyACAAPQAgAE4" &_
"AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAbQAuAFcAaQBuAGQAbwB3AHMALgBGAG8AcgBtAHMALgBGAG8AcgBtAA0ACgAkAG0AYQ" &_
"BpAG4AMgAuAEMAbABpAGUAbgB0AFMAaQB6AGUAIAA9ACAAJwA2ADAAMAAsADYAMAAwACcADQAKACQAbQBhAGkAbgAyAC4ATQBpAG4AaQBtA" &_
"GkAegBlAEIAbwB4ACAAPQAgACQAZgBhAGwAcwBlAA0ACgAkAG0AYQBpAG4AMgAuAE0AYQB4AGkAbQBpAHoAZQBCAG8AeAAgAD0AIAAkAGYA" &_
"YQBsAHMAZQANAAoAJABtAGEAaQBuADIALgBUAGUAeAB0" &_
"ACAAPQAgACcARAB6AGkAYQBsAGEAcwB6ACAAawB1AHIA" &_
"dwBvACcADQAKACQAbQBhAGkAbgAyAC4AQQB1AHQAbwBT" &_
"AGkAegBlACAAPQAgACQAdAByAHUAZQAgAA0ACgAkAG0A" &_
"YQBpAG4AMgAuAFMAdABhAHIAdABQAG8AcwBpAHQAaQBv" &_
"AG4AIAA9ACAAWwBTAHkAcwB0AGUAbQAuAFcAaQBuAGQA" &_
"bwB3AHMALgBGAG8AcgBtAHMALgBGAG8AcgBtAF" &_
"MAdABhAHIAdABQAG8AcwBpAHQAaQBvAG4AXQA6" &_
"ADoAQwBlAG4AdABlAHIAUwBjAHIAZQBlAG4AIA" &_
"ANAAoAJABtAGEAaQBuADIALgBTAGgAbwB3AEQA" &_
"aQBhAGwAbwBnACgAKQANAAoA"
set shell = WScript.CreateObject("WScript.Shell")
shell.Run "powershell.exe -noexit -executionpolicy bypass -encodedcommand " & EncodedCommand

[EDIT]

I've figured out what I wanted to achieve.

In order for 0, True arguments to take effect I had to encase whole powershell command in a single variable, as seen below.

dim EncodedCommand
EncodedCommand = "YQBkAGQALQB0AHkAcABlACAALQBBAHMAcwBlAG0AYgBsAHkATgBhAG0AZQAgACcAUwB5AHMAdABlAG0ALgBXAGkAbgBkAG8AdwBzAC4ARgBvAHIAbQBzACcADQAKACQAbQBhAGkAbgAyACAAPQAgAE4" &_
"AZQB3AC0ATwBiAGoAZQBjAHQAIABTAHkAcwB0AGUAbQAuAFcAaQBuAGQAbwB3AHMALgBGAG8AcgBtAHMALgBGAG8AcgBtAA0ACgAkAG0AYQ" &_
"BpAG4AMgAuAEMAbABpAGUAbgB0AFMAaQB6AGUAIAA9ACAAJwA2ADAAMAAsADYAMAAwACcADQAKACQAbQBhAGkAbgAyAC4ATQBpAG4AaQBtA" &_
"GkAegBlAEIAbwB4ACAAPQAgACQAZgBhAGwAcwBlAA0ACgAkAG0AYQBpAG4AMgAuAE0AYQB4AGkAbQBpAHoAZQBCAG8AeAAgAD0AIAAkAGYA" &_
"YQBsAHMAZQANAAoAJABtAGEAaQBuADIALgBUAGUAeAB0" &_
"ACAAPQAgACcARAB6AGkAYQBsAGEAcwB6ACAAawB1AHIA" &_
"dwBvACcADQAKACQAbQBhAGkAbgAyAC4AQQB1AHQAbwBT" &_
"AGkAegBlACAAPQAgACQAdAByAHUAZQAgAA0ACgAkAG0A" &_
"YQBpAG4AMgAuAFMAdABhAHIAdABQAG8AcwBpAHQAaQBv" &_
"AG4AIAA9ACAAWwBTAHkAcwB0AGUAbQAuAFcAaQBuAGQA" &_
"bwB3AHMALgBGAG8AcgBtAHMALgBGAG8AcgBtAF" &_
"MAdABhAHIAdABQAG8AcwBpAHQAaQBvAG4AXQA6" &_
"ADoAQwBlAG4AdABlAHIAUwBjAHIAZQBlAG4AIA" &_
"ANAAoAJABtAGEAaQBuADIALgBTAGgAbwB3AEQA" &_
"aQBhAGwAbwBnACgAKQANAAoA"

pSCmd = "powershell.exe -noexit -windowstyle Hidden -executionpolicy bypass -encodedcommand " & EncodedCommand

CreateObject("WScript.Shell").Run pSCmd, 0, True
Nawad-sama
  • 151
  • 2
  • 12
  • Did you try `-WindowStyle hidden` on the Powershell.exe? – Scepticalist Jan 27 '23 at 10:09
  • From my expirience it does nothing, but will chceck when I have time – Nawad-sama Jan 27 '23 at 11:52
  • I was able to run your encoded dialog, without any console window (not even a flash), by using [this little C# program](https://github.com/SeidChr/RunHiddenConsole). Message back if you need implementation details. – LesFerch Jan 27 '23 at 20:44
  • Thanks for the reply, but as I mentioned in the original post, I want to use single file solution. See my edit at the top of the page to see what I mean. – Nawad-sama Jan 30 '23 at 07:52
  • When I first played around with it, I was stumped on getting the console hidden with the dialog visible. Glad to see you got it working as desired and that it's a simple change. It would be great if you added this solution to the duplicate link because this question will probably end up being removed automatically after a while. – LesFerch Jan 30 '23 at 17:27

0 Answers0