Solved

How to open wshell in dos window?

Posted on 2008-10-22
5
397 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 500 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 Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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