scwoobles

combobox set values

7 posts in this topic

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Windows Updates", 8, 376, 289, 65)
$Combo1 = GUICtrlCreateCombo("Sunday", 24, 400, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("12:00AM", 184, 400, 105, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetData($Combo1, "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "Monday")
GUICtrlSetData($Combo2, "1:00AM|2:00AM|3:00AM|4:00AM|5:00AM|6:00AM|7:00AM|8:00AM|9:00AM|10:00AM|11:00AM|12:00PM|1:00PM|2:00PM|3:00PM|4:00PM|5:00PM|6:00PM|7:00PM|8:00PM|9:00PM|10:00PM|11:00PM", "5:00AM")

I am looking for a way to make it so when the user selects an option that it gives a numerical value for later use in the program

eg.

if the user selects wednesday that would be a value of 4, where as sunday would be a value of 1

and the time would be basicly converted to the 24 Hour clock, so if the user selects 5AM that would be a value of 5, where as 7pm would be a value of 19,

Thanks in advance

Share this post


Link to post
Share on other sites



So what particular issue is it that you are requesting advice on?  Is it the future accessing of the information within the application?  Have you considered using the INI functions in the file, directory, and disk functions in the help file (at the very end).  That way the information is stored in a file outside the application, but the file and the information can still be easily accessed and modified as need be.  For example, if you want the user to be able to save a single checkbox selection, you can use INIdelete to remove the previous entries and update the info.  Since I am not sure what the entire objective of your script is, I am only speculating here, but you would need to create conditional statements that would run when the control is selected.  for example:

$Form1 = GUICreate("Test", 555, 473, 205, 146)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Windows Updates", 8, 376, 289, 65)
$Combo1 = GUICtrlCreateCombo("Sunday", 24, 400, 97, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("12:00AM", 184, 400, 105, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetData($Combo1, "Monday|Tuesday|Wednesday|Thursday|Friday|Saturday", "Monday")
GUICtrlSetData($Combo2, "1:00AM|2:00AM|3:00AM|4:00AM|5:00AM|6:00AM|7:00AM|8:00AM|9:00AM|10:00AM|11:00AM|12:00PM|1:00PM|2:00PM|3:00PM|4:00PM|5:00PM|6:00PM|7:00PM|8:00PM|9:00PM|10:00PM|11:00PM", "5:00AM")

While 1
    $nmsp = GUIGetMsg ()
    Switch $nmsp
        Case $GUI_EVENT_CLOSE
            Exit
            
        Case $Combo1
            $select = GUICtrlRead ( $Combo1 )
            If $select == "Sunday" Then
                $num = 1
                ;stuff you want to do when sunday
            ElseIf $select == "Monday" Then
                $num = 2
                ;stuff you want to do when monday
            ElseIf $select == "Tuesday" Then
                $num = 3
                ;stuff you want to do when tuesday
                ;keep calling elseif for remainder days of week then
            Else
                ;put soomething random or nothing here at all, as this block will most likely never execute.
            EndIf
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I think using arrays is a good idea:

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <Array.au3>

Global $aWeekdays[8] = [7, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
;a 1 based array row 0 = count of real elements
Global $aHours[24]  ;a 0 based array all rows are used from elements
_initHours()
$Form1 = GUICreate("Test", 555, 473, 205, 146)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Windows Updates", 8, 376, 289, 65)
$Combo1 = GUICtrlCreateCombo("", 24, 400, 97, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 184, 400, 105, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlCreateGroup("", -99, -99, 1, 1)
_SetDay()
_setHour()
GUISetState(@SW_SHOW)

While 1
    $nmsp = GUIGetMsg()
    Switch $nmsp
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1
            $select = GUICtrlRead($Combo1)
            $iWeekday=_ArraySearch($aWeekdays,$select)
            Switch $iWeekday
                case 2 to 6
                    MsgBox(0,'working Day: ',"hurry up it's time to work something")
                Case 7
                    MsgBox(0,'Saturday','time to do do work in garden')
                Case 8
                    MsgBox(0,'Sunday','do just what you want')
            EndSwitch
        Case $Combo2
            $select = GUICtrlRead($Combo2)
            $iHour =_ArraySearch($aHours,$select)
            MsgBox(0,'Hour',$select&': '&$iHour)
    EndSwitch
WEnd

Func _initHours()
    For $i=0 to 12
        $aHours[$i]=$i&':00 am'
    Next
    For $i=13 to 23
        $aHours[$i]=$i&':00 pm'
    Next
EndFunc

Func _SetDay()
    Local $iWeekday = _DateToDayOfWeek(@YEAR, @MON, @MDAY)
    For $i = 1 To 7
        If $i = $iWeekday Then
            GUICtrlSetData($Combo1, $aWeekdays[$i], $aWeekdays[$i])
        Else
            GUICtrlSetData($Combo1, $aWeekdays[$i])
        EndIf
    Next
EndFunc   ;==>_SetDay

Func _setHour()
    For $i=0 To 23
        If $i=@HOUR Then
            GUICtrlSetData($Combo2, $aHours[$i], $aHours[$i])
        Else
            GUICtrlSetData($Combo2, $aHours[$i])
        EndIf
    Next
EndFunc

 

Edited by AutoBert

Share this post


Link to post
Share on other sites
#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\aaron.kennedy\desktop\test1.kxf
$Form1_1 = GUICreate("Form1", 293, 328, 192, 124)
$Group1 = GUICtrlCreateGroup("Network Information", 8, 8, 273, 193)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1_1, 128, 24, 145, 17)
_GUICtrlIpAddress_Set($IPAddress1, "192.168.4.100")
$Subnet = _GUICtrlIpAddress_Create($Form1_1, 128, 48, 145, 17)
_GUICtrlIpAddress_Set($Subnet, "255.255.255.0")
$DefaultGateway = _GUICtrlIpAddress_Create($Form1_1, 128, 72, 145, 17)
_GUICtrlIpAddress_Set($DefaultGateway, "192.168.4.1")
$DNS1 = _GUICtrlIpAddress_Create($Form1_1, 128, 112, 146, 17)
_GUICtrlIpAddress_Set($DNS1, "192.168.4.1")
_GUICtrlIpAddress_ShowHide($DNS1, @SW_HIDE)
$DNS2 = _GUICtrlIpAddress_Create($Form1_1, 128, 136, 145, 17)
_GUICtrlIpAddress_Set($DNS2, "8.8.4.4")
_GUICtrlIpAddress_ShowHide($DNS2, @SW_HIDE)
$Checkbox1 = GUICtrlCreateCheckbox("Custom DNS", 24, 168, 97, 17)
$Label1 = GUICtrlCreateLabel("IP Address", 24, 24, 55, 17)
$Label2 = GUICtrlCreateLabel("Subnet Mask", 24, 48, 67, 17)
$Label3 = GUICtrlCreateLabel("Default Gateway", 24, 72, 83, 17)
$Label4 = GUICtrlCreateLabel("Primary DNS", 24, 120, 64, 17)
$Label5 = GUICtrlCreateLabel("Secondary DNS", 24, 136, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 216, 288, 65, 33)
$Button2 = GUICtrlCreateButton("Cancel", 16, 288, 65, 33)
$ALOHABOH = GUICtrlCreateInput("ALOHABOH", 128, 224, 145, 21)
$Label6 = GUICtrlCreateLabel("Computer Name", 24, 224, 80, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region ;Varibles
Local $string = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}"
Local $Value1 = "ProviderName"
Local $Value2 = "PnPCapabilities"
Local $key0 = RegRead($string &"\0000",$Value1)
Local $key1 = RegRead($string &"\0001",$Value1)
Local $key2 = RegRead($string &"\0002",$Value1)
Local $key3 = RegRead($string &"\0003",$Value1)
Local $key4 = RegRead($string &"\0004",$Value1)
Local $key5 = RegRead($string &"\0005",$Value1)
Local $key6 = RegRead($string &"\0006",$Value1)
Local $key7 = RegRead($string &"\0007",$Value1)
Local $key8 = RegRead($string &"\0008",$Value1)
Local $key9 = RegRead($string &"\0009",$Value1)
Local $key10 = RegRead($string &"\0010",$Value1)
Local $key11 = RegRead($string &"\0011",$Value1)
Local $key12 = RegRead($string &"\0012",$Value1)
Local $key13 = RegRead($string &"\0013",$Value1)
Local $key14 = RegRead($string &"\0014",$Value1)
Local $key15 = RegRead($string &"\0015",$Value1)
Local $key16 = RegRead($string &"\0016",$Value1)
Local $key17 = RegRead($string &"\0017",$Value1)
Local $key18 = RegRead($string &"\0018",$Value1)
Local $key19 = RegRead($string &"\0019",$Value1)
Local $key20 = RegRead($string &"\0020",$Value1)
#EndRegion

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
                If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    _GUICtrlIpAddress_ShowHide($DNS1, @SW_SHOW)
    _GUICtrlIpAddress_ShowHide($DNS2, @SW_SHOW)
                EndIf

        Case $Button2
            Exit

        Case $Button1


#Region ; Logging
DirCreate ( "C:\Setup\" )
DirCreate ( "C:\Setup\Logs\" )
FileInstall("C:\work\Hospitallity\TBMUserSetup.bat","C:\Setup\TBMUserSetup.bat")
FileInstall("C:\work\Hospitallity\firewall_ports.bat","C:\Setup\firewall_ports.bat")
FileInstall("C:\work\Hospitallity\setwork.ps1","C:\Setup\setwork.ps1")
#EndRegion
#Region ;Registry
MsgBox(64,"Terminal Registry","The Registry will be modified",0,0)
Sleep(2000)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\","DisabledComponents","REG_DWORD",0xffffffff) ;tcpip6
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\","DisabledDHCPMediaSense","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CSC\","Start","REG_DWORD",4)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","FileinfoCacheLifetime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","FileNotFoundCacheLiftime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","DirectoryCacheLiftime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\","DontShowUI","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","SoftwareSASGeneration","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","EnableLUA","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","ConsentPromptBehaviorAdmin","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","PromptOnSecureDesktop","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","dontdisplaylastusername","REG_DWORD",1); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","DontDisplayLockedUserId","REG_DWORD",8); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL\","CheckedValue","REG_DWORD",1);show folders
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\HideFileExt\","CheckedValue","REG_DWORD",1); show file extentions
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\SharingWizardOn\","CheckedValue","REG_DWORD",1); should disable file share wiz
RegWrite("HKLM\SYSTEM\ControlSet001\Control\TimeZoneInformation\","TimeZoneKeyName","REG_SZ","Mountain Standard Time"); first timezone change
RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\","TimeZoneKeyName","REG_SZ","Mountain Standard Time"); Second timezone change
; Windows 10 Disable
RegWrite("HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\","DisableOSUpgrade","REG_DWORD",1)
RegWrite("HKLM\SOFTWARE\Policies\Microsoft\Windows\GWX\","DisableGwx","REG_DWORD",1)
RegWrite("HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade\","ReservationsAllowed","REG_DWORD",0)
; Windows 10 Disable
RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\381b4222-f694-41f0-9685-ff5bb260df2e\0012ee47-9041-4b5d-9b77-535fba8b1442\6738e2c4-e8a5-4a42-b16a-e040e769756e\","ACSettingIndex","REG_DWORD",0)
if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLockedUserId",2) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\","DontDisplayLockedUserId","REG_DWORD",2)
EndIf
if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions",4) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","AUOptions","REG_DWORD",4)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDay",2) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallDay","REG_DWORD",2)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallTime",5) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallTime","REG_DWORD",5)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\IncludeRecommendedUpdates",0) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","IncludeRecommendedUpdates","REG_DWORD",0)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ElevateNonAdmins",1) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ElevateNonAdmins","REG_DWORD",1)
EndIf
MsgBox(64,"Terminal Registry","The Registry has been modified",0,0)
#EndRegion
Sleep(2000)
MsgBox(64,"Terminal Commands","The DOS commands will start in 2 Seconds",0,0)
Sleep(2000)
Run(@ComSpec & " /c " & 'NET TIME \\ALOHABOH /SET /YES > C:\Setup\Logs\Nettime.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'bcdedit.exe /set nx alwaysoff > C:\Setup\Logs\bcdedit.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'sc config "UI0Detect" start= disabled > C:\Setup\Logs\isd.log', "", @SW_HIDE); Interactive Services detection
Sleep(2000)
#Region ;Network IP setting
Run(@ComSpec & " /c " & 'netsh interface ip set address name="Local Area Connection" source=static addr='&  _GUICtrlIpAddress_Get( $IPAddress1) &' mask='& _GUICtrlIpAddress_Get($Subnet) &' gateway='& _GUICtrlIpAddress_Get($DefaultGateway) &' gwmetric=1', "", @SW_HIDE) ;setting of IP address
Run(@ComSpec & " /c " & 'netsh interface ipv4 add dns "Local Area Connection" ' & _GUICtrlIpAddress_Get($DNS1), "", @SW_HIDE) ;setting of Dns 1 address
Run(@ComSpec & " /c " & 'netsh interface ipv4 add dns "Local Area Connection" ' & _GUICtrlIpAddress_Get($DNS2) & ' index=2', "", @SW_HIDE) ;setting of Dns 2 address
Run(@ComSpec & " /c " & 'wmic computersystem where name="%COMPUTERNAME%" call rename name="' & GUICtrlRead($ALOHABOH) & '"', "", @SW_HIDE)
MsgBox(64,"Terminal User Setup","The User Setup will start in 2 Seconds",0,0)
Sleep(2000)
Run(@ComSpec & " /c " & 'C:\Setup\TBMUserSetup.bat', "", @SW_SHOW)
Run(@ComSpec & " /c " & 'Powershell.exe C:\Setup\setwork.ps1', "", @SW_SHOW)
Run(@ComSpec & " /c " & 'C:\Setup\firewall_ports.bat > C:\Setup\Logs\Firewall.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'wmic nicconfig where TcpipNetbiosOptions=0 call SetTcpipNetbios 2 > C:\Setup\Logs\Netbios.log', "", @SW_HIDE) ; Netbios
Run(@ComSpec & " /c " & 'powercfg -x -disk-timeout-ac 0', "", @SW_HIDE)
#Region ;Network Power Disable
if not ($key0 ="Microsoft") Then
    RegWrite($string &"\0000",$Value2,"REG_DWORD",24)
EndIf

if not ($key1 ="Microsoft") Then
    RegWrite($string &"\0001",$Value2,"REG_DWORD",24)
EndIf

if not ($key2 ="Microsoft") Then
    RegWrite($string &"\0002",$Value2,"REG_DWORD",24)
EndIf

if not ($key3 ="Microsoft") Then
    RegWrite($string &"\0003",$Value2,"REG_DWORD",24)
EndIf

if not ($key4 ="Microsoft") Then
    RegWrite($string &"\0004",$Value2,"REG_DWORD",24)
EndIf

if not ($key5 ="Microsoft") Then
    RegWrite($string &"\0005",$Value2,"REG_DWORD",24)
EndIf

if not ($key6 ="Microsoft") Then
    RegWrite($string &"\0006",$Value2,"REG_DWORD",24)
EndIf

if not ($key7 ="Microsoft") Then
    RegWrite($string &"\0007",$Value2,"REG_DWORD",24)
EndIf

if not ($key8 ="Microsoft") Then
    RegWrite($string &"\0008",$Value2,"REG_DWORD",24)
EndIf

if not ($key9 ="Microsoft") Then
    RegWrite($string &"\0009",$Value2,"REG_DWORD",24)
EndIf

if not ($key10 ="Microsoft") Then
    RegWrite($string &"\0010",$Value2,"REG_DWORD",24)
EndIf
if not ($key11 ="Microsoft") Then
    RegWrite($string &"\0011",$Value2,"REG_DWORD",24)
EndIf

if not ($key12 ="Microsoft") Then
    RegWrite($string &"\0012",$Value2,"REG_DWORD",24)
EndIf

if not ($key13 ="Microsoft") Then
    RegWrite($string &"\0013",$Value2,"REG_DWORD",24)
EndIf

if not ($key14 ="Microsoft") Then
    RegWrite($string &"\0014",$Value2,"REG_DWORD",24)
EndIf

if not ($key15 ="Microsoft") Then
    RegWrite($string &"\0015",$Value2,"REG_DWORD",24)
EndIf

if not ($key16 ="Microsoft") Then
    RegWrite($string &"\0016",$Value2,"REG_DWORD",24)
EndIf

if not ($key17 ="Microsoft") Then
    RegWrite($string &"\0017",$Value2,"REG_DWORD",24)
EndIf

if not ($key18 ="Microsoft") Then
    RegWrite($string &"\0018",$Value2,"REG_DWORD",24)
EndIf

if not ($key19 ="Microsoft") Then
    RegWrite($string &"\0019",$Value2,"REG_DWORD",24)
EndIf

if not ($key20 ="Microsoft") Then
    RegWrite($string &"\0020",$Value2,"REG_DWORD",24)
EndIf
#EndRegion
#Region ; Set Long File Date all users
If @OSArch = "X86" Then
Fileinstall("C:\work\Hospitallity\Script files\slongdate.exe","C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup\slongdate.exe")
ElseIf @OSArch = "X64" Then
Fileinstall("C:\work\Hospitallity\Script files\slongdate64.exe","C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup\slongdate64.exe")
EndIf
sleep(2500)
;Run(@ComSpec & " /c " & 'copy C:\slongdate.exe C:\Windows\System32\GroupPolicy\User\Scripts\Logon\slongdate.exe', "", @SW_HIDE)
;Sleep(2500)
;FileOpen("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini",$FO_OVERWRITE)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "[Logon]" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "0CmdLine=slongdate.exe" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "0Parameters=" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", @CRLF)
;FileClose("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini")
#EndRegion
MsgBox(64,"Checklist","The Checklist has been run",0,0)
Sleep(7000)
ProcessWaitClose("cmd.exe")
FileDelete("C:\Setup\TBMUserSetup.bat")
FileDelete("C:\Setup\firewall_ports.bat")
FileDelete("C:\Setup\setwork.ps1")
Shutdown(6)
Exit
    EndSwitch
WEnd

I think the array would be the ticket however I am just not sure how to properly convert the string

RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallDay","REG_DWORD",2)

where 2 = monday

but from the example above I can make it work for that but

 

for the time i am not sure how to, 

RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallTime","REG_DWORD",5)

where 5= 5:00AM

I would like to keep the information in the combobox to be in the 12 hour clock format, but when the script parses it grabs the 24 hour clock format I am just not sure how to put that into an array to count it to pass it to a varible

Share this post


Link to post
Share on other sites

I couldn't find a combo in your script and as you see in my script, i get time in 24 h format and the array is in 12 h format. The little changed skript: 

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <Array.au3>

Global $iHour, $iWeekday
Global $aWeekdays[8] = [7, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
;a 1 based array row 0 = count of real elements
Global $aHours[24]  ;a 0 based array all rows are used from elements
_initHours()
$Form1 = GUICreate("Test", 555, 473, 205, 146)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Windows Updates", 8, 376, 289, 65)
$Combo1 = GUICtrlCreateCombo("", 24, 400, 97, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 184, 400, 105, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Convert= GUICtrlCreateButton('&OK',450,400,55, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
_SetDay()
_setHour()
GUISetState(@SW_SHOW)

While 1
    $nmsp = GUIGetMsg()
    Switch $nmsp
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1
            $select = GUICtrlRead($Combo1)
            $iWeekday=_ArraySearch($aWeekdays,$select)
        Case $Combo2
            $select = GUICtrlRead($Combo2)
            $iHour =_ArraySearch($aHours,$select)
        Case $Convert
            RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallDay","REG_DWORD",$iWeekday)
            RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallTime","REG_DWORD",$iHour)             
    EndSwitch
WEnd

Func _initHours()
    For $i=0 to 12
        $aHours[$i]=$i&':00 am'
    Next
    For $i=13 to 23
        $aHours[$i]=$i&':00 pm'
    Next
EndFunc

Func _SetDay()
    Local $iWeekday = _DateToDayOfWeek(@YEAR, @MON, @MDAY)
    For $i = 1 To 7
        If $i = $iWeekday Then
            GUICtrlSetData($Combo1, $aWeekdays[$i], $aWeekdays[$i])
        Else
            GUICtrlSetData($Combo1, $aWeekdays[$i])
        EndIf
    Next
EndFunc   ;==>_SetDay

Func _setHour()
    For $i=0 To 23
        If $i=@HOUR Then
            GUICtrlSetData($Combo2, $aHours[$i], $aHours[$i])
        Else
            GUICtrlSetData($Combo2, $aHours[$i])
        EndIf
    Next
    $iHour=@HOUR
EndFunc
#RequireAdmin
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <FileConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\aaron.kennedy\desktop\test1.kxf
$Form1_1 = GUICreate("Form1", 293, 328, 192, 124)
$Group1 = GUICtrlCreateGroup("Network Information", 8, 8, 273, 193)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1_1, 128, 24, 145, 17)
_GUICtrlIpAddress_Set($IPAddress1, "192.168.4.100")
$Subnet = _GUICtrlIpAddress_Create($Form1_1, 128, 48, 145, 17)
_GUICtrlIpAddress_Set($Subnet, "255.255.255.0")
$DefaultGateway = _GUICtrlIpAddress_Create($Form1_1, 128, 72, 145, 17)
_GUICtrlIpAddress_Set($DefaultGateway, "192.168.4.1")
$DNS1 = _GUICtrlIpAddress_Create($Form1_1, 128, 112, 146, 17)
_GUICtrlIpAddress_Set($DNS1, "192.168.4.1")
_GUICtrlIpAddress_ShowHide($DNS1, @SW_HIDE)
$DNS2 = _GUICtrlIpAddress_Create($Form1_1, 128, 136, 145, 17)
_GUICtrlIpAddress_Set($DNS2, "8.8.4.4")
_GUICtrlIpAddress_ShowHide($DNS2, @SW_HIDE)
$Checkbox1 = GUICtrlCreateCheckbox("Custom DNS", 24, 168, 97, 17)
$Label1 = GUICtrlCreateLabel("IP Address", 24, 24, 55, 17)
$Label2 = GUICtrlCreateLabel("Subnet Mask", 24, 48, 67, 17)
$Label3 = GUICtrlCreateLabel("Default Gateway", 24, 72, 83, 17)
$Label4 = GUICtrlCreateLabel("Primary DNS", 24, 120, 64, 17)
$Label5 = GUICtrlCreateLabel("Secondary DNS", 24, 136, 81, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("OK", 216, 288, 65, 33)
$Button2 = GUICtrlCreateButton("Cancel", 16, 288, 65, 33)
$ALOHABOH = GUICtrlCreateInput("ALOHABOH", 128, 224, 145, 21)
$Label6 = GUICtrlCreateLabel("Computer Name", 24, 224, 80, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region ;Varibles
Local $string = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}"
Local $Value1 = "ProviderName"
Local $Value2 = "PnPCapabilities"
Local $key0 = RegRead($string &"\0000",$Value1)
Local $key1 = RegRead($string &"\0001",$Value1)
Local $key2 = RegRead($string &"\0002",$Value1)
Local $key3 = RegRead($string &"\0003",$Value1)
Local $key4 = RegRead($string &"\0004",$Value1)
Local $key5 = RegRead($string &"\0005",$Value1)
Local $key6 = RegRead($string &"\0006",$Value1)
Local $key7 = RegRead($string &"\0007",$Value1)
Local $key8 = RegRead($string &"\0008",$Value1)
Local $key9 = RegRead($string &"\0009",$Value1)
Local $key10 = RegRead($string &"\0010",$Value1)
Local $key11 = RegRead($string &"\0011",$Value1)
Local $key12 = RegRead($string &"\0012",$Value1)
Local $key13 = RegRead($string &"\0013",$Value1)
Local $key14 = RegRead($string &"\0014",$Value1)
Local $key15 = RegRead($string &"\0015",$Value1)
Local $key16 = RegRead($string &"\0016",$Value1)
Local $key17 = RegRead($string &"\0017",$Value1)
Local $key18 = RegRead($string &"\0018",$Value1)
Local $key19 = RegRead($string &"\0019",$Value1)
Local $key20 = RegRead($string &"\0020",$Value1)
#EndRegion

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Checkbox1
                If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
    _GUICtrlIpAddress_ShowHide($DNS1, @SW_SHOW)
    _GUICtrlIpAddress_ShowHide($DNS2, @SW_SHOW)
                EndIf

        Case $Button2
            Exit

        Case $Button1


#Region ; Logging
DirCreate ( "C:\Setup\" )
DirCreate ( "C:\Setup\Logs\" )
FileInstall("C:\work\Hospitallity\TBMUserSetup.bat","C:\Setup\TBMUserSetup.bat")
FileInstall("C:\work\Hospitallity\firewall_ports.bat","C:\Setup\firewall_ports.bat")
FileInstall("C:\work\Hospitallity\setwork.ps1","C:\Setup\setwork.ps1")
#EndRegion
#Region ;Registry
MsgBox(64,"Terminal Registry","The Registry will be modified",0,0)
Sleep(2000)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\","DisabledComponents","REG_DWORD",0xffffffff) ;tcpip6
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\","DisabledDHCPMediaSense","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CSC\","Start","REG_DWORD",4)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","FileinfoCacheLifetime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","FileNotFoundCacheLiftime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters\","DirectoryCacheLiftime","REG_DWORD",0)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting\","DontShowUI","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","SoftwareSASGeneration","REG_DWORD",1)
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","EnableLUA","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","ConsentPromptBehaviorAdmin","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","PromptOnSecureDesktop","REG_DWORD",0); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","dontdisplaylastusername","REG_DWORD",1); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\","DontDisplayLockedUserId","REG_DWORD",8); Disables UAC
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL\","CheckedValue","REG_DWORD",1);show folders
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\HideFileExt\","CheckedValue","REG_DWORD",1); show file extentions
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\SharingWizardOn\","CheckedValue","REG_DWORD",1); should disable file share wiz
RegWrite("HKLM\SYSTEM\ControlSet001\Control\TimeZoneInformation\","TimeZoneKeyName","REG_SZ","Mountain Standard Time"); first timezone change
RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\","TimeZoneKeyName","REG_SZ","Mountain Standard Time"); Second timezone change
; Windows 10 Disable
RegWrite("HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\","DisableOSUpgrade","REG_DWORD",1)
RegWrite("HKLM\SOFTWARE\Policies\Microsoft\Windows\GWX\","DisableGwx","REG_DWORD",1)
RegWrite("HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade\","ReservationsAllowed","REG_DWORD",0)
; Windows 10 Disable
RegWrite("HKLM\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\381b4222-f694-41f0-9685-ff5bb260df2e\0012ee47-9041-4b5d-9b77-535fba8b1442\6738e2c4-e8a5-4a42-b16a-e040e769756e\","ACSettingIndex","REG_DWORD",0)
if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLockedUserId",2) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\","DontDisplayLockedUserId","REG_DWORD",2)
EndIf
if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\AUOptions",4) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","AUOptions","REG_DWORD",4)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallDay",2) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallDay","REG_DWORD",2)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ScheduledInstallTime",5) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallTime","REG_DWORD",5)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\IncludeRecommendedUpdates",0) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","IncludeRecommendedUpdates","REG_DWORD",0)
EndIf

if not RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\ElevateNonAdmins",1) Then
    RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ElevateNonAdmins","REG_DWORD",1)
EndIf
MsgBox(64,"Terminal Registry","The Registry has been modified",0,0)
#EndRegion
Sleep(2000)
MsgBox(64,"Terminal Commands","The DOS commands will start in 2 Seconds",0,0)
Sleep(2000)
Run(@ComSpec & " /c " & 'NET TIME \\ALOHABOH /SET /YES > C:\Setup\Logs\Nettime.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'bcdedit.exe /set nx alwaysoff > C:\Setup\Logs\bcdedit.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'sc config "UI0Detect" start= disabled > C:\Setup\Logs\isd.log', "", @SW_HIDE); Interactive Services detection
Sleep(2000)
#Region ;Network IP setting
Run(@ComSpec & " /c " & 'netsh interface ip set address name="Local Area Connection" source=static addr='&  _GUICtrlIpAddress_Get( $IPAddress1) &' mask='& _GUICtrlIpAddress_Get($Subnet) &' gateway='& _GUICtrlIpAddress_Get($DefaultGateway) &' gwmetric=1', "", @SW_HIDE) ;setting of IP address
Run(@ComSpec & " /c " & 'netsh interface ipv4 add dns "Local Area Connection" ' & _GUICtrlIpAddress_Get($DNS1), "", @SW_HIDE) ;setting of Dns 1 address
Run(@ComSpec & " /c " & 'netsh interface ipv4 add dns "Local Area Connection" ' & _GUICtrlIpAddress_Get($DNS2) & ' index=2', "", @SW_HIDE) ;setting of Dns 2 address
Run(@ComSpec & " /c " & 'wmic computersystem where name="%COMPUTERNAME%" call rename name="' & GUICtrlRead($ALOHABOH) & '"', "", @SW_HIDE)
MsgBox(64,"Terminal User Setup","The User Setup will start in 2 Seconds",0,0)
Sleep(2000)
Run(@ComSpec & " /c " & 'C:\Setup\TBMUserSetup.bat', "", @SW_SHOW)
Run(@ComSpec & " /c " & 'Powershell.exe C:\Setup\setwork.ps1', "", @SW_SHOW)
Run(@ComSpec & " /c " & 'C:\Setup\firewall_ports.bat > C:\Setup\Logs\Firewall.log', "", @SW_HIDE)
Run(@ComSpec & " /c " & 'wmic nicconfig where TcpipNetbiosOptions=0 call SetTcpipNetbios 2 > C:\Setup\Logs\Netbios.log', "", @SW_HIDE) ; Netbios
Run(@ComSpec & " /c " & 'powercfg -x -disk-timeout-ac 0', "", @SW_HIDE)
#Region ;Network Power Disable
if not ($key0 ="Microsoft") Then
    RegWrite($string &"\0000",$Value2,"REG_DWORD",24)
EndIf

if not ($key1 ="Microsoft") Then
    RegWrite($string &"\0001",$Value2,"REG_DWORD",24)
EndIf

if not ($key2 ="Microsoft") Then
    RegWrite($string &"\0002",$Value2,"REG_DWORD",24)
EndIf

if not ($key3 ="Microsoft") Then
    RegWrite($string &"\0003",$Value2,"REG_DWORD",24)
EndIf

if not ($key4 ="Microsoft") Then
    RegWrite($string &"\0004",$Value2,"REG_DWORD",24)
EndIf

if not ($key5 ="Microsoft") Then
    RegWrite($string &"\0005",$Value2,"REG_DWORD",24)
EndIf

if not ($key6 ="Microsoft") Then
    RegWrite($string &"\0006",$Value2,"REG_DWORD",24)
EndIf

if not ($key7 ="Microsoft") Then
    RegWrite($string &"\0007",$Value2,"REG_DWORD",24)
EndIf

if not ($key8 ="Microsoft") Then
    RegWrite($string &"\0008",$Value2,"REG_DWORD",24)
EndIf

if not ($key9 ="Microsoft") Then
    RegWrite($string &"\0009",$Value2,"REG_DWORD",24)
EndIf

if not ($key10 ="Microsoft") Then
    RegWrite($string &"\0010",$Value2,"REG_DWORD",24)
EndIf
if not ($key11 ="Microsoft") Then
    RegWrite($string &"\0011",$Value2,"REG_DWORD",24)
EndIf

if not ($key12 ="Microsoft") Then
    RegWrite($string &"\0012",$Value2,"REG_DWORD",24)
EndIf

if not ($key13 ="Microsoft") Then
    RegWrite($string &"\0013",$Value2,"REG_DWORD",24)
EndIf

if not ($key14 ="Microsoft") Then
    RegWrite($string &"\0014",$Value2,"REG_DWORD",24)
EndIf

if not ($key15 ="Microsoft") Then
    RegWrite($string &"\0015",$Value2,"REG_DWORD",24)
EndIf

if not ($key16 ="Microsoft") Then
    RegWrite($string &"\0016",$Value2,"REG_DWORD",24)
EndIf

if not ($key17 ="Microsoft") Then
    RegWrite($string &"\0017",$Value2,"REG_DWORD",24)
EndIf

if not ($key18 ="Microsoft") Then
    RegWrite($string &"\0018",$Value2,"REG_DWORD",24)
EndIf

if not ($key19 ="Microsoft") Then
    RegWrite($string &"\0019",$Value2,"REG_DWORD",24)
EndIf

if not ($key20 ="Microsoft") Then
    RegWrite($string &"\0020",$Value2,"REG_DWORD",24)
EndIf
#EndRegion
#Region ; Set Long File Date all users
If @OSArch = "X86" Then
Fileinstall("C:\work\Hospitallity\Script files\slongdate.exe","C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup\slongdate.exe")
ElseIf @OSArch = "X64" Then
Fileinstall("C:\work\Hospitallity\Script files\slongdate64.exe","C:\Users\All Users\Microsoft\Windows\Start Menu\Programs\Startup\slongdate64.exe")
EndIf
sleep(2500)
;Run(@ComSpec & " /c " & 'copy C:\slongdate.exe C:\Windows\System32\GroupPolicy\User\Scripts\Logon\slongdate.exe', "", @SW_HIDE)
;Sleep(2500)
;FileOpen("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini",$FO_OVERWRITE)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "[Logon]" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "0CmdLine=slongdate.exe" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", "0Parameters=" & @CRLF)
;FileWriteLine("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini", @CRLF)
;FileClose("C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini")
#EndRegion
MsgBox(64,"Checklist","The Checklist has been run",0,0)
Sleep(7000)
ProcessWaitClose("cmd.exe")
FileDelete("C:\Setup\TBMUserSetup.bat")
FileDelete("C:\Setup\firewall_ports.bat")
FileDelete("C:\Setup\setwork.ps1")
Shutdown(6)
Exit
    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I couldn't find a combo in your script and as you see in my script, i get time in 24 h format and the array is in 12 h format. The little changed skript: 

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <Array.au3>

Global $iHour, $iWeekday
Global $aWeekdays[8] = [7, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
;a 1 based array row 0 = count of real elements
Global $aHours[24]  ;a 0 based array all rows are used from elements
_initHours()
$Form1 = GUICreate("Test", 555, 473, 205, 146)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Windows Updates", 8, 376, 289, 65)
$Combo1 = GUICtrlCreateCombo("", 24, 400, 97, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Combo2 = GUICtrlCreateCombo("", 184, 400, 105, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Convert= GUICtrlCreateButton('&OK',450,400,55, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
_SetDay()
_setHour()
GUISetState(@SW_SHOW)

While 1
    $nmsp = GUIGetMsg()
    Switch $nmsp
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Combo1
            $select = GUICtrlRead($Combo1)
            $iWeekday=_ArraySearch($aWeekdays,$select)
        Case $Combo2
            $select = GUICtrlRead($Combo2)
            $iHour =_ArraySearch($aHours,$select)
        Case $Convert
            RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallDay","REG_DWORD",$iWeekday)
            RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\","ScheduledInstallTime","REG_DWORD",$iHour)             
    EndSwitch
WEnd

Func _initHours()
    For $i=0 to 12
        $aHours[$i]=$i&':00 am'
    Next
    For $i=13 to 23
        $aHours[$i]=$i&':00 pm'
    Next
EndFunc

Func _SetDay()
    Local $iWeekday = _DateToDayOfWeek(@YEAR, @MON, @MDAY)
    For $i = 1 To 7
        If $i = $iWeekday Then
            GUICtrlSetData($Combo1, $aWeekdays[$i], $aWeekdays[$i])
        Else
            GUICtrlSetData($Combo1, $aWeekdays[$i])
        EndIf
    Next
EndFunc   ;==>_SetDay

Func _setHour()
    For $i=0 To 23
        If $i=@HOUR Then
            GUICtrlSetData($Combo2, $aHours[$i], $aHours[$i])
        Else
            GUICtrlSetData($Combo2, $aHours[$i])
        EndIf
    Next
    $iHour=@HOUR
EndFunc

 

Edited by AutoBert
deliting 2. script

Share this post


Link to post
Share on other sites

Thank You I got it working with autobert's sugesstion but thanks again to everyone

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now