PC Review


Reply
Thread Tools Rate Thread

Can not run CScript or WScript on XP Pro command prompt

 
 
cjeffwang@gmail.com
Guest
Posts: n/a
 
      6th Nov 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

 
Reply With Quote
 
 
 
 
Shenan Stanley
Guest
Posts: n/a
 
      6th Nov 2005
(E-Mail Removed) 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


 
Reply With Quote
 
Wesley Vogel
Guest
Posts: n/a
 
      6th Nov 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:(E-Mail Removed),
(E-Mail Removed) <(E-Mail Removed)> 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

 
Reply With Quote
 
cjeffwang@gmail.com
Guest
Posts: n/a
 
      7th Nov 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?

 
Reply With Quote
 
Wesley Vogel
Guest
Posts: n/a
 
      8th Nov 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\System32\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:(E-Mail Removed),
(E-Mail Removed) <(E-Mail Removed)> 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?


 
Reply With Quote
 
cjeffwang@gmail.com
Guest
Posts: n/a
 
      8th Nov 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problemn in cscript command Parthasarathi R Windows XP Work Remotely 0 4th Jun 2008 05:33 AM
"cscript.exe: Command Screen BAR Windows XP Help 3 27th May 2008 12:06 AM
Changing prompt from C:\documents and settings\ to C:\ within command prompt Nulligan@gmail.com Windows XP General 4 1st Aug 2006 08:10 PM
Logon Scripts - CScript vs WScript? Gerry Hickman Microsoft Windows 2000 Group Policy 4 30th Jun 2006 12:24 AM
Permission Denied while running cscript command in command prompt Eric Microsoft Windows 2000 CMD Promt 0 3rd Oct 2003 08:11 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:50 AM.