CScript Error: Can't change default script host

John Burgess 0 Reputation points
2025-04-08T00:37:20.1566667+00:00

On Windows 11, having registered wscript.exe as the default script host for running scripts, by using

/h:wscript on the command line like this:

       wscript /h:wscript xyz.wsf

I find I now cannot change the default script host. I want to register cscript.exe as the default script host for running script, but windows won't let me.

       C:\junk>cscript /h:cscript xyz.wsf

       Microsoft (R) Windows Script Host Version 5.812

       Copyright (C) Microsoft Corporation. All rights reserved.

       CScript Error: Can't change default script host.
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
11,353 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. John Burgess 0 Reputation points
    2025-04-08T01:16:54.1433333+00:00

    https://learn.microsoft.com/en-us/answers/support/self-answering

    I fixed the problem, it is not actually a problem, just user ignorance. To change the default host you need to be running CMD with admin privileges.

    Here is the simplest way to set the default script host:

    Open CMD "run as Administrator" and execute "cscript /h:cscript".

     C:\Windows\System32>cscript /h:cscript
    
     Microsoft (R) Windows Script Host Version 5.812
    
     Copyright (C) Microsoft Corporation. All rights reserved.
    
     The default script host is now set to "cscript.exe".
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.