none
Error message changing default mode of wscript in Windows 7

    Question

  • I'm running Windows 7 Home Premium. I have a number of .js scripts that I'm trying to bring over from XP. They all ran there under cscript.When I try to change the default script mode using

            CScript//:HCScript

    I get the message

            CScript Error: Can't change default script host.

    If I run one of these old scripts using

            cscript <script name>.js

    it works fine. I'de rather not have to do it this way. Can anyone help?

    Sunday, October 03, 2010 6:36 PM

Answers

  • You could try to add a key manually, using regedit. You can go to Start, Run,  and enter "regedit" (or start search and enter "regedit"). Click regedit.exe to run it. Expand HKEY_LOCAL_MACHINE. Right click the "Software" folder and select New, Key, and enter something like "TestKey". If it works, you have permission, and you can delete the new key. If you lack permissions, you need to logon with an account that has administrator permissions.

    Richard Mueller


    MVP ADSI
    Wednesday, October 13, 2010 5:53 PM
    Moderator

All replies

  • Per this link:

    http://msdn.microsoft.com/en-us/library/cy391bzc(VS.85).aspx

    you might lack permission to modify the registry.

    Richard Mueller


    MVP ADSI
    Sunday, October 03, 2010 7:23 PM
    Moderator
  • You issued the command

    CScript//:HCScript

    It should be

    CScript  //H:CScript

    Note also that while spaces are not always required to separate parameters at the Command Prompt, you should make it a habit of always including them, same as you put a space between words in the English language.

    Sunday, October 03, 2010 7:54 PM
  • How can I determine if this is the case? And if this is true, how do I change it?
    Monday, October 04, 2010 9:04 PM
  • Sorry about that. The missing space was only in the post. Actually, I tried

            CScript H\\:CScript

    and

            WScript H\\:Cscript

    with similar results in both cases.

    Monday, October 04, 2010 9:08 PM
  • When you program then you need to be very exact. You wrote

    CScript  H\\:CScript
    which is completely different from the correct syntax of
    CScript  //H:CScript

    Furthermore, when you post about a problem then you should always use copy & paste methods. If you retype things then you are likely to introduce new errors which will confuse everyone, including yourself.

    Monday, October 04, 2010 9:30 PM
  • You could try to add a key manually, using regedit. You can go to Start, Run,  and enter "regedit" (or start search and enter "regedit"). Click regedit.exe to run it. Expand HKEY_LOCAL_MACHINE. Right click the "Software" folder and select New, Key, and enter something like "TestKey". If it works, you have permission, and you can delete the new key. If you lack permissions, you need to logon with an account that has administrator permissions.

    Richard Mueller


    MVP ADSI
    Wednesday, October 13, 2010 5:53 PM
    Moderator