?
Solved

How to open wshell in dos window?

Posted on 2008-10-22
5
Medium Priority
?
399 Views
Last Modified: 2012-06-27
I have created many vbs scripts in the past that when double clicked, run within the command prompt window and I can see the output and progress.

I am now running the same scripts on a new server and instead of the command prompt window opening, I am getting the windows message window, with the typical OK button, which I have to press to proceed. This is very annoying.

What do I need to change to make these run within the command prompt window?

I read somewhere that CScript would do this, but as I said, this works as desired on other windows boxes, why not this one?
Set wShell = CreateObject("WScript.Shell")
 
WScript.Echo "hello world"
 
wshell.run "%comspec% /c AddWindowsUser.bat " & "hello world", 0, True
 
Wscript.Echo "user added" & vbcrlf & vbcrlf

Open in new window

0
Comment
Question by:juliandormon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22778240
The default engine on the other boxes may be cscript - that's a registry setting...
You can either change the registry, or try this code to ensure it's run with cscript:
(place it just after your assignment of wShell)
If Lcase(Right(wscript.fullname,11))="wscript.exe" Then
  strPath=wscript.ScriptFullName
  strCmd = "%comspec% /k cscript " & chr(34) & strPath & chr(34)
  WShell.Run strCmd, 0
  wscript.quit
End If

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22778266
The registry change is located at HKCU\VBSFile\Shell\Open\Command
The default is normally %SystemRoot%\System32\Wscript.exe "%1" %*
but you can easily change it to cscript.exe
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 22778271
And http://support.microsoft.com/default.aspx/kb/952033 details the change as well...
0
 

Author Comment

by:juliandormon
ID: 22778405
Thanks a bunch!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 22778413
Happy to help - thanx for the grade! :^)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question