Sending Echo Off through VBS Script

Hi Experts.

I'm using a VBS Script to invoke a runas command through CMD.
I got it working perfectly except for one little thing. I need the CMD Screen to be completely blank while working or better yet, not to be visible at all.
The VBS Script looks like this:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("runas /user:mydomain\domain admin user ""Path With Spaces"""), 1, False
WScript.Sleep 100
objShell.Sendkeys "domain admin password~"

Open in new window


Is there a way to invoke it with @echo off or somehow make the cmd windows not to jump up.
Please keep in mind that creating a batch and invoking it using the VBS Script is NOT an option.
LVL 8
David SankovskySenior SysAdminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
Try it like this:
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("cmd.exe /c runas.exe /user:mydomain\domain admin user ""Path With Spaces"" >NUL"), 1, False
WScript.Sleep 100
objShell.Sendkeys "domain admin password~"

Open in new window

0
Dan McFaddenSystems EngineerCommented:
Here is the MSDN reference for the WScript.Shell Run Method:

link:  https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx

What you can do is make it so the CMD prompt runs minimized.  You need to change the intWindowStyle option on the .Run method.  It should be 2.  This way you'll see the main command console, but all the spawned commands will run minimized.

Dan
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
David SankovskySenior SysAdminAuthor Commented:
I used a combination of Both!
Piping the output into a non-existent output was great.
Starting it minimized made it look even sleeker

Thank you both!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.