
scarboni
Active Members-
Posts
22 -
Joined
-
Last visited
Everything posted by scarboni
-
Active Directory UDF - Help & Support
scarboni replied to water's topic in AutoIt General Help and Support
Awsome Water thanks! Can I use the $ADUser[0] to get the total of the Array? Do you think this script would work on a exchange server and AD accessed. 11 days befor the password expires the user will get a email giving them information about the password change. ;=========================== Include =========================== #include <AD.au3> #include <OutlookEX.au3> #include <date.au3> ;========================== Parameters ========================== local $i local $currentDate = _NowDate() Global $ADUsers = _AD_GetGroupMemberOf("Users") ;========== Connect to Outlook and Active Directory ============= Global $oAD = _AD_Open() Global $oOL = _OL_Open() ;========================== E N D =============================== For $i = 1 to $ADUser[0] $passwordInfo = _AD_GetPasswordInfo($ADUser[$i]) $passwordExpireTime = $passwordInfo[9] $calcElevenDays = _DateAdd("D", -11, $passwordExpireTime) If ($currentDate <= $calcElevenDays) Then msgbox(0,"","Password expire time: " & $passwordInfo[9] & @CRLF & "Mail time: " & $calcElevenDays) _OL_Wrapper_SendMail($oOL, $ADUser[$i], "", "", "Password Expires in 10 days", "<h2>User account password Expire</h2><br /> <br /><h3>Information</h3><br /><br /><p>Your accounts password will expire in 10 days,</p>", "", $olFormatHTML, $olImportanceHigh) EndIf Next _OL_Close() ;==>_OL_Start _AD_Close() ;== _AD_Start -
Active Directory UDF - Help & Support
scarboni replied to water's topic in AutoIt General Help and Support
Im sorry im kinda new to using others script or my brain just had a blackout. Lets make a simple example and see if i made it correct I want to make a msg box with the info from the AD user. #include <AD.au3> $domain = "domain1" $username = "user1" $password = "passwd" $fetchedUsername = "fromADUsername" _AD_Open($domain&"\"&$username, $password) $passwordExpireTime = _AD_GetPasswordInfo($fetchedUsername) msgbox(0,"","Password expire time Local Time: "& $passwordExpireTime[9]) msgbox(0,"","Password expire time UTC: "& $passwordExpireTime[11]) _AD_Close() And does $ADUsers = _AD_GetGroupMemberOf("Users") $maxUsers = $ADUser[0] $maxUser result in the maximum amount of users in the users group by typing $ADUser[0]? And while you look this through I wonder if there is a way to be able to get the date of 11 days befor the password expires. So lets say i get the user "Tony" and his passwordExpireTime = 2011-01-20 I would like to be able to get the date 11 days befor that which would result in 2011-01-09 and wonder how i convert the _Date_Time_SystemTimeToDateTimeStr or $sAD_Temp2 to be able to calculate 11 days . If you didnt understand anything of that please tell... -
Active Directory UDF - Help & Support
scarboni replied to water's topic in AutoIt General Help and Support
Hello there Waters, This is a awsome script I read through it and I wonder if there is a function which i can reach... Is it possible to get the date when the password will expire on a user? or is that the Array key in the _AD_GetPasswordInfo #9 and #14? -
This code works but its a ugly solution :S $domain = "domain" $username = "user" $password = "password" send("#r") WinWaitActive("Run") ControlSetText("Run", "","[CLASSNN:Edit1]","c:\windows\system32") send("{ENTER}") ControlFocus("system32", "", "SysListView321") sleep(500) Send("dsa.",1) Send("{APPSKEY}") Sleep(100) send("u") winwaitactive("Run as") ControlCommand("", "", "Button3", "Check") Sleep(500) ControlSetText("Run as", "","[CLASSNN:Edit1]",""&$domain&"\"&$username) ControlSetText("Run as", "","[CLASSNN:Edit2]",""&$password) send("{ENTER}") Also found out another solution which worked better. Send("#r") ControlSetText("Run", "", "[CLASSNN:Edit1]", "runas /user:"&$DomainCheck&"\"&$UNCheck&' "mmc %windir%\system32\dsa.msc"') Send("{ENTER}") WinWaitActive(@WindowsDir &"\system32") Send($PWCheck ,1) Send("{ENTER}")
-
The idea is to get full access to the original AD program, I sure could build my own AD GUI and create most of the functions with your UDF but it would be kinda redundant to invent the wheel once again when all i just want to do is access the program But if it's not possible to use all the functions inside the original AD i probably will have to create my own :S Or I could make a ugly solution where I open the Systemdir and locate dsa.msc and send shift + right mouse button and select run as, check the run as another user and enter the needed information.
-
I would like to get access to this window If im using your UDF i will have to build my own GUI for it right?
-
I read through your UDF a bit, is it able to connect to the Active Directory and search, reset passwords and manage accounts? Im working at a company as a IT dekstop engineer and i created a program named AdminIT which runs AD as the engineers admin account it works to search through the AD but i cannot reset passwords and i suppose i cant create accounts with it either.
-
Am I able to run the AD through the CMD by just adding the original run as command and being able to reset passwords? Runas /user:Domain\Username "dsa.msc"
-
Hello there, I just came across a problem while i was using a simple code contaning run as when im running Active directory. I cant change password on users if i write the following code. If i do a normal run as on the file i can change the password on a ad user but not when im running this code snippet. RunAs($Username, $Domain, $Password, 0, @ComSpec & " /c " & 'dsa.msc', "", @SW_HIDE) Help please
-
Program name: AdminIT Version: 1.1 Author: Tony Sundström Website: http://www.rocksta.se Description: 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/text Main GUI, small buttons/icons Main GUI, Large buttons/text Settings window Code: The code is pretty heavy and contains around 800 lines of code #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) WEnd Download: Zip - Exe
-
Thanks guys, ill do that I hope it works...
-
Replace text and display in a text box?
scarboni replied to ICANSEEYOU7687's topic in AutoIt General Help and Support
If you just want to write something in the window you can add: GUICtrlCreateLabel ( "text", left, top [, width [, height [, style [, exStyle]]]] ) by making a static width and height the text will do an automated linebreak when reaching the end of the labels "frame". Have a window Width: 500px, 400px. Create a label: GUICtrlCreateLabel ("text", 10, 10, 480, 380) -
I did, but for some reason the installation file used some weird format or something... I used all sort of AutoIt functions but didnt get it to work.
-
This is one annoying nut to crack :S I'm making a Admin tool for work and I got to the final stage where we cant run explorer.exe because windows needs to allow SeparateProcess in the regedit. It can be changed if the account you are using is Admin but the whole idea is to be able to run the program with a singel logon and than be able to use all the admin tools needed. As I wrote in previouse post I'm trying to change the regedit state of SeparateProcess with RunAs, but as BrewManNH explained I will just do the changes to the RunAs account if I do it that way. So I went to the section with HKEY_USERS and changed the defult value of all users instead but I'm not sure if it works? Is there anyone who know how to change the state of the current users account or to change it for all users as its really no harm done by changing that setting. And it has to be changed with domain or local Admin priveleges I think...
-
I actually encounterd a similar problem but in an installation of a program but my solution to that problem might not be able to implement on a website though :S I located the windows X(WinX)and Y(winY) and took the X(editX) and Y(editY) from the edit box made a calculation to locate the 0,0 coordinate of the edit field and made the calculation with thouse variables to reach to the checkboxes in the editbox. $editZeroX = $winX + $editX $editZeroY = $winY + $editY $checkboxX = $editZeroX + int (freebased) $checkboxY = $editZeroY + int (freebased) MouseClick ("left" ,$checkboxX ,$checkboxY ,1) I do not recommend this method if there is any easier way to do it as it is dependent on the resolution :S
-
That did change the value of the parameter but does it work? :S
-
Am I able to do this setting for all the users on the machine? by changing the location to HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced???
-
Hello, I'm having a slight problem trying to change a regedit variable but can't get it to work for some reason. I need to run and change it as admin or it won't work in the environment we are using. RunAs("username", "domain", "password", 0, @ComSpec & " /c " & 'REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v SeparateProcess /t REG_DWORD /d 0x00000001 /f', "", @SW_HIDE)
-
I don't know if the close processes does any harm to the programs or the OS, if anyone know please send feedback. Anyway the script takes about 2sec to initiate the shutdown procedure which is pretty neat.
-
I will post the source code in this post. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListboxConstants.au3> #include <IE.au3> Global $list = ProcessList() Global $iniPath = @HomePath & "\ShutIT.ini" Global $max = $list[0][0]+1 Global $arr[$max] If FileExists($iniPath) Then $var = IniReadSection($iniPath, "Action") If @error Then _Start() Else For $i = 1 To $var[0][0] If ($var[$i][1] = "1") Then Global $option = $var[$i][0] _PreShut() Else _Start() EndIf Next EndIf Else _Start() EndIf ;=============================================================== ;Start Function GUI ;=============================================================== Func _Start() $Start = GUICreate("ShutIT",230, 320) ;~~~~~~~~~~GUI Top Menu~~~~~~~~~~ $fileMenu = GUICtrlCreateMenu("&File") $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $settingsMenu = GUICtrlCreateMenu("Tools") $settingsitem = GUICtrlCreateMenuItem("Settings", $SettingsMenu) $deleteitem = GUICtrlCreateMenuItem("Delete ini", $SettingsMenu) $helpMenu = GUICtrlCreateMenu("Help") $infoitem = GUICtrlCreateMenuItem("Info", $helpMenu) ;~~~~~~~~~~GUI List~~~~~~~~~~ GUICtrlCreateGroup("Program Settings", 10, 40, 210, 150) GUICtrlCreateLabel("Chose programs to exit and which action to take when running ShutIT", 10, 10, 210,30) $procList = GUICtrlCreateList("", 20,60, 190, 105, $LBS_NOSEL) ;~~~~~~~~~~GUI Combo~~~~~~~~~~ GUICtrlCreateGroup("Action Settings", 10, 195, 210, 68) $labelCombo = GUICtrlCreateLabel("Action:", 35, 215) Global $decisionCombo = GUICtrlCreateCombo("Close Programs", 75,212, 120) GUICtrlSetData(-1, "Shutdown|Restart|Hibernate") ;~~~~~~~~~~GUI Check Box~~~~~~~~~~ $labelCheckBox = GUICtrlCreateLabel("Use same settings next time:", 35, 240) Global $startCheckBox = GUICtrlCreateCheckBox("", 178,238,20,20) ;~~~~~~~~~~GUI Buttons~~~~~~~~~~ $buttonStart = GUICtrlCreateButton("Start", 30, 270, 75, 25) $buttonCancel = GUICtrlCreateButton("Cancel", 125, 270, 75,25) $buttonPrograms = GUICtrlCreateButton("Programs", 20, 160, 70, 23) ;~~~~~~~~~~List chosen programs to close ~~~~~~~~~~ For $i = 1 to $list[0][0] If ($list[$i][0] == "[System Process]") Or ($list[$i][0] == "svchost.exe") Then ;Do Nothing Else $iniCheck = IniRead($iniPath, "Checked", $list[$i][0], "empty") If FileExists($iniPath) Then If Not(($iniCheck == 4) Or ($iniCheck == 260) Or ($iniCheck == 0) Or ($iniCheck = "empty")) Then $test = GUICtrlSetData($procList, $list[$i][0]) Else ;Do Nothing EndIf Else ;Do Nothing EndIf EndIf Next GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exititem Or $msg = $buttonCancel ExitLoop Case $msg = $settingsitem Or $msg = $buttonPrograms GUIDelete() Sleep(100) _ProcessChoice() Case $msg = $buttonStart _Shutit() Case $msg = $infoitem _Info() Case $msg = $deleteitem FileDelete($iniPath) TrayTip("ShutIT", "The ini file has been deleted", 5,1) EndSelect WEnd _Close() EndFunc ;=============================================================== ;Process Picker GUI ;=============================================================== Func _ProcessChoice() Global $Choice = GUICreate("ShutIT",300, 530) ;~~~~~~~~~~GUI TreeView~~~~~~~~~~ $CBTree = GUICtrlCreateTreeView(10,50,280,390, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_DISABLEDRAGDROP, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) ;~~~~~~~~~~GUI Buttons~~~~~~~~~~ $buttonCheck = GUICtrlCreateButton("Save", 140, 500, 70, 25) $buttonCancel = GUICtrlCreateButton("Cancel", 220, 500, 70, 25) $buttonCheckAll = GUICtrlCreateButton("Check All", 10, 445, 70, 20) $buttonUnCheckAll = GUICtrlCreateButton("UnCheck All", 90, 445, 70, 20) ;~~~~~~~~~~Misc~~~~~~~~~~ $labelTop = GUICtrlCreateLabel("Choose which programs/applications you want to close during the shutdown process", 10, 10, 280,40) $iniFile = IniReadSection($iniPath, "Checked") ;~~~~~~~~~~Check previously chosen programs~~~~~~~~~~ For $i = 1 to $list[0][0] If ($list[$i][0] == "[System Process]") Or ($list[$i][0] == "svchost.exe") Then ;Do Nothing Else $arr[$i] = GUICtrlCreateTreeViewItem($list[$i][0], $CBTree) $iniCheck = IniRead($iniPath, "Checked", $list[$i][0], "empty") If FileExists($iniPath) Then If Not(($iniCheck == 4) Or ($iniCheck == 260)) Then For $z = 1 To $iniFile[0][0] If ($list[$i][0] == $iniFile[$z][0]) Then GUICtrlSetState($arr[$i], $GUI_CHECKED) Else ;Do nothing EndIf Next Else ;Do Nothing EndIf Else ;Do nothing EndIf EndIf Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $buttonCheck _Check() GUIDelete() Sleep(100) _Start() Case $msg = $buttonCancel GUIDelete() Sleep(100) _Start() Case $msg = $buttonCheckAll For $z = 1 To $max-1 GUICtrlSetState($arr[$z], $GUI_CHECKED) Next Case $msg = $buttonUnCheckAll For $z = 1 To $max-1 GUICtrlSetState($arr[$z], $GUI_UNCHECKED) Next EndSelect WEnd GUIDelete() Sleep(100) _Start() EndFunc ;=============================================================== ;Check if a Process has been saved befor ;=============================================================== Func _Check() for $i = 1 to $max-1 $test = GUICtrlRead($arr[$i]) $name = GUICtrlRead($arr[$i],1) If ($name == "0") Then ;Do Nothing Else IniWrite($iniPath, "Checked", $name, $test) EndIf Next EndFunc ;=============================================================== ;Start the ShutIT function ;=============================================================== Func _Shutit() $inputDecision = GUICtrlRead($decisionCombo) $inputSave = GUICtrlRead($startCheckBox) ;~~~~~~~~~~Close the chosen programs~~~~~~~~~~ For $i = 1 to $list[0][0] If ($list[$i][0] == "[System Process]") Or ($list[$i][0] == "svchost.exe") Then ;Do Nothing Else $iniCheck = IniRead($iniPath, "Checked", $list[$i][0], "empty") If FileExists($iniPath) Then If Not(($iniCheck == 4) Or ($iniCheck == 260)) Then ProcessClose($list[$i][0]) TrayTip("ShutIT", "Closing "&$list[$i][0],3,1) Else ;Do Nothing EndIf Else ;Do Nothing EndIf EndIf Next If ($inputDecision = "Shutdown") Then If ($inputSave = 1) Then $cont = MsgBox(36,"","You have set ShutIT to "&$inputDecision&", this setting will be saved and the next time you run ShutIT this action will take place without any window pop-up."&@CRLF&""&@CRLF&"To be able to chose new programs or another action you will have to change the value under [Action] section in shutit.ini to a 0.") Select Case $cont = $GUI_EVENT_CLOSE GUIDelete() _Start() Case $cont = 6 IniWrite($iniPath, "Action", $inputDecision, "1") Case $cont = 7 GUIDelete() _Start() EndSelect Else IniWrite($iniPath, "Action", $inputDecision, "0") EndIf Sleep(1000) Shutdown(5, "Forced AutoIT Shutdown") ElseIf ($inputDecision = "Restart") Then If ($inputSave = 1) Then $cont = MsgBox(36,"","You have set ShutIT to "&$inputDecision&", this setting will be saved and the next time you run ShutIT this action will take place without any window pop-up."&@CRLF&""&@CRLF&"To be able to chose new programs or another action you will have to change the value under [Action] section in shutit.ini to a 0.") Select Case $cont = $GUI_EVENT_CLOSE GUIDelete() _Start() Case $cont = 6 IniWrite($iniPath, "Action", $inputDecision, "1") Case $cont = 7 GUIDelete() _Start() EndSelect Else IniWrite($iniPath, "Action", $inputDecision, "0") EndIf Sleep(1000) Shutdown(6, "Forced AutoIT Restart") ElseIf ($inputDecision = "Hibernate") Then If ($inputSave = 1) Then $cont = MsgBox(36,"","You have set ShutIT to "&$inputDecision&", this setting will be saved and the next time you run ShutIT this action will take place without any window pop-up."&@CRLF&""&@CRLF&"To be able to chose new programs or another action you will have to change the value under [Action] section in shutit.ini to a 0.") Select Case $cont = $GUI_EVENT_CLOSE GUIDelete() _Start() Case $cont = 6 IniWrite($iniPath, "Action", $inputDecision, "1") Case $cont = 7 GUIDelete() _Start() EndSelect Else IniWrite($iniPath, "Action", $inputDecision, "0") EndIf Sleep(1000) Shutdown(68, "Forced AutoIT Hibernate") ElseIf ($inputDecision = "Close Programs") Then If ($inputSave = 1) Then $cont = MsgBox(36,"","You have set ShutIT to "&$inputDecision&", this setting will be saved and the next time you run ShutIT this action will take place without any window pop-up."&@CRLF&""&@CRLF&"To be able to chose new programs or another action you will have to change the value under [Action] section in shutit.ini to a 0.") Select Case $cont = $GUI_EVENT_CLOSE GUIDelete() _Start() Case $cont = 6 IniWrite($iniPath, "Action", $inputDecision, "1") Case $cont = 7 GUIDelete() _Start() EndSelect Else IniWrite($iniPath, "Action", $inputDecision, "0") EndIf Sleep(1000) Else ;Do nothing EndIf EndFunc Func _PreShut() ;~~~~~~~~~~Close the chosen programs~~~~~~~~~~ For $i = 1 to $list[0][0] If ($list[$i][0] == "[System Process]") Or ($list[$i][0] == "svchost.exe") Then ;Do Nothing Else $iniCheck = IniRead($iniPath, "Checked", $list[$i][0], "empty") If FileExists($iniPath) Then If Not(($iniCheck == 4) Or ($iniCheck == 260)) Then ProcessClose($list[$i][0]) TrayTip("ShutIT", "Closing "&$list[$i][0],3,1) Else ;Do Nothing EndIf Else ;Do Nothing EndIf EndIf Next If ($option = "Shutdown") Then Shutdown(5, "Forced AutoIT Shutdown") ElseIf ($option = "Restart") Then Shutdown(6, "Forced AutoIT Restart") ElseIf ($option = "Hibernate") Then Shutdown(68, "Forced AutoIT Hibernate") ElseIf ($option = "Close Programs") Then ;Do Nothing Else ;Do nothing EndIf EndFunc ;=============================================================== ;Close the script ;=============================================================== Func _Close() Exit EndFunc ;=============================================================== ;Information GUI ;=============================================================== Func _Info() $text = ""&@CRLF&"This program is made for thouse who want to shutdown certain programs with one click. You can chose if you want to just shutdown programs or if you want to shutdown programs and Restart/Shutdown/Hybernate your computer"&@CRLF&""&@CRLF&"Step-by-Step"&@CRLF&"1. Go to Tools > Settings and chose which programs to close"&@CRLF&"2. Click the Save button"&@CRLF&"3. Decide if you want to Restart/Shutdown/Hybernate or just close programs"&@CRLF&"4. Click the Start button"&@CRLF&"5. Let the program do its job"&@CRLF&""&@CRLF&"This program is coded in AutoIt scripting language if you have any feedback or is interested in more visit http://www.rocksta.se" GUICreate("ShutIT - Information",400,350) $title = GUICtrlCreateLabel("ShutIT", 170, 20, 100) GUICtrlSetFont(-1, 12, 800) $owner = GUICtrlCreateLabel("Tony Sundström Langlet", 140, 50, 200) $link = GUICtrlCreateLabel("www.rocksta.se",160, 70, 100) GUICtrlSetColor(-1, 0x0000FF) $buttonClose = GUICtrlCreateButton("Close", 160, 310, 70, 25) $infoEdit = GUICtrlCreateEdit($text, 10, 100, 380, 200, BitOr($ES_READONLY, $ES_MULTILINE)) GUICtrlSetBkColor(-1, 0xffffff) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $buttonClose ExitLoop Case $msg = $link _IECreate("http://www.rocksta.se") EndSelect WEnd GUIDelete() EndFunc
-
I created a script which will help out closing programs befor shutdown/restart/hibernate your computer. The idea came to me when my computer didn't turn of properly when I clicked Start -> Shutdown, it for some reason got stuck on shuting down the programs running. This script can solve some problems but it probably isn't a world changing script I just wanted to post it for others who might have the same problem and want to solve it with a easy script. Please send feedback, thoughts and if you find anything that could be a contribution for its upgrade. ShutIT ** GUI ** *Menu* File - Exit script Tools- Clear the ini file and go into choose programs process. Help - A little information part. *Buttons* Programs - choose which programs that are active to close when starting the script. Start - Start the main function Cancel - Exit the script *List View* Shows the choose programs. *Radio buttons* Use same settings next time - If you don't want to open the GUI next time you double click the file but start the script immediately ** Function ** First the script will check if you already got a ini file created if not it will create one, if you got programs checked from previously runs it will automaticly add thouse to the list view. If you enter the Choose programs section you will be able to mark all, unmark all active processes. When you have marked all the processes you want to close during the script you will have to click the button Save and it will jump back to first GUI screen, during this it will save all your choosen programs and add them to the ini file. Decided if you just want to close the choosen programs or if you want to close the programs and shutdown/restart/hibernate afterwards. If you do not want to go into this GUI again you can mark the Save settings for next time and it will remember the programs you have choosen.Download link: ShutIT.zip Website: Website link Screenshot: