#include #include #include #include #include #include #include ;Read ini file variables Local $rAppName="Application Store",$rClientLog="C:\Temp\",$rCompany = "Company Name" ,$rDatabase1="AppStore",$rDatabase2="AppStoreLogs",$rDomain,$rDomainFQDN Local $rGroups,$rGroupsOU,$rInstallPassword,$rInstallUser,$rLocalInstallPassword,$rLocalInstallUser,$rLogo,$rPassword1,$rPassword2 Local $rProvider1="SQLOLEDB",$rProvider2="SQLOLEDB",$rServer1,$rServer2,$rTable1="Applications",$rTable2="AppStoreLogs",$rUser1,$rUser2,$rUsers ;Start GUI #Region ### START Koda GUI section ### Form= $formMain = GUICreate("Application Store - Configuration", 625, 446, 189, 124) $tabPages = GUICtrlCreateTab(8, 8, 601, 401) $TabSheet1 = GUICtrlCreateTabItem("Administrators") $inUser = GUICtrlCreateInput("", 140, 42, 449, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Users listed here will have full Admin rights to the Application Store. Separate the usernames with a comma.") $inGroups = GUICtrlCreateInput("", 140, 81, 449, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Groups listed here will have full Admin rights to the Application Store. Separate the group names with a comma.") $inInstallUser = GUICtrlCreateInput("", 140, 121, 449, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "This is a domain user that has local admin rights on the system installing an application.") $inInstallPassword = GUICtrlCreateInput("", 140, 161, 369, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $btnEncrypt3 = GUICtrlCreateButton("&Encrypt", 515, 158, 73, 25) $inLocalUser = GUICtrlCreateInput("", 140, 201, 449, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "This will be the name of a temporary account used to install an application. Some applications will be required to install as the user themselves and therefore will prompt the user for credentials if using a system with UAC. This account is created for the installation of an application, and then automatically removed. The user will be provided with the temporary admin username upon installation.") $inLocalInstallPassword = GUICtrlCreateInput("", 140, 241, 449, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "This is a random password for the Local Install account. 6 random digits will follow the characters listed here. The password will always be different.") $lblUsers = GUICtrlCreateLabel("Users", 20, 45, 31, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblGroups = GUICtrlCreateLabel("Groups", 20, 85, 38, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblInstallUser = GUICtrlCreateLabel("Install User", 20, 125, 56, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblInstallPassword = GUICtrlCreateLabel("Install Password", 20, 165, 80, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblLocalInstallUser = GUICtrlCreateLabel("Local Install User", 20, 205, 85, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblLocalInstallPassword = GUICtrlCreateLabel("Local Install Password", 20, 245, 109, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $TabSheet2 = GUICtrlCreateTabItem("System") $lblAppName = GUICtrlCreateLabel("App Name", 20, 47, 54, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblLogo = GUICtrlCreateLabel("Logo", 20, 87, 28, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblCompany = GUICtrlCreateLabel("Company", 20, 127, 48, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblDomain = GUICtrlCreateLabel("Domain", 20, 167, 40, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblClientLog = GUICtrlCreateLabel("Client Log", 20, 207, 51, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblGroupsOU = GUICtrlCreateLabel("Groups OU", 20, 247, 57, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $lblDomainFQDN = GUICtrlCreateLabel("Domain FQDN", 20, 287, 73, 17) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetBkColor(-1, 0xFFFFFF) $inAppName = GUICtrlCreateInput("", 124, 45, 465, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Here you can name the Application Store with your own branding.") $inLogo = GUICtrlCreateInput("", 124, 85, 361, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Select a logo to appear upon the launch of the Application Store. The resolution of the image should not be larger than 620x290.") $inCompany = GUICtrlCreateInput("", 124, 125, 465, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "You may list the App Store as your company here.") $inDomain = GUICtrlCreateInput("", 124, 165, 465, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Enter the domain name of your Active Directory server. e.g. northwinds.com") $inClientLog = GUICtrlCreateInput("", 124, 205, 361, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "The location specified here will save a log on the users machine explaining the process of the installation.") $inGroupsOU = GUICtrlCreateInput("", 124, 245, 465, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Enter the FQDN of where your Security Groups are stored in Active Directory. e.g. OU=Groups,DC=northwinds,DC=com") $inDomainFQDN = GUICtrlCreateInput("", 124, 285, 465, 22) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "Enter the Fully Qualified Domain Name of your Active Directory network. e.g. DC=northwinds,DC=com") $btnBrowseLogo = GUICtrlCreateButton("Browse", 516, 85, 75, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $btnBrowseLog = GUICtrlCreateButton("Browse", 516, 205, 75, 25) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $TabSheet3 = GUICtrlCreateTabItem("Database") GUICtrlSetState(-1,$GUI_SHOW) $grpDatabase = GUICtrlCreateGroup("Database", 20, 37, 569, 177) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $lblProvider1 = GUICtrlCreateLabel("Provider", 48, 65, 43, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblServer1 = GUICtrlCreateLabel("Server", 48, 89, 35, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblDatabase1 = GUICtrlCreateLabel("Database", 48, 113, 50, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblUser1 = GUICtrlCreateLabel("User", 48, 137, 26, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblPassword1 = GUICtrlCreateLabel("Password", 48, 161, 50, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblTable1 = GUICtrlCreateLabel("Table", 48, 185, 31, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $inProvider1 = GUICtrlCreateInput("", 124, 61, 449, 22) GUICtrlSetTip(-1, "Specify the SQL provider here for your Database. The default is already specified.") $inServer1 = GUICtrlCreateInput("", 124, 85, 449, 22) GUICtrlSetTip(-1, "Enter the server name where the database of your Application Store is being hosted.") $inDatabase1 = GUICtrlCreateInput("", 124, 109, 449, 22) GUICtrlSetTip(-1, "Enter the name of your Application Store Database") $inUser1 = GUICtrlCreateInput("", 124, 133, 449, 22) GUICtrlSetTip(-1, "Enter a user account that has admin rights to the Database.") $inPassword1 = GUICtrlCreateInput("", 124, 157, 369, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $btnEncrypt1 = GUICtrlCreateButton("&Encrypt", 497, 156, 75, 25) $inTable1 = GUICtrlCreateInput("", 124, 181, 449, 22) GUICtrlSetTip(-1, "Enter the name of the table being used to store the software that is available in the Application Store.") GUICtrlCreateGroup("", -99, -99, 1, 1) $grpDatabaseLogs = GUICtrlCreateGroup("Database Logs", 20, 221, 569, 177) GUICtrlSetFont(-1, 8, 400, 0, "Arial") $lblProvider2 = GUICtrlCreateLabel("Provider", 48, 247, 43, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblServer2 = GUICtrlCreateLabel("Server", 48, 271, 35, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblDatabase2 = GUICtrlCreateLabel("Database", 48, 295, 50, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblUser2 = GUICtrlCreateLabel("User", 48, 319, 26, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblPassword2 = GUICtrlCreateLabel("Password", 48, 343, 50, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $lblTable2 = GUICtrlCreateLabel("Table", 48, 367, 31, 17) GUICtrlSetBkColor(-1, 0xFFFFFF) $inProvider2 = GUICtrlCreateInput("", 124, 245, 449, 22) GUICtrlSetTip(-1, "Specify the SQL provider here for your Database. The default is already specified.") $inServer2 = GUICtrlCreateInput("", 124, 269, 449, 22) GUICtrlSetTip(-1, "Enter the server name where the database of your Application Store is being hosted.") $inDatabase2 = GUICtrlCreateInput("", 124, 293, 449, 22) GUICtrlSetTip(-1, "Enter the name of your Application Store Database") $inUser2 = GUICtrlCreateInput("", 124, 317, 449, 22) GUICtrlSetTip(-1, "Enter a user account that has admin rights to the Database.") $inPassword2 = GUICtrlCreateInput("", 124, 341, 369, 22, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD)) $btnEncrypt2 = GUICtrlCreateButton("&Encrypt", 497, 340, 75, 25) $inTable2 = GUICtrlCreateInput("", 124, 365, 449, 22) GUICtrlSetTip(-1, "Enter the name of the table being used to store the software installation logs to document when an application is installed in the Application Store.") GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateTabItem("") $btnExit = GUICtrlCreateButton("Exit", 530, 413, 75, 25) $btnSave = GUICtrlCreateButton("Save", 445, 413, 75, 25) $btnCreate = GUICtrlCreateButton("Create", 360, 413, 75, 25) GUICtrlSetState($TabSheet1, $GUI_SHOW) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### ;********** Check for Existing config.ini file and load the form with the data if it does exist. If FileExists(@ScriptDir & "\config.ini") Then $fOpen = FileOpen(@ScriptDir & "\config.ini",10) ;________________________________________________________________________________________________________ $rUsers = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","Users","") $rGroups = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","Groups","") $rInstallUser = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","InstallUser","") $rInstallPassword = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","InstallPassword","") $rLocalInstallUser = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","LocalInstallUser","") $rLocalInstallPassword = IniRead(@ScriptDir & "\config.ini","ADMINISTRATORS","LocalInstallPassword","") ;________________________________________________________________________________________________________ $rAppName = IniRead(@ScriptDir & "\config.ini","SYSTEM","AppName","") $rLogo = IniRead(@ScriptDir & "\config.ini","SYSTEM","Logo","") $rCompany = IniRead(@ScriptDir & "\config.ini","SYSTEM","Company","") $rDomain = IniRead(@ScriptDir & "\config.ini","SYSTEM","Domain","") $rClientLog = IniRead(@ScriptDir & "\config.ini","SYSTEM","ClientLog","") $rGroupsOU = IniRead(@ScriptDir & "\config.ini","SYSTEM","GroupsOU","") $rDomainFQDN = IniRead(@ScriptDir & "\config.ini","SYSTEM","DomainFQDN","") ;________________________________________________________________________________________________________ $rProvider1 = IniRead(@ScriptDir & "\config.ini","DATABASE","Provider","") $rServer1 = IniRead(@ScriptDir & "\config.ini","DATABASE","Server","") $rDatabase1 = IniRead(@ScriptDir & "\config.ini","DATABASE","Database","") $rUser1 = IniRead(@ScriptDir & "\config.ini","DATABASE","User","") $rPassword1 = IniRead(@ScriptDir & "\config.ini","DATABASE","Password","") $rTable1 = IniRead(@ScriptDir & "\config.ini","DATABASE","Table","") ;________________________________________________________________________________________________________ $rProvider2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","Provider","") $rServer2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","Server","") $rDatabase2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","Database","") $rUser2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","User","") $rPassword2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","Password","") $rTable2 = IniRead(@ScriptDir & "\config.ini","DATABASELOGS","Table","") Else $fOpen = FileOpen(@ScriptDir & "\config.ini",10) EndIf ;Set Data in Config GUI GUICtrlSetData($inUser,$rUsers) GUICtrlSetData($inGroups,$rGroups) GUICtrlSetData($inInstallUser,$rInstallUser) GUICtrlSetData($inInstallPassword,$rInstallPassword) GUICtrlSetData($inLocalUser,$rLocalInstallUser) GUICtrlSetData($inLocalInstallPassword,$rLocalInstallPassword) ;________________________________________________________________________________________________________ GUICtrlSetData($inAppName,$rAppName) GUICtrlSetData($inLogo,$rLogo) GUICtrlSetData($inCompany,$rCompany) GUICtrlSetData($inDomain,$rDomain) GUICtrlSetData($inClientLog,$rClientLog) GUICtrlSetData($inGroupsOU,$rGroupsOU) GUICtrlSetData($inDomainFQDN,$rDomainFQDN) ;________________________________________________________________________________________________________ GUICtrlSetData($inProvider1,$rProvider1) GUICtrlSetData($inServer1,$rServer1) GUICtrlSetData($inDatabase1,$rDatabase1) GUICtrlSetData($inUser1,$rUser1) GUICtrlSetData($inPassword1,$rPassword1) GUICtrlSetData($inTable1,$rTable1) ;________________________________________________________________________________________________________ GUICtrlSetData($inProvider2,$rProvider2) GUICtrlSetData($inServer2,$rServer2) GUICtrlSetData($inDatabase2,$rDatabase2) GUICtrlSetData($inUser2,$rUser2) GUICtrlSetData($inPassword2,$rPassword2) GUICtrlSetData($inTable2,$rTable2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=None If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(260,"Exit","Exiting out of the configuration tool will discard any changes made that have not been saved. Are you sure you would like to exit now?") Select Case $iMsgBoxAnswer = 6 ;Yes FileClose($fOpen) Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code End --- Case $btnExit #Region --- CodeWizard generated code Start --- ;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes and No, Default Button=Second, Icon=None If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(260,"Exit","Exiting out of the configuration tool will discard any changes made that have not been saved. Are you sure you would like to exit now?") Select Case $iMsgBoxAnswer = 6 ;Yes FileClose($fOpen) Exit Case $iMsgBoxAnswer = 7 ;No EndSelect #EndRegion --- CodeWizard generated code End --- Case $btnBrowseLog $rClientLog = FileSelectFolder("Select Log Directory","C:\") GUICtrlSetData($inClientLog,$rClientLog & "\asLog.txt") Case $btnBrowseLogo $rLogo = FileOpenDialog("Select a Logo","C:\","jpg(*.jpg)") GUICtrlSetData($inLogo,$rLogo) Case $btnSave $rUsers = GUICtrlRead($inUser) $rGroups = GUICtrlRead($inGroups) $rInstallUser = GUICtrlRead($inInstallUser) $rInstallPassword = GUICtrlRead($inInstallPassword) $rLocalInstallUser = GUICtrlRead($inLocalUser) $rLocalInstallPassword = GUICtrlRead($inLocalInstallPassword) ;________________________________________________________________________________________________________ $rAppName = GUICtrlRead($inAppName) $rLogo = GUICtrlRead($inLogo) $rCompany = GUICtrlRead($inCompany) $rDomain = GUICtrlRead($inDomain) $rClientLog = GUICtrlRead($inClientLog) $rGroupsOU = GUICtrlRead($inGroupsOU) $rDomainFQDN = GUICtrlRead($inDomainFQDN) ;________________________________________________________________________________________________________ $rProvider1 = GUICtrlRead($inProvider1) $rServer1 = GUICtrlRead($inServer1) $rDatabase1 = GUICtrlRead($inDatabase1) $rUser1 = GUICtrlRead($inUser1) $rPassword1 = GUICtrlRead($inPassword1) $rTable1 = GUICtrlRead($inTable1) ;________________________________________________________________________________________________________ $rProvider2 = GUICtrlRead($inProvider2) $rServer2 = GUICtrlRead($inServer2) $rDatabase2 = GUICtrlRead($inDatabase2) $rUser2 = GUICtrlRead($inUser2) $rPassword2 = GUICtrlRead($inPassword2) $rTable2 = GUICtrlRead($inTable2) ;________________________________________________________________________________________________________ IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","Users",$rUsers) IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","Groups",$rGroups) IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","InstallUser",$rInstallUser) IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","InstallPassword",$rInstallPassword) IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","LocalInstallUser",$rLocalInstallUser) IniWrite(@ScriptDir & "\config.ini","ADMINISTRATORS","LocalInstallPassword",$rLocalInstallPassword) ;________________________________________________________________________________________________________ IniWrite(@ScriptDir & "\config.ini","SYSTEM","AppName",$rAppName) IniWrite(@ScriptDir & "\config.ini","SYSTEM","Logo",$rLogo) IniWrite(@ScriptDir & "\config.ini","SYSTEM","Company",$rCompany) IniWrite(@ScriptDir & "\config.ini","SYSTEM","Domain",$rDomain) IniWrite(@ScriptDir & "\config.ini","SYSTEM","ClientLog",$rClientLog) IniWrite(@ScriptDir & "\config.ini","SYSTEM","GroupsOU",$rGroupsOU) IniWrite(@ScriptDir & "\config.ini","SYSTEM","DomainFQDN",$rDomainFQDN) ;________________________________________________________________________________________________________ IniWrite(@ScriptDir & "\config.ini","DATABASE","Provider",$rProvider1) IniWrite(@ScriptDir & "\config.ini","DATABASE","Server",$rServer1) IniWrite(@ScriptDir & "\config.ini","DATABASE","Database",$rDatabase1) IniWrite(@ScriptDir & "\config.ini","DATABASE","User",$rUser1) IniWrite(@ScriptDir & "\config.ini","DATABASE","Password",$rPassword1) IniWrite(@ScriptDir & "\config.ini","DATABASE","Table",$rTable1) ;________________________________________________________________________________________________________ IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","Provider",$rProvider2) IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","Server",$rServer2) IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","Database",$rDatabase2) IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","User",$rUser2) IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","Password",$rPassword2) IniWrite(@ScriptDir & "\config.ini","DATABASELOGS","Table",$rTable2) MsgBox(0,"Saved","The configuration has been saved.") Case $btnEncrypt1 $rPassword1 = GUICtrlRead($inPassword1) _Crypt_Startup() $rPassword1 = _Encrypt("password", $rPassword1) _Crypt_Shutdown() GUICtrlSetData($inPassword1,$rPassword1) Case $btnEncrypt2 $rPassword2 = GUICtrlRead($inPassword2) _Crypt_Startup() $rPassword2 = _Encrypt("password", $rPassword2) _Crypt_Shutdown() GUICtrlSetData($inPassword2,$rPassword2) Case $btnEncrypt3 $rInstallPassword = GUICtrlRead($inInstallPassword) _Crypt_Startup() $rInstallPassword = _Encrypt("password", $rInstallPassword) _Crypt_Shutdown() GUICtrlSetData($inInstallPassword,$rInstallPassword) EndSwitch WEnd Func _Decrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $sDecrypted = BinaryToString(_Crypt_DecryptData(Binary($sData), $hKey, $CALG_USERKEY)) _Crypt_DestroyKey($hKey) Return $sDecrypted EndFunc Func _Encrypt($sKey, $sData) Local $hKey = _Crypt_DeriveKey($sKey, $CALG_AES_256) Local $bEncrypted = _Crypt_EncryptData($sData, $hKey, $CALG_USERKEY) _Crypt_DestroyKey($hKey) Return $bEncrypted EndFunc