Solved

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

Posted on 2007-04-03
13
121 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Isolating a VM 1 79
Opinion:  What is the best Boot Camp CCNA 3 79
Managing IT related issues 6 72
Phone service in Israel 4 64
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The Bounty Board allows you to request an article or video on any technical topic, or fulfill a bounty request to earn points. Watch this video to learn how to use the Bounty Board to get the content you want, earn points, and browse submitted bount…

919 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now