runas admin script

Author Message
kirrilian

  • Total Posts : 629
  • Scores: 3
  • Reward points : 0
  • Joined: 3/15/2005
  • Location:
  • Status: offline
runas admin script Friday, December 30, 2005 4:27 AM (permalink)
0
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 [url="http://www.google.com"]here [/url]?
[url="http://tinyurl.com/as7xm"]VBScript Fundamentals[/url]
[url="http://kirrilian.dyndns.org/projects/code/"]My Site[/url]
 
#1
    Tnguyen81

    • Total Posts : 7
    • Scores: 0
    • Reward points : 0
    • Joined: 8/8/2006
    • Status: offline
    RE: runas admin script Monday, August 28, 2006 6:58 AM (permalink)
    0
    This is a very nice script.. LOL 1 yr later..
     
    #2
      kirrilian

      • Total Posts : 629
      • Scores: 3
      • Reward points : 0
      • Joined: 3/15/2005
      • Location:
      • Status: offline
      RE: runas admin script Friday, September 01, 2006 3:14 PM (permalink)
      0
      It's quite a bit different now too, I will post it when I get back to work next time.
      Have you searched [url="http://www.google.com"]here [/url]?
      [url="http://tinyurl.com/as7xm"]VBScript Fundamentals[/url]
      [url="http://kirrilian.dyndns.org/projects/code/"]My Site[/url]
       
      #3
        est

        • Total Posts : 40
        • Scores: 0
        • Reward points : 0
        • Joined: 10/12/2006
        • Status: offline
        RE: runas admin script Thursday, October 12, 2006 9:35 PM (permalink)
        0
        A abbr way to use runas:
         
        runas /u:administrator /sa xxx.exe
        Do NOT program in a programmer's way
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • 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
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9