2

I have code that I was able to do in .vbs:

If GetNumlockState() = True Then    
Else
    set WshShell = CreateObject("WScript.Shell")
    WshShell.SendKeys "{NUMLOCK}"
End If
Function GetNumlockState()
    strResult = WScript.CreateObject("WScript.Shell").Exec("powershell.exe -command [console]::NumberLock").StdOut.ReadLine
    If strResult = "True" Then GetNumlockState = True Else GetNumlockState = False
End Function

I would like the .cmd console window and icon not to appear when running a saved .vbs file with this code, which is visible and disappears quickly. I wish it wasn't visible. Is it possible to modify this code and rewrite it so that the .cmd console is not visible, and the whole code works the same all the time, i.e. turns on the numlock key after detecting when it is turned off? It has to be code that matches and works for .vbs for it to handle and accept this.

Unless it is possible to execute the command from poweshell somehow from a file saved in .vbs?

Will someone help me? Best regards.

Ian Campbell
  • 23,484
  • 14
  • 36
  • 57
  • I changed:("powershell.exe -command [console]::NumberLock").StdOut.ReadLine For this = ("powershell.exe -WindowStyle Hidden -command [console]::NumberLock").StdOut.ReadLine – RemixPL1994 Nov 26 '20 at 19:10
  • This way .cmd console no longer shows when executing powershell, but the powershell icon in the start bar still shows for a while. I'm still looking for a way to hide the powershell display while the hidden .cmd console is executing the powershell command. – RemixPL1994 Nov 26 '20 at 19:21

0 Answers0