Tech Support > Microsoft Windows > Can not run CScript or WScript on XP Pro command prompt
Can not run CScript or WScript on XP Pro command prompt
Posted by cjeffwang@gmail.com on November 6th, 2005


I am reviewing WSH and VBScript programming.

With a statement: WScript.Echo "Hello World!" , in my HelloWscript.vbs
file, I had no problem running this file by double-clicking on it.
However, on the command prompt, typing either CScript HelloWScript or
WScript HelloWScript.vbs returned the same error message:

CScript/WScript is not recognized as an internal or external command,
operable program or batch file.

I just upgraded XP Home to XP Pro. Does XP Pro support WSH command
prompt?

TIA,
Jeffrey

Posted by Shenan Stanley on November 6th, 2005


cjeffwang@gmail.com wrote:
> I am reviewing WSH and VBScript programming.
>
> With a statement: WScript.Echo "Hello World!" , in my HelloWscript.vbs
> file, I had no problem running this file by double-clicking on it.
> However, on the command prompt, typing either CScript HelloWScript or
> WScript HelloWScript.vbs returned the same error message:
>
> CScript/WScript is not recognized as an internal or external command,
> operable program or batch file.
>
> I just upgraded XP Home to XP Pro. Does XP Pro support WSH command
> prompt?


Sounds like your path is messed up.
At the same command prompt, type:

path

and press ENTER.

is "C:\WINDOWS\system32" in there?

--
Shenan Stanley
MS-MVP
--
How To Ask Questions The Smart Way
http://www.catb.org/~esr/faqs/smart-questions.html


Posted by Wesley Vogel on November 6th, 2005


Place HelloWScript.vbs in %windir% or %windir%\system32.
Open a command prompt and type:

HelloWScript

Hit Enter

or this in a command prompt...
WScript "%windir%\system32\HelloWScript.vbs"
both will display...
---------------------------
Windows Script Host
---------------------------
Hello World!
---------------------------
OK
---------------------------

CScript "%windir%\system32\HelloWScript.vbs"
in a command prompt will echo Hello World! in the command prompt window.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:1131309003.036746.124340@g43g2000cwa.googlegr oups.com,
cjeffwang@gmail.com <cjeffwang@gmail.com> hunted and pecked:
> I am reviewing WSH and VBScript programming.
>
> With a statement: WScript.Echo "Hello World!" , in my HelloWscript.vbs
> file, I had no problem running this file by double-clicking on it.
> However, on the command prompt, typing either CScript HelloWScript or
> WScript HelloWScript.vbs returned the same error message:
>
> CScript/WScript is not recognized as an internal or external command,
> operable program or batch file.
>
> I just upgraded XP Home to XP Pro. Does XP Pro support WSH command
> prompt?
>
> TIA,
> Jeffrey

Posted by cjeffwang@gmail.com on November 7th, 2005


> At the same command prompt, type:
> path and press ENTER.
> is "C:\WINDOWS\system32" in there?


Yes, mine is c:\WINXP\Systems32

> Place HelloWScript.vbs in %windir% or %windir%\system32.
> Open a command prompt and type:
> HelloWScript Hit Enter


Popup dialog created. Typing Hello and HelloWSH showed 'Not Recognized'
error.

> CScript "%windir%\system32\HelloWScript.vbs"
> in a command prompt will echo Hello World! in the command prompt window.


Yes, Popup dialog created.

At my C:\Script\WSH command, typing Hello, HelloWSH, or HelloWScript
now show the popup dialog.

I am totally confused. One thing I did, which is different from the
book, is I have had 3 Hello files with
3 different names, i.e. Hello.vbs, HelloWSH.vbs for WScript Shell, and
HelloWScript for WScript.Ech.
Is this the reason why the WScript and CScript commands are not
working?

Posted by Wesley Vogel on November 8th, 2005


I have no idea what the extension .ech is for.

Is C:\Script\WSH in your PATH?

Open a command prompt, type: path and hit Enter.

At a minumum it should have these
PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Sys tem32\Wbem
and you need to add C:\Script\WSH if that's where you are storing your
practice scripts.

See this on how to add to the PATH...
HOW TO Manage Environment Variables in Windows XP
http://support.microsoft.com/default...b;en-us;310519

Or move your scripts to a folder that is already listed in PATH.

[[The PATH environment variable defines the Windows NT search path. The
search path is a list of directories that are searched when the command
shell attempts to locate an executable file.

The PATHEXT environment variable defines the list of file extensions
checked by Windows NT when searching for an executable file. Like the PATH
variable, semi-colons separate individual items in the PATHEXT variable.
The default value of PATHEXT is .COM;.EXE;.BAT;.CMD. ]]
http://www.microsoft.com/technet/arc.../shellscr.mspx

You can also open a command prompt, type: set and hit Enter to see both
PATH & PATHEXT.

--
Hope this helps. Let us know.

Wes
MS-MVP Windows Shell/User

In news:1131334301.606323.235040@g43g2000cwa.googlegr oups.com,
cjeffwang@gmail.com <cjeffwang@gmail.com> hunted and pecked:
>> At the same command prompt, type:
>> path and press ENTER.
>> is "C:\WINDOWS\system32" in there?

>
> Yes, mine is c:\WINXP\Systems32
>
>> Place HelloWScript.vbs in %windir% or %windir%\system32.
>> Open a command prompt and type:
>> HelloWScript Hit Enter

>
> Popup dialog created. Typing Hello and HelloWSH showed 'Not Recognized'
> error.
>
>> CScript "%windir%\system32\HelloWScript.vbs"
>> in a command prompt will echo Hello World! in the command prompt window.

>
> Yes, Popup dialog created.
>
> At my C:\Script\WSH command, typing Hello, HelloWSH, or HelloWScript
> now show the popup dialog.
>
> I am totally confused. One thing I did, which is different from the
> book, is I have had 3 Hello files with
> 3 different names, i.e. Hello.vbs, HelloWSH.vbs for WScript Shell, and
> HelloWScript for WScript.Ech.
> Is this the reason why the WScript and CScript commands are not
> working?


Posted by cjeffwang@gmail.com on November 8th, 2005


I finally figured it out.

With 3 Hello files: Hello.vbs, HelloWSH.vbs, and HelloWScript on my
C:\WINXP\WSH directory,
double-clicking or typing Hello, HelloWSH, or HelloWScript showed Hello
World ! popup dialog.
Coping HelloWScript vbs file i.e. WScript.Echo "Hello world!" to
C:WINXP\SYSTEM32, then
typing WScript HelloWScript.vbs showed popup dialog; while typing
CScrpt HelloWScript.vbs
showed only Hello World ! on the Windows console.

Thank you all.
-- Jeffrey


Similar Posts