-1

When I use slmgr /skms <URL> | cmd command in PowerShell it shows me a pop up that I must press the ok button after that I run slmgr /ato | cmd and again shows me another pop up that I press the ok button.

I don't want to press the ok button manually, can anybody help me if there is a solution for it, please?

I just disabled the in windows, but it does not help me.

1 Answer 1

1

What you are looking for is cscript. By just executing a vbs script file, output gets sent to dialog boxes, which need your interaction.

Using cscript, the desired output gets printed to your current stdout:

cscript C:\Windows\System32\slmgr.vbs /ato

That doesn't have anything to do with UAC and you might consider re-activating it.


But why is that?

slmgr is not a command nor is it an executable in windows. It's a script file written in VBScript. VBScript is a kind-of scripting version of VB, So it's good for your peace of mind not to deal with it too much.

If you type in slmgr /skms, what windows does is looking for a file named slmgr in its search paths (%PATH%), finding C:\Windows\System32\slmgr.vbs and deciding that, as its a .vbs file, executing wscript.exe with the file path and your arguments as parameter is the right thing to do.

WScript is the default interpreter for vbs files and just interprets the file and executes its code. On the other hand, there is cscript for console scripts.

If the author of the .vbs file decides to write a message to the user of their script, they usually use a statement like

Wscript.Echo "Hello, World!"

And thats where your confusion starts:
Executing this script in cscript means that Hello, World! is written to the console. (That's what you want to do)
Executing the same script using wscript renders a message box with a OK button. You can easily reproduce it yourself by creating a vbs file with the above statement.

The difference between cscript and wscript is also discussed in this question:
Difference between wscript and cscript

5
  • Hi Clijsters, I'm a beginner at Powershell and Script, is it possible to give me more detailed guidance? Commented Jan 21, 2023 at 6:12
  • Of course, I just added some explanation to my answer.
    – Clijsters
    Commented Jan 21, 2023 at 13:29
  • setting the server: cscript //Nologo c:\windows\system32\slmgr.vbs /skms kms.stackoverflow.com
    – js2010
    Commented Jan 21, 2023 at 16:38
  • I think you mean wscript.exe not vscript.exe, there is no such executable. Both cscript.exe and wscript.exe are part of the Windows Scripting Host.
    – user692942
    Commented Jan 22, 2023 at 8:30
  • @user692942 of course, thanks for the hint. I stopped using windows several years ago. Thats why I couldnt verify my snippets 1st hand
    – Clijsters
    Commented Jan 23, 2023 at 9:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.