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