Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RunAs

 
Logged in as: Guest
arrSession:exec spGetSession 2,16,61041
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> RunAs
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 RunAs - 6/4/2008 6:08:08 AM   
  jcarver_14

 

Posts: 25
Score: 0
Joined: 6/4/2008
From: Cincinnati
Status: offline
Hi everyone,

Very new to scripting (bout 3 mo.) so this might not be as pretty as some of your scripts but it may help someone.  This will alow you to do a run as on just about anything but a folder.  Just drag and drop onto the file.

title = "User Name"
title2 = "Password"
message = "Please enter the user name." & vbCrLf & vbCrLf & "**NOTE**" & vbCrLf & vbCrLf & "User name must be entered as" & vbCrLf & "domain\username or username@domain.com"
username=InputBox(message, title)
message2 = "Please enter the password for:" & vbCrLf & vbCrLf & username
password=InputBox(message2, title2)
set wshShell=CreateObject("Wscript.Shell")
set oShell= Wscript.CreateObject("WScript.Shell")
wshShell.run("runas /noprofile /user:" & username & " " & Chr(34) & "cmd /c\" & Chr(34) & WScript.Arguments(0) & "\" & Chr(34) & Chr(34))
WScript.Sleep 100
wshShell.AppActivate "Runas"
oshell.Sendkeys password & "~"
Wscript.Quit

Big down fall to this is you can see the password but it looks nice.  If anyone knows how to fix that let me know.






title = "User Name"
message = "Please enter the user name." & vbCrLf & vbCrLf & "**NOTE**" & vbCrLf & vbCrLf & "User name must be entered as" & vbCrLf & "domain\username or username@domain.com"
username=InputBox(message, title)
set wshShell=CreateObject("Wscript.Shell")
wshShell.run("runas /noprofile /user:" & username & " " & Chr(34) & "cmd /c\" & Chr(34) & WScript.Arguments(0) & "\" & Chr(34) & Chr(34))
WScript.Sleep 100
wshShell.AppActivate "Runas"
Wscript.Quit

This one does the same thing but it will alow you to put the password in in a dos window where you cant see it.




set wshShell=CreateObject("Wscript.Shell")
set oShell= Wscript.CreateObject("WScript.Shell")
wshShell.run("runas /noprofile /user:username " & Chr(34) & "cmd /c\" & Chr(34) & WScript.Arguments(0) & "\" & Chr(34) & Chr(34))
WScript.Sleep 100
wshShell.AppActivate "Runas"
oshell.Sendkeys "password" & "~"
Wscript.Quit

Replace usernames and password and it willl not prompt for anything... be careful though you dont want anyone to find your password.
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> Post a VBScript >> RunAs Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts