Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


runas admin script

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> Post a VBScript >> runas admin script
  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 admin script - 12/30/2005 3:27:22 AM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
This script provides a quick interface to common admin applications without creating shortcuts or typing out the runas command. It uses an input box as a menu.

'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
' NAME: runas admin tool
'
' AUTHOR: Kirrilian
' DATE  : 12/29/2005
'
' COMMENT: This script makes a quick way to run common admin tools with runas via a
'            gui.
'
'==========================================================================
Option Explicit

Dim objmenu, username, wshshell, fso
Set WshShell = WScript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Username = InputBox("Enter your admin username (domain\username)", "Enter Username")
'create an object from the gui_menu class
Set objmenu = New gui_menu
'start the application
objmenu.getInput

Class gui_menu
    private Input, quit, strText, cmd, arrMenu, i, return, strProg
   
    Private Sub pickInput
        'if you add anything to the menu array below, make sure you add a corresponding entry here
        Select Case Input
            Case "1"
                cmd = " ""mmc %windir%\system32\compmgmt.msc"""
                startProg cmd
                getInput
            Case "2"
                cmd = " ""mmc %windir%\system32\dsa.msc"""
                startProg cmd
                getInput
            Case "3"
                cmd = " ""mmc %windir%\system32\tsmmc.msc"""
                startProg cmd
                getInput
            Case "4"
                cmd = " %comspec%"
                startProg cmd
                getInput
            Case "5"
                cmd = " ""mmc C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQL Server Enterprise Manager.MSC"""
                startProg cmd
                getInput
            Case "6"
                strProg = InputBox("Input the full path to the program", "User Defined")
                If fso.FileExists(strProg) then
                    cmd = " """ & strProg & """"
                    startProg cmd
                    getInput
                Else
                    strProg = MsgBox("File doesn't exist, try again!",48,"Error!!")
                    getInput
                End if
            Case "7"
                quit = MsgBox ("Are you sure?", 36, "Want To quit?")'52
                If quit = 6 Then
                    MsgBox ("Bye!!")
                    WScript.Quit
                Else
                    getInput
                End If
                Case ""
                quit = MsgBox ("Are you sure?", 36, "Want To quit?")'52
                If quit = 6 Then
                    MsgBox ("Bye!!")
                    WScript.Quit
                Else
                    getInput
                End If
            Case Else
                MsgBox ("That is an incorrect entry, try again")
                getInput
        End Select
    End Sub 'pickInput
   
    Public sub getInput
        'add any menu names you want in this array, make sure you adjust the select/case in pickInput() accordingly
        arrMenu = Array("Computer Management","ADUC","RemoteDesktop","Command Prompt","SQL Admin","User Defined","Quit or click Cancel")
        strText = "Enter selection below." & vbNewLine
        'build the menu
        For i = 1 To (UBound(arrMenu) + 1)
            strText = strText & i & ". " & arrMenu(i - 1) & vbNewLine
        Next
        Input = InputBox(strText, "Make your selection")
        pickInput
    End sub 'getInput
   
    Private Sub startProg(cmd)
        return = WshShell.Run("%windir%\system32\runas.exe /savecred /user:" & username & cmd, 1, False)
    End Sub 'startProg
End Class 'gui_menu

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site
 
 
Post #: 1
 
 RE: runas admin script - 8/28/2006 5:58:51 AM   
  Tnguyen81

 

Posts: 7
Score: 0
Joined: 8/8/2006
Status: offline
This is a very nice script.. LOL 1 yr later..

(in reply to kirrilian)
 
 
Post #: 2
 
 RE: runas admin script - 9/1/2006 2:14:02 PM   
  kirrilian


Posts: 628
Score: 3
Joined: 3/15/2005
From:
Status: offline
It's quite a bit different now too, I will post it when I get back to work next time.

_____________________________

Have you searched here ?
VBScript Fundamentals
My Site

(in reply to Tnguyen81)
 
 
Post #: 3
 
 RE: runas admin script - 10/12/2006 8:35:08 PM   
  est

 

Posts: 39
Score: 0
Joined: 10/12/2006
Status: offline
A abbr way to use runas:

runas /u:administrator /sa xxx.exe

_____________________________

Do NOT program in a programmer's way

(in reply to Tnguyen81)
 
 
Post #: 4
 
 
 
  

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 admin script 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