runaway Cmd prompt script!

C

Craig

Hi folks,
I have a simple .vbs script to open a command prompt and
then display the "ipconfig" info. When I launch the script
from the desktop..."it's off to the races!!!" The script
starts a perpetual loop and I have to shutdown to stop it.
Can someone tell me why Windows (2000-Pro) does this?

Thank you,
Craig

Here's the script:

Set objShell = CreateObject("WScript.Shell")
objShell.Run ("%COMSPEC% /k ipconfig")
 
A

Austin M. Horst

If those are the only lines,
there is nothing in the script causing a loop.
It's written correctly.

The same result could be achieved using a small batch file:

@echo off
ipconfig
pause


Austin M. Horst
 
C

Craig

Austin,
Then why does it run as if it's a perpetual loop? (Which
is EXACTLY how it behaves)

Craig
 
P

Paul R. Sadowski

Craig said:
Hi folks,
I have a simple .vbs script to open a command prompt and
then display the "ipconfig" info. When I launch the script
from the desktop..."it's off to the races!!!" The script
starts a perpetual loop and I have to shutdown to stop it.
Can someone tell me why Windows (2000-Pro) does this?

You didn't by chance name it ipconfig.vbs, did you?
 
C

Craig

Hi Paul,
Yes, I did. :) And...I could tell by your question that
it SHOULDN'T have been named that. So...I renamed it, and
now it works fine.

Can you tell me what the problem was that I encountered
because I had it named ipconfig.vbs???

Thank you very much.

Craig
 
P

Paul R. Sadowski

Craig said:
Hi Paul,
Yes, I did. :) And...I could tell by your question that
it SHOULDN'T have been named that. So...I renamed it, and
now it works fine.

Can you tell me what the problem was that I encountered
because I had it named ipconfig.vbs???

You told the script to run the command interpreter which would run ipconfig.
Since you didn't use an extension like ipconfig.exe, cmd used the first
executable ipconfig it found which is ipconfig.vbs in the current directory
(the current directory is always searched first), and in 2K, XP, etc. .vbs
files are executable extensions. So as a consequence of this behaviour
ipconfig.vbs in essence kept executing copies of itself over and over.

We've all done it some point. :)

From a command prompt type
echo %PATHEXT%
to see the file types cmd can execute.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top