scarboni Posted August 23, 2011 Posted August 23, 2011 (edited) Program name: AdminITVersion: 1.1Author: Tony SundströmWebsite: http://www.rocksta.seDescription: The program is created for support or other type of personeel who sometimes need to start programs using their admin account or want a easier way to come across the administrator tools from MS adminpak. Program Information: Login windows which requires admin username/password/domain to be able to run the applications.Guest account can be used by typing guest att all three locations at the login window.Main GUI have your choosen applications shown as buttons with either icons, small boxes with text or larger boxes with text.Settings allow you to delete the ini file and recreate the ini file it also allows you to change Appearance of the buttons, choose programs to show and other general settings.A ini file is created which will save usefull information for the next time you are using the program for your own good. User information can be saved, if it is it will be saved encrypted inside the ini file and decrypted only when needed. You can download the exe file alone or the zip file with all needed files to be able to run it with the source script.Screenshots: Main GUI, small buttons/textMain GUI, small buttons/iconsMain GUI, Large buttons/textSettings windowCode: The code is pretty heavy and contains around 800 lines of code expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=.\Ico\logo.ICO #AutoIt3Wrapper_Outfile=AdminIT.exe #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=System requierment: Windows XP / 7 #AutoIt3Wrapper_Res_Description=AdminIT #AutoIt3Wrapper_Res_Fileversion=1.0.0.0 #AutoIt3Wrapper_Res_LegalCopyright=CopyRight © 2011 by Tony SL #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Run_Tidy=y #Obfuscator_Parameters=/sci 1 #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListboxConstants.au3> #include <ButtonConstants.au3> #include <TabConstants.au3> #include <IE.au3> #include <Crypt.au3> Opt("GuiOnEventMode", 1) AutoItSetOption ("TrayIconHide" ,1) ;~~~~~~~~~~~~~~~~~~INSTALL ICONS~~~~~~~~~~~~~~~~~~ DirCreate("C:\temp\Icons\") FileInstall(".\ico\Active_Directory.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Add_Printer.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\CMD.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Computer_Management.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Event_Viewer.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Explorer.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Internet_Explorer.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Local_Security_Policy.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Performance.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Remote_Desktop.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Services.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\System_Manager.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\Task_Manager.ico", "C:\temp\Icons\", 1) ;~~~~~~~~~~~~~~~~~~INSTALL MISC~~~~~~~~~~~~~~~~~~ FileInstall(".\AdminIT.ini","c:\temp\AdminIT.ini",0) FileInstall(".\ico\logo.ico", "C:\temp\Icons\", 1) FileInstall(".\ico\donate.gif", "C:\temp\Icons\",1) ;If adminpak is already installed don't add it to the temp folder. If (FileExists(@SystemDir &"\dsa.msc")) Then ;do nothing Else FileInstall(".\adminpak.msi", "c:\temp\", 0) EndIf ;~~~~~~~~~~~~~~~~~~GLOBAL PARAMETERS~~~~~~~~~~~~~~~~~~ Global $iniPath = "c:\temp\AdminIT.ini" Global $iniFile = IniReadSection($iniPath, "Program") Global $iniFileIcon = IniReadSection($iniPath, "IconOption") Global $iniFileUser = IniReadSection($iniPath, "User") Global $hKey=_Crypt_DeriveKey("Tonyscarboni",$CALG_RC4) Global $max = $iniFile[0][0]+1 Global $arr[$max] Global $UNColorState = 0 Global $PWcolorState = 0 Global $DomainColorState = 0 Global $iconOption = 0 HotKeySet("{F1}", "_Info") _LoginGUI() ;========================================================= ; Login GUI ;========================================================= ;The Login GUI which is created in the start ;========================================================= Func _LoginGUI() $winY = 0 ;Move all items at once on the Y-axis Global $LoginForm = GUICreate("Login AdminIT", 230, 168, -1, -1, BitOR($WS_SYSMENU, $WS_CAPTION), $WS_EX_CLIENTEDGE) Global $text = GUICtrlCreateLabel("", 20, 15+$winY, 195, 30, $SS_CENTER) If (($UNColorState = 1) OR ($PWColorState = 1) OR ($DomainColorState = 1)) Then GUICtrlSetData($text, "Failed to login!") GUICtrlSetColor($text, 0x0000ff) Else GUICtrlSetData($text, "Login as domain admin or guest") GUICtrlSetColor($text, 0x0000ff) EndIf GUICtrlCreateLabel("Username *", 20, 53+$winY) If ($UNColorState = 1) Then GUICtrlSetColor(-1, 0xff0000) $UNColorState = 0 Else GUICtrlSetColor(-1, 0x000000) EndIf GUICtrlCreateLabel("Password *", 20, 81+$winY) If ($PWcolorState = 1) Then GUICtrlSetColor(-1, 0xff0000) $PWcolorState = 0 Else GUICtrlSetColor(-1, 0x000000) EndIf GUICtrlCreateLabel("Domain *", 20, 107+$winY) If ($DomainColorState = 1) Then GUICtrlSetColor(-1, 0xff0000) $DomainColorState = 0 Else GUICtrlSetColor(-1, 0x000000) EndIf GUICtrlCreateGroup("", 13, 33+$winY, 205, 100) GUICtrlCreateGroup("", 13, 2+$winY, 205, 32) If (IniRead($iniPath, "User", "Save", "empty") == 1) Then For $l = 1 to $iniFileUser[0][0] $iniCheckUser = IniRead($iniPath, "User", $iniFileUser[$l][0], "empty") If FileExists($iniPath) Then If ($iniFileUser[$l][0] = "Crypto1") Then Global $LoginUN = GUICtrlCreateInput(BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)),80, 53+$winY, 130, 20, BitOR($ES_CENTER, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter a valid Admin Username") ElseIf ($iniFileUser[$l][0] = "Crypto2") Then Global $LoginPW = GUICtrlCreateInput(BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)),80, 78+$winY, 130, 20, BitOR($ES_CENTER, $ES_PASSWORD, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter the Admin Password") ElseIf ($iniFileUser[$l][0] = "Crypto3") Then Global $LoginDomain = GUICtrlCreateInput(BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)),80, 103+$winY, 130, 20, BitOR($ES_CENTER, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter Domain") EndIf EndIf Next Else Global $LoginUN = GUICtrlCreateInput("", 80, 53+$winY, 130, 20, BitOR($ES_CENTER, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter a valid Admin Username") Global $LoginPW = GUICtrlCreateInput("", 80, 78+$winY, 130, 20, BitOR($ES_CENTER, $ES_PASSWORD, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter the Admin Password") Global $LoginDomain = GUICtrlCreateInput("", 80, 103+$winY, 130, 20, BitOR($ES_CENTER, $ES_AUTOHSCROLL)) GUICtrlSetTip(-1, "Enter Domain") EndIf Local $LoginButton = GUICtrlCreateButton("Login", 35, 143+$winY, 80, 20, BitOR($BS_CENTER, $BS_VCENTER, $WS_GROUP, $BS_DEFPUSHBUTTON)) Local $CancelButton1 = GUICtrlCreateButton("Cancel", 125, 143+$winY, 80, 20, BitOR($BS_CENTER, $BS_VCENTER, $WS_GROUP)) ;~~~~~~~~~~Event Handlers~~~~~~~~~~ GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") GUICtrlSetOnEvent($LoginButton, "_LoginCheck") GUICtrlSetOnEvent($CancelButton1, "_Close") EndFunc ;<--- End LoginGUI ;========================================================= ;Login check function ;========================================================= Func _LoginCheck() Local $PWLoginCheck = GUICtrlRead($LoginPW) Local $UNLoginCheck = GUICtrlRead($LoginUN) Local $DomainLoginCheck = GUICtrlRead($LoginDomain) $EncryptPW = _Crypt_EncryptData($PWLoginCheck, $hKey, $CALG_RC4) $EncryptUN = _Crypt_EncryptData($UNLoginCheck, $hKey, $CALG_RC4) $EncryptDomain = _Crypt_EncryptData($DomainLoginCheck, $hKey, $CALG_RC4) If ($PWLoginCheck == "") AND ($UNLoginCheck == "") AND ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "All fields are missing information") $UNColorState = 1 $PWcolorState = 1 $DomainColorState = 1 Guidelete() _LoginGUI() ElseIf ($PWLoginCheck == "") AND ($UNLoginCheck == "") AND NOT ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Username and Password fields are empty") $UNColorState = 1 $PWcolorState = 1 Guidelete() _LoginGUI() Return ElseIf ($PWLoginCheck == "") AND NOT ($UNLoginCheck == "") AND ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Password and Domain fields are empty") $PWcolorState = 1 $DomainColorState = 1 Guidelete() _LoginGUI() Return ElseIf NOT ($PWLoginCheck == "") AND ($UNLoginCheck == "") AND ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Username and Domain field are empty") $UNColorState = 1 $DomainColorState = 1 Guidelete() _LoginGUI() Return ElseIf ($PWLoginCheck == "") AND NOT ($UNLoginCheck == "") AND NOT ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Password field is empty") $PWcolorState = 1 Guidelete() _LoginGUI() Return ElseIf NOT ($PWLoginCheck == "") AND ($UNLoginCheck == "") AND NOT ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Username field is empty") $UNColorState = 1 Guidelete() _LoginGUI() Return ElseIf NOT ($PWLoginCheck == "") AND NOT ($UNLoginCheck == "") AND ($DomainLoginCheck == "") Then MsgBox(0,"Data missing", "Domain field is empty") $DomainColorState = 1 Guidelete() _LoginGUI() Return ElseIf ($PWLoginCheck == "guest") AND ($UNLoginCheck == "guest") AND ($DomainLoginCheck == "guest") Then _Start() Else IniWrite($iniPath, "User", "Crypto1", $EncryptUN) IniWrite($iniPath, "User", "Crypto2", $EncryptPW) IniWrite($iniPath, "User", "Crypto3", $EncryptDomain) _Start() EndIf EndFunc ;=============================================================== ;Start GUI ;=============================================================== Func _Start() ;Declare PW,UN and Domain from ini file For $l = 1 to $iniFileUser[0][0] $iniCheckUser = IniRead($iniPath, "User", $iniFileUser[$l][0], "empty") If FileExists($iniPath) Then If ($iniFileUser[$l][0] = "Crypto1") Then Global $UNCheck = BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)) ElseIf ($iniFileUser[$l][0] = "Crypto2") Then Global $PWCheck = BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)) ElseIf ($iniFileUser[$l][0] = "Crypto3") Then Global $DomainCheck= BinaryToString(_Crypt_DecryptData($iniCheckUser, $hKey, $CALG_RC4)) EndIf EndIf Next ;~~~~~~~~~~~~~~~~~~VARIABLES~~~~~~~~~~~~~~~~~~ GUIDelete($LoginForm) Global $count = -1 Global $iconOption = 0 Global $iconOption2 = 0 Global $progCount = 1 Local $i, $j, $m, $k, $l Local $myX = 10 Local $myY = 10 Local $myX2 = 10 Local $myY2 = 70 Local $myX3 = 10 Local $myY3 = 130 Local $myX4 = 10 Local $myY4 = 190 Local $myX5 = 10 Local $myY5 = 250 Local $myXS = 10 Local $myYS = 10 ;~~~~~~~~~~~~~~~~~~GUI~~~~~~~~~~~~~~~~~~ Global $Start = GUICreate("AdminIT") Global $posW = 320 Global $posXY = WinGetPos ($Start) GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_Close") ;FILE MENU $fileMenu = GUICtrlCreateMenu("&File") $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) GUICtrlSetOnEvent(-1, "_Close") ;TOOLS MENU $settingsMenu = GUICtrlCreateMenu("Tools") $settingsitem = GUICtrlCreateMenuItem("Settings", $SettingsMenu) GUICtrlSetOnEvent(-1, "_Prog") $separator1 = GUICtrlCreateMenuItem("", $SettingsMenu, 1) $iniSettings = GUICtrlCreateMenu("ini Options", $SettingsMenu, 2) $cleariniitem = GUICtrlCreateMenuItem("Clear ini", $iniSettings) GUICtrlSetOnEvent(-1, "_DelIni") $newiniitem = GUICtrlCreateMenuItem("Create ini", $iniSettings) GUICtrlSetOnEvent(-1, "_CreateIni") ;HELP MENU $helpMenu = GUICtrlCreateMenu("Help") $infoitem = GUICtrlCreateMenuItem("Info F1", $helpMenu) GUICtrlSetOnEvent(-1, "_info") ;Set separateprocess RegWrite("HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "SeparateProcess", "REG_DWORD", 0x00000001) ;RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & ' /c "REG ADD HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v SeparateProcess /t REG_DWORD /d 1 /f"', "", @SW_HIDE) ;Icon appearance For $k = 1 to $iniFileIcon[0][0] $iniCheckIcon = IniRead($iniPath, "IconOption", $iniFileIcon[$k][0], "empty") If FileExists($iniPath) Then If (($iniCheckIcon = 1) AND ($iniFileIcon[$k][0] = "IconImage")) Then Global $iconOption = 1 ElseIf (($iniCheckIcon = 1) AND ($iniFileIcon[$k][0] = "IconSize")) Then Global $iconOption2 = 1 EndIf EndIf Next ;Window OnTop If (IniRead($iniPath, "User", "OnTop", "empty") == 1) Then WinSetOnTop("AdminIT","",1) EndIf ;Call InstallAdminPak function to install adminpak if not already installed _AdminPakInstall() ;Call total function for total of checked progress _total() ;Create a Array with only the checked programs Global $arr2[$tot+1][2] Global $arrTEST[$tot+1] For $m = 1 to $iniFile[0][0] $iniCheck = IniRead($iniPath, "Program", $iniFile[$m][0], "empty") If ($iniCheck == 1) OR ($iniCheck == 257) Then $count = $count+1 $arr2[$count][0] = $count $arr2[$count][1] = $iniFile[$m][0] EndIf Next ;Global $arrTEST[$tot+1] ;Set the window size when adding more than one row of objects If (($iconOption == 1) OR ($iconOption == 0) AND ($iconOption2 == 0)) Then If ($count < 5) Then WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 130) ElseIf ($count >=5) AND ($count <10) Then WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 200) ElseIf ($count >=10) AND ($count <15) Then WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 260) ElseIf ($count >=15) AND ($count <20) Then WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 320) ElseIf ($count >=20) AND ($count <25) Then WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 380) Else WinMove ($Start, "", $posXY[0], $posXY[1], $posW, 510) EndIf ElseIf (($iconOption2 == 1) AND ($iconOption == 0)) Then $size = 55 For $o = 1 to $tot $size = $size+36 Next WinMove ($Start, "", $posXY[0], $posXY[1], $posW, $size) EndIf ;Create a new button for every program choosen For $i = 1 to $tot ;Button size option control If (($iconOption == 1) OR ($iconOption == 0) AND ($iconOption2 == 0)) Then If ($progCount < 6) Then $progCount = $progCount+1 If (($iconOption == 1) AND ($iconOption2 == 0)) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX, $myY, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER, $BS_ICON)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetImage(-1, "c:\temp\Icons\"&$arr2[$i-1][1]&".ico", 1) Else GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX, $myY, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) EndIf $myX = $myX+60 $myY = $myY+0 ElseIf ($progCount >=6) AND ($progCount <11) Then $progCount = $progCount+1 If ($iconOption == 1) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX2, $myY2, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER, $BS_ICON)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetImage(-1, "c:\temp\Icons\"&$arr2[$i-1][1]&".ico", 1) Else GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX2, $myY2, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) EndIf $myX2 = $myX2+60 $myY2 = $myY2+0 ElseIf ($progCount >=11) AND ($progCount <16) Then $progCount = $progCount+1 If ($iconOption == 1) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX3, $myY3, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER, $BS_ICON)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetImage(-1, "c:\temp\Icons\"&$arr2[$i-1][1]&".ico", 1) Else GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX3, $myY3, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) EndIf $myX3 = $myX3+60 $myY3 = $myY3+0 ElseIf ($progCount >=16) AND ($progCount <21) Then $progCount = $progCount+1 If ($iconOption == 1) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX4, $myY4, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER, $BS_ICON)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetImage(-1, "c:\temp\Icons\"&$arr2[$i-1][1]&".ico", 1) Else GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX4, $myY4, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) EndIf $myX4 = $myX4+60 $myY4 = $myY4+0 ElseIf ($progCount >=21) AND ($progCount <26) Then $progCount = $progCount+1 If ($iconOption == 1) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX5, $myY5, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER, $BS_ICON)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetImage(-1, "c:\temp\Icons\"&$arr2[$i-1][1]&".ico", 1) Else GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myX5, $myY5, 50, 50, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) EndIf $myX5 = $myX5+60 $myY5 = $myY5+0 EndIf ;big buttons option ElseIf (($iconOption2 == 1) AND ($iconOption == 0)) Then GUICtrlCreateButton(_StringReplaceAccend($arr2[$i-1][1]), $myXS, $myYS, 295, 30, BitOR($BS_MULTILINE, $BS_CENTER)) GUICtrlSetOnEvent(-1, "_"&$arr2[$i-1][1]) GUICtrlSetFont(-1, 10, 100) $myXS = $myXS+0 $myYS = $myYS+35 EndIf Next EndFunc ;=============================================================== ;Tool tab GUI ;=============================================================== Func _Prog() GUIDelete("Start") Local $i, $j, $k, $l, $m Local $tab, $tab0, $CBTree Local $tab1, $tab2 Global $cb Global $Prog = GUICreate("AdminIT", 300, 360) ;~~~~~~~~~~GUI Buttons~~~~~~~~~~ $buttonCheck = GUICtrlCreateButton("Apply", 140, 328, 70, 25) GUICtrlSetOnEvent(-1, "_Check") $buttonCancel = GUICtrlCreateButton("Cancel", 220, 328, 70, 25, $BS_DEFPUSHBUTTON) GUICtrlSetOnEvent(-1, "_GuiDelStart") GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiDelStart") ;~~~~~~~~~~Tab Frame~~~~~~~~~~ $tab = GUICtrlCreateTab(0, 0, 302, 320, $TCS_FIXEDWIDTH) ;~~~~~~~~~~General Tab~~~~~~~~~ $tab0 = GUICtrlCreateTabItem("General") GUICtrlCreateLabel("General settings for the AdminIT application", 15, 30) GUICtrlCreateLabel("Save user information for next logon, All information"&@CRLF&"is encrypted and should be safe to use. You check "&@CRLF&"this box at your own risk.", 20, 67) GUICtrlCreateLabel("The AdminIT window will always be on top which"&@CRLF&"means the window will be shown over all other windows.", 20, 167) GUICtrlCreateGroup("Logon Options", 13, 50, 275, 90) GUICtrlCreateGroup("Always Show Options", 13, 150, 275, 80) Global $saveRB = GUICtrlCreateCheckBox("Save user information", 20, 110) Global $showRB = GUICtrlCreateCheckBox("Window on top", 20, 200) ;Check previously choosen options For $m = 1 to $iniFileUser[0][0] $iniCheckUser = IniRead($iniPath, "User", $iniFileUser[$m][0], "empty") If FileExists($iniPath) Then If ($iniCheckUser = 1) Then If ($iniFileUser[$m][0] == "Save") Then GUICtrlSetState($saveRB, $GUI_CHECKED) ElseIf ($iniFileUser[$m][0] == "OnTop") Then GUICtrlSetState($showRB, $GUI_CHECKED) EndIf EndIf EndIf Next ;~~~~~~~~~~Programs Tab~~~~~~~~~~ $tab1 = GUICtrlCreateTabItem("Programs") GUICtrlCreateLabel("Choose which programs to add to you interface", 15, 30) $CBTree = GUICtrlCreateTreeView(10,55,280,220, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) $buttonCheckAll = GUICtrlCreateButton("Check All", 10, 283, 70, 20) GUICtrlSetOnEvent(-1, "_SelectAll") $buttonUnCheckAll = GUICtrlCreateButton("UnCheck All", 90, 283, 70, 20) GUICtrlSetOnEvent(-1, "_UnSelectAll") ;Check previously chosen programs For $j = 1 to $iniFile[0][0] $arr[$j] = GUICtrlCreateTreeViewItem($iniFile[$j][0], $CBTree) $iniCheck = IniRead($iniPath, "Program", $iniFile[$j][0], "empty") If FileExists($iniPath) Then If Not(($iniCheck == 4) Or ($iniCheck == 260)) Then For $k = 1 To $iniFile[0][0] GUICtrlSetState($arr[$j], $GUI_CHECKED) Next EndIf EndIf Next ;~~~~~~~~~~Appearance Tab~~~~~~~~~ $tab2 = GUICtrlCreateTabItem("Appearance") GUICtrlCreateLabel("Settings to change the appearance of the interface", 15, 30) GUICtrlCreateLabel("You can decide if you want to use the Icons set or if"&@CRLF&"you just want the buttons to just contain the application"&@CRLF&"name.", 20, 67) GUICtrlCreateGroup("Icon Options", 13, 50, 275, 90) Global $iconRB = GUICtrlCreateCheckBox("Use Icon Images", 20, 110) GUICtrlSetOnEvent(-1, "_DisableOne") Global $iconRB2 = GUICtrlCreateCheckBox("Button Resize", 150, 110) GUICtrlSetOnEvent(-1, "_DisableTwo") For $l = 1 to $iniFileIcon[0][0] $iniCheckIcon = IniRead($iniPath, "IconOption", $iniFileIcon[$l][0], "empty") If FileExists($iniPath) Then If ($iniCheckIcon = 1) Then If ($iniFileIcon[$l][0] == "IconSize") Then GUICtrlSetState($iconRB2, $GUI_CHECKED) GUICtrlSetState($iconRB, $GUI_DISABLE) ElseIf ($iniFileIcon[$l][0] == "IconImage") Then GUICtrlSetState($iconRB, $GUI_CHECKED) GUICtrlSetState($iconRB2, $GUI_DISABLE) EndIf EndIf EndIf Next GUICtrlCreateTabItem("") ; end tabitem definition GUISetState() EndFunc ;=============================================================== ;Program Functions ;=============================================================== ;_Active_Directory Program Function ;--------------------------------------------------------------- Func _Active_Directory() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'dsa.msc', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'dsa.msc', "", @SW_HIDE) EndIF EndFunc ;--------------------------------------------------------------- ;_Add_Printer Program Function ;--------------------------------------------------------------- Func _Add_Printer() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /il', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'rundll32 printui.dll,PrintUIEntry /il', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_CMD Program Function ;--------------------------------------------------------------- Func _CMD() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'start Cmd', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'start Cmd', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Computer_Management Program Function ;--------------------------------------------------------------- Func _Computer_Management() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'compmgmt.msc', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'compmgmt.msc', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Event_Viewer Program Function ;--------------------------------------------------------------- Func _Event_Viewer() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'eventvwr', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'eventvwr', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Explorer Program Function ;--------------------------------------------------------------- Func _Explorer() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'explorer.exe', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'explorer.exe', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Internet_Explorer Program Function ;--------------------------------------------------------------- Func _Internet_Explorer() If ($UNCheck == "guest") Then Run(@WindowsDir &"\ie8\iexplore.exe", "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @WindowsDir &"\ie8\iexplore.exe") EndIf EndFunc ;--------------------------------------------------------------- ;_Local_Security_Policy Program Function ;--------------------------------------------------------------- Func _Local_Security_Policy() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'secpol.msc', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'secpol.msc', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Performance Program Function ;--------------------------------------------------------------- Func _Performance() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'perfmon', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'perfmon', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Regedit Program Function ;--------------------------------------------------------------- Func _Regedit() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'regedit', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'regedit', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Remote_Desktop Program Function ;--------------------------------------------------------------- Func _Remote_Desktop() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'mstsc', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'mstsc', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Services Program Function ;--------------------------------------------------------------- Func _Services() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'services.msc', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'services.msc', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_System_Manager Program Function ;--------------------------------------------------------------- Func _System_Manager() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'control SMSCFGRC', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'control SMSCFGRC', "", @SW_HIDE) EndIf EndFunc ;--------------------------------------------------------------- ;_Task_Manager Program Function ;--------------------------------------------------------------- Func _Task_Manager() If ($UNCheck == "guest") Then Run(@ComSpec & " /c " & 'start taskmgr', "", @SW_HIDE) Else RunAs($UNCheck, $DomainCheck, $PWCheck, 0, @ComSpec & " /c " & 'start taskmgr', "", @SW_HIDE) EndIf EndFunc ;======================END PROGRAM============================== ;=============================================================== ;Information GUI ;=============================================================== Func _Info() $text = ""&@CRLF&"Admin Tools is a program created to make it easier for Administrators to use their administration tools."&@CRLF&""&@CRLF&"This program allows the user to choose which programs to show in the main interface and programs can be added and removed to the interface from the list given in settings."&@CRLF&""&@CRLF&"You must have a admin account connected to the domain to be able to use the admin tools, there is also a guest account which is usable to start the programs without admin rights."&@CRLF&""&@CRLF&"Step-by-step"&@CRLF&"1. Go to Tools >> Settings"&@CRLF&"2. Choose which programs to use"&@CRLF&"3. Click the button with the program you want to use"&@CRLF&"4. Enjoy!" GUICreate("Admin Tools - Information",400,350) $Dlink = GUICtrlCreatePic("C:\temp\Icons\donate.gif", 10, 10, 92, 26) GUICtrlSetOnEvent($Dlink, "_DonateLink") $title = GUICtrlCreateLabel("Admin Tools", 150, 20, 100) GUICtrlSetFont(-1, 12, 800) $owner = GUICtrlCreateLabel("Tony Sundström Langlet", 140, 50, 200) GUICtrlCreateButton("Close", 160, 310, 70, 25) GUICtrlSetOnEvent(-1, "_GuiDel") $infoEdit = GUICtrlCreateEdit($text, 10, 70, 380, 230, BitOr($ES_READONLY, $ES_MULTILINE)) GUICtrlSetBkColor(-1, 0xffffff) GUISetOnEvent($GUI_EVENT_CLOSE, "_GuiDel") GUISetState(@SW_SHOW) EndFunc ;=============================================================== ;Close Function ;=============================================================== Func _Close() FileDelete("C:\temp\adminpak.msi") _Crypt_DestroyKey($hKey) Exit EndFunc ;=============================================================== ;Deletes the current GUI ;=============================================================== Func _GuiDel() GUIDelete() EndFunc Func _GuiDelStart() GUIDelete() _Start() EndFunc ;=============================================================== ;Select all objects ;=============================================================== Func _SelectAll() For $z = 1 To $max-1 GUICtrlSetState($arr[$z], $GUI_CHECKED) Next EndFunc ;=============================================================== ;UnSelect all objects ;=============================================================== Func _UnSelectAll() For $z = 1 To $max-1 GUICtrlSetState($arr[$z], $GUI_UNCHECKED) Next EndFunc ;=============================================================== ;Check if the ini files contain checked objects ;=============================================================== Func _Check() Local $icon = GUICtrlRead($iconRB) Local $icon2 = GUICtrlRead($iconRB2) Local $save = GUICtrlRead($saveRB) Local $show = GUICtrlRead($showRB) IniWrite($iniPath, "User", "Save", $save) IniWrite($iniPath, "User", "OnTop", $show) ;Update IconOption Section IniWrite($iniPath, "IconOption", "IconImage", $icon) IniWrite($iniPath, "IconOption", "IconSize", $icon2) ;Update ini file with programs for $i = 1 to $max-1 $progValue = GUICtrlRead($arr[$i]) $name = GUICtrlRead($arr[$i],1) If ($name == "0") Then ;Do Nothing Else IniWrite($iniPath, "Program", $name, $progValue) EndIf Next GUIDelete("Prog") _Start() EndFunc ;=============================================================== ;Check if adminPak is installed else install it ;=============================================================== Func _AdminPakInstall() If (FileExists(@SystemDir &"\dsa.msc")) Then ;do nothing Else RunWait("msiexec /i c:\temp\adminpak.msi /quiet", "") EndIf EndFunc ;=============================================================== ;Counts the total of the checked objects ;=============================================================== Func _total() Global $tot = 0 Local $i For $i = 1 to $iniFile[0][0] $iniCheck = IniRead($iniPath, "Program", $iniFile[$i][0], "empty") If ($iniCheck == 1) OR ($iniCheck == 257) Then $tot = $tot+1 EndIf Next EndFunc ;=============================================================== ;Delete ini ;=============================================================== Func _DelIni() FileDelete($iniPath) GUIDelete() _Start() EndFunc ;=============================================================== ;Create ini ;=============================================================== Func _CreateIni() FileInstall(".\AdminIT.ini","c:\temp\AdminIT.ini",1) GUIDelete() _Start() EndFunc ;=============================================================== ;Disable Functions ;=============================================================== Func _DisableOne() _Disable(1) EndFunc Func _DisableTwo() _Disable(2) EndFunc Func _Disable($arg) Local $iconSize = GUICtrlRead($iconRB2) Local $iconImage = GUICtrlRead($iconRB) If ($arg == 1) Then If ($iconImage = 1) Then GUICtrlSetState($iconRB2, $GUI_DISABLE) ElseIf ($iconImage = 4) Then GUICtrlSetState($iconRB2, $GUI_ENABLE) EndIf ElseIf ($arg == 2) Then If ($iconSize = 1) Then GUICtrlSetState($iconRB, $GUI_DISABLE) ElseIf ($iconSize = 4) Then GUICtrlSetState($iconRB, $GUI_ENABLE) EndIf EndIf EndFunc ;=============================================================== ;Donate Link ;=============================================================== Func _DonateLink() _IECreate("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=tonyscarboni%40hotmail%2ecom&lc=SE¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted") Return EndFunc ;=============================================================== ;Replace _ with a space ;=============================================================== Func _StringReplaceAccend($sString) Local $Pattern[1][2] = [["[_]", " "]] For $i = 0 To 0 $sString = StringRegExpReplace($sString, $Pattern[$i][0], $Pattern[$i][1]) Next Return $sString EndFunc ;=============================================================== ;Keep the GUI alive ;=============================================================== While 1 Sleep(1000) WEndDownload:Zip - Exe Edited August 24, 2011 by scarboni
subzerostig Posted March 21, 2012 Posted March 21, 2012 I get an error when I run it. Line 60 There are 10 types of people in this world. Those that understand binary, and those that do not
BrewManNH Posted March 21, 2012 Posted March 21, 2012 (edited) I'm guessing that's because all the icon files aren't there and the FileInstalls are failing. The OP's links aren't working so there's no way to get them unless someone else has downloaded them in the past year. Edited March 21, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
spudw2k Posted May 9, 2012 Posted May 9, 2012 so, where's the source? the external link is dead.considering the original post was in August of 2011 i don't find this too surprising. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now