Solved

using runas to launch a cmd window from a vbs with unexpected result.

Posted on 2007-04-03
13
127 Views
Last Modified: 2008-01-09
I am trying to create a vbs script that will launch a cmd window under an admin user account while a user is logged in. the problem I have is that when I combine the .Run command with the runas command I am getting strange results. my code is below. the strangeness is that no matter what I place after the runas the ouput is alwas /user:domain\administrator "notepad". I can type in complete junk like "lksjdjfo32445@345" and the output is still /user:domain\administrator "notepad".
could anyon tell me what is happening so I can correct this?

set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:domain\administrator cmd.exe", 9
0
Comment
Question by:mattolan
[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
  • 7
  • 6
13 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846441
Try:

WshShell.Run "cmd /c runas /user:domain\administrator cmd.exe"
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846503
still comes up as notepad
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846534
this worked for me...

wshShell.Run "cmd /k runas /user:domain\username notepad"

The /k states to leave the command window open after processing.../c closes it afterwards...

Not sure what you mean that it still comes up as notepad?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 67

Expert Comment

by:sirbounty
ID: 18846536
can you post a screenshot?
www.ee-stuff.com is an upload site...
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846552
what I mean is that I enter
WshShell.Run "cmd /c runas /user:domain\administrator cmd.exe" in my vbs script but it outputs
runas /user\domain\administrator "notepad" instead.

it doesnot matter what I put after the runas portion of the command the results are always

/user\domain\administrator "notepad"
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846567
Is your script named runas.vbs?
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846623
this code
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas /user:domain\administrator cmd.exe", 9
or this code
set WshShell = CreateObject("WScript.Shell")
WshShell.Run "runas asdfh4567$%^%&",9

will both generates this output

c:\>runas /user\domain\administrator "notepad"
Enter the password for domain\administrator:
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846627
my script is named test.vbs
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846648
if I used the command from the cmd prompt it works, but as soon as I combine it with the WshShell.Run command it doesn't work
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 125 total points
ID: 18846683
is there any batch file or script named 'runas.*' anywhere on your drive?
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846692
I'm thinking that's coming from somewhere else...
Even when I use your example and don't use cmd /c
the 'only' think I get at the prompt is to enter the password...
0
 
LVL 2

Author Comment

by:mattolan
ID: 18846717
that was it exactly I had an old file sitting on my destop called runas.bat.
I deleted it and the command works perfectly. glad you asked that question becuase I don't think I would have found that any time soon
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846727
Happy to help! :^)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Saved searches can save you time by quickly referencing commonly searched terms on any topic. Whether you are looking for questions you can answer or hoping to learn about a specific issue, a saved search can help you get the most out of your time o…

733 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