Necromorph Posted October 15, 2010 Share Posted October 15, 2010 i like feed back! expandcollapse popup#include<GUIConstants.au3> #include<EditConstants.au3> #include<StaticConstants.au3> #include<WindowsConstants.au3> If @OSArch = "X86" Then $dlPackage = "http://go.microsoft.com/?linkid=9729746" $HKLM = "HKLM" Else $dlPackage = "http://go.microsoft.com/?linkid=9729747" $HKLM = "HKLM64" EndIf $guiTile = "redLabel® sqlInstaller" $guiIcon = @ScriptDir & "\Needed Assemblies\database.ico" ;EVENTS $msgboxInstallWarning = MsgBox(36, $guiTile, "This application will download, install, and configure SQL Express 2008 R2 with Advanced Services without any user intervention. Are you sure you wish to continue?") If $msgboxInstallWarning = 7 Then Exit Else _SQLRequirements() $sqlinstance = _SQLInstance() _SQLDownload() _SQLInstall() Exit EndIf ;FUNCTIONS Func _SQLRequirements() $guiSQLRequirements = GUICreate($guiTile, 325, 200) GUISetIcon($guiIcon) GUISetState() GUICtrlCreateLabel("Checking for Microsoft® Windows® Installer Version.", 25, 25) GUICtrlCreateLabel("Checking for Microsoft® Windows® PowerShell Version.", 25, 75) GUICtrlCreateLabel("Checking for Microsoft® Windows® .NET Version 3.5.", 25, 125) $buttonInstallerLinks = GUICtrlCreateButton("Installer links", 25, 165, 75) GUICtrlSetState(-1, $gui_disable) $buttonCancel = GUICtrlCreateButton("Cancel", 150, 165, 75) GUICtrlSetState(-1, $gui_disable) $buttonAccept = GUICtrlCreateButton("OK", 225, 165, 75) GUICtrlSetState(-1, $gui_disable) Sleep(1000) $msiVersion = FileGetVersion(@SystemDir & "\msi.dll") If $msiVersion >= 4.5 Then GUICtrlCreateLabel("Current version: " & $msiVersion, 25, 40) GUICtrlCreateLabel("PASSED!", 250, 40) Else GUICtrlCreateLabel("Current version: " & $msiVersion, 25, 40) GUICtrlCreateLabel("FAILED!", 250, 40) EndIf Sleep(1000) $powershellVersion = RegRead($HKLM & "\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine", "PowerShellVersion") If @error <> 0 Or $powershellVersion < 2.0 Then GUICtrlCreateLabel("Current version: " & $powershellVersion, 25, 90) GUICtrlCreateLabel("FAILED!", 250, 90) Else GUICtrlCreateLabel("Current version: " & $powershellVersion, 25, 90) GUICtrlCreateLabel("PASSED!", 250, 90) EndIf Sleep(1000) $netframeworkVersion = RegRead($HKLM & "\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5", "Version") If @error <> 0 Then GUICtrlCreateLabel("FAILED!", 250, 140) Else GUICtrlCreateLabel("Current version: " & $netframeworkVersion, 25, 140) GUICtrlCreateLabel("PASSED!", 250, 140) EndIf Sleep(1000) GUICtrlSetState($buttonCancel, $gui_enable) If $msiVersion >= 4.5 And $powershellVersion >= 2.0 And $netframeworkVersion >= 3.5 Then GUICtrlSetState($buttonAccept, $gui_enable) GUICtrlSetState($buttonAccept, $gui_defbutton) Else GUICtrlSetState($buttonInstallerLinks, $gui_enable) GUICtrlSetState($buttonInstallerLinks, $gui_defbutton) MsgBox(48, $guiTile, "Some SQL Requirement(s) checks failed, please use the 'Downloads' button for links to required components that must be installed first to continue with this installation.") EndIf While 1 $msg = GUIGetMsg() Switch $msg Case $gui_event_close, $buttonCancel Exit Case $buttonInstallerLinks $guiDownloads = GUICreate($guiTile, 325, 150) GUISetIcon($guiIcon) GUISetState() GUICtrlCreateLabel("Download Links:", 25, 25) $downloadInstaller = GUICtrlCreateLabel("Microsoft® Windows® Installer v4.5", 25, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetFont(-1, 8.5, 400, 4) GUICtrlSetCursor(-1, 0) $downloadPowerShell = GUICtrlCreateLabel("Microsoft® Windows® PowerShell v2.0", 25, 65) GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetFont(-1, 8.5, 400, 4) GUICtrlSetCursor(-1, 0) $downloadNetFramework = GUICtrlCreateLabel("Microsoft® Windows® .Net Framework v3.5", 25, 80) GUICtrlSetColor(-1, 0x0000FF) GUICtrlSetFont(-1, 8.5, 400, 4) GUICtrlSetCursor(-1, 0) $buttonDone = GUICtrlCreateButton("Done", 225, 100, 75) While 1 $msg = GUIGetMsg() Switch $msg Case $gui_event_close, $buttonDone GUIDelete($guiDownloads) ExitLoop Case $downloadInstaller ShellExecute("http://www.microsoft.com/downloads/en/details.aspx?FamilyID=5a58b56f-60b6-4412-95b9-54d056d6f9f4&displaylang=en") Case $downloadPowerShell ShellExecute("http://support.microsoft.com/kb/968929") Case $downloadNetFramework ShellExecute("http://www.microsoft.com/downloads/en/details.aspx?FamilyId=333325fd-ae52-4e35-b531-508d977d32a6&displaylang=en") EndSwitch WEnd Case $buttonAccept GUIDelete() ExitLoop EndSwitch WEnd EndFunc Func _SQLInstance() $guiSQLInstance = GUICreate($guiTile, 300, 150) GUISetIcon($guiIcon) GUISetState() GUICtrlCreateLabel("Instance Name: ", 25 ,25) $inputInstaceName = GUICtrlCreateInput("MSSQLSERVER", 25, 50, 250) $buttonAccept = GUICtrlCreateButton("OK", 200, 100, 75) GUICtrlSetState($buttonAccept, $gui_defbutton) While 1 $msg = GUIGetMsg() Switch $msg Case $buttonAccept $instanceName = GUICtrlRead($inputInstaceName) $x = 0 Do $x += 1 $instances = RegEnumVal($HKLM & "\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL", $x) Until @error <> 0 Or $instances = $instanceName If $instanceName = $instances Then If @OSArch = "X86" Then $msgboxX86DL = MsgBox(52, "redLabel® SQL Installer", "SQL Server Setup cannot continue." & @CRLF & @CRLF & "An instance named '" & $instanceName & "' already exists on this system." & @CRLF & "Please install manually or use the pre-existing instance of SQL." & @CRLF & @CRLF & "Would you like to download the SQL Install Package?") If $msgboxX86DL = 6 Then ShellExecute("http://go.microsoft.com/?linkid=9729746") Else MsgBox(0, "redLabel® SQL Installer", "The installer will now close.", 2) Exit EndIf Else $msgboxX64DL = MsgBox(52, "redLabel® SQL Installer", "SQL Server Setup cannot continue." & @CRLF & @CRLF & "An instance named '" & $instanceName & "' already exists on this system." & @CRLF & "Please install manually or use the pre-existing instance of SQL." & @CRLF & @CRLF & "Would you like to download the SQL Install Package?") If $msgboxX64DL = 6 Then ShellExecute("http://go.microsoft.com/?linkid=9729747") Else MsgBox(0, "redLabel® SQL Installer", "The installer will now close.", 2) Exit EndIf EndIf Else GUIDelete() ExitLoop EndIf EndSwitch WEnd Return $instanceName EndFunc Func _SQLDownload() $download = InetGet($dlPackage, @TempDir & "\SQL2008Installer.exe", 16, 1) $guiDownload = GUICreate($guiTile, 300, 175) GUISetIcon($guiIcon) GUISetState() GUICtrlCreateLabel("Please wait, the SQL installer is being downloaded...", 25, 25) $progressDownload = GUICtrlCreateProgress(25, 75, 250) GUICtrlCreateLabel("Downloaded: ", 25, 100) GUICtrlCreateLabel("(This could take several minutes to complete.)", 25, 125) $totalSize = InetGetSize($dlPackage) Sleep(2500) WinSetTitle($guiDownload, '', '') Sleep(1000) Do $currentSize = InetGetInfo($download, 0) $sizetoset = StringLeft($currentSize / $totalSize, 4) * 100 GUICtrlSetData($progressDownload, $sizetoset) WinSetTitle($guiDownload, '', $sizetoset & "% " & " Downloaded") GUICtrlCreateLabel($currentSize & " / " & $totalSize & " Bytes", 90, 100) Sleep(1000) Until InetGetInfo($download, 2) InetClose($download) GUIDelete($guiDownload) MsgBox(0, '', "the download is complete", 2.5) EndFunc Func _SQLInstall() ShellExecuteWait(@TempDir & '\SQL2008Installer.exe', ' /QS /ACTION=Install /FEATURES=SQLEngine,FullText,Tools /INSTANCENAME=' & $sqlinstance & ' /SQLSVCACCOUNT="NT AUTHORITY\NETWORK SERVICE" /AGTSVCACCOUNT="NT AUTHORITY\Network Service" /ADDCURRENTUSERASSQLADMIN /IACCEPTSQLSERVERLICENSETERMS') MsgBox(0, "redLabel® SQL Installer", "SQL Express 2008 installed sucsessfully") $msgboxDeleteInstaller = MsgBox(36, "redLabel® SQL Installer", "Would you like to delete the SQL installation package?") If $msgboxDeleteInstaller = 6 Then FileDelete(@TempDir & "\SQL2008Installer.exe") Else Exit EndIf EndFunc Link to comment Share on other sites More sharing options...
wraithdu Posted October 15, 2010 Share Posted October 15, 2010 But not describing your own work apparently... Link to comment Share on other sites More sharing options...
Necromorph Posted October 15, 2010 Author Share Posted October 15, 2010 true... sorry well, it goes like this first it determins the os archetecture to decide if it needs to download x64 or x86, then scans required pre reqs for sql 2008, if it fails, provids download links to the files needed to install, or if it passes, allows you to specify and instance name. if that instance name is unique, it will continue to download sql, then run command switches to install sql, then, once finished, prompt to delete the sql installer from the @TempDir. it works well, just supply the $guiIcon variable for what ever you want (or it may fail to build, im not sure) then try it out. there are some other features as well, if you try to install the same instance twice, it wont let you, but will offer to take you to the sql download page, so you can download the installer and do it manually. stuff like that. Link to comment Share on other sites More sharing options...
cbertram68 Posted June 5, 2014 Share Posted June 5, 2014 Necromorph, I am trying to update this script to install SQL Express 2012 SP1. MS did some changes to the files, so if you are installing the 64 bit the file name is different that the 32 bit, they also give you several different files to run now, two MSI's, two EXE's. So far my i have updated the URL's that are used for the download, I found a couple of errors in the code, they are in the URL sections, the " was in the wrong place. It appears that it is trying to download the files for a few seconds, but it is not successful, it fails to install, the failure is not caught as a failure, sot eh script ends saying it was successful. I would love to help update this script, and post it, but I am just a level above Novice, and two levels below intermediate. Any help on updating this would be greatly appreciated. Link to comment Share on other sites More sharing options...
cbertram68 Posted June 6, 2014 Share Posted June 6, 2014 So far I have soved the problem in this way. You had this line in your variable for the download: If @OSArch = "X86" Then $dlPackage = "<a href='http://go.microsoft.com/?linkid=9729746' class='bbc_url' title='External link' rel='nofollow external'>http://go.microsoft.com/?linkid=9729746"</a> $HKLM = "HKLM" Else $dlPackage = "<a href='http://go.microsoft.com/?linkid=9729747' class='bbc_url' title='External link' rel='nofollow external'>http://go.microsoft.com/?linkid=9729747"</a> $HKLM = "HKLM64" EndIf I have replaced that with this: If @OSArch = "X86" Then $dlPackage = "http://download.microsoft.com/download/5/2/9/529FEF7B-2EFB-439E-A2D1-A1533227CD69/SQLEXPR_x86_ENU.exe" $HKLM = "HKLM" Else $dlPackage = "http://download.microsoft.com/download/5/2/9/529FEF7B-2EFB-439E-A2D1-A1533227CD69/SQLEXPR_x64_ENU.exe" $HKLM = "HKLM64" EndIf By making this change it now downloads the 2012 sp1 version of SQLExpress, and seems to download 100%, I will post again after it completes to let you know if the rest of the code worked. BTW, I am not sure your original code would have competed successfully, all InetGet wants is a URL, all the extrenaious info about Href etc was what was causing it to fail for me as I was working on this. I have not tested one other thing, which is I did an include of InetConstants.au3 in the help file it seems that they were needed. I will post the completed and updated code once I know it works. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now