Solved

How to open wshell in dos window?

Posted on 2008-10-22
5
398 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

724 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