; Script For Services. !include nsDialogs.nsh !include LogicLib.nsh !include ValidateIP.nsh ; RequestExecutionLevel REQUIRED! RequestExecutionLevel admin ; defines For Product Info ;!define PRODUCT_NAME "" !define PRODUCT_VERSION "2.0.2" ;!define PRODUCT_PUBLISHER "" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" ; MUI 1.67 compatible ------ !include "MUI2.nsh" ; MUI Settings !define MUI_ABORTWARNING ; Welcome page !insertmacro MUI_PAGE_WELCOME ; Custom Pages page custom domtype domtypeLeave page custom nsDialogsPage clearnow page custom nsDialogsverify ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page ;!insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "ServiceInstallerSetup.exe" InstallDir "$PROGRAMFILES\AtlantisUnity" ShowInstDetails show ShowUnInstDetails show ;SetCompress off ;------------------------------------------------ ; Global Variables ;------------------------------------------------- ;XPStyle on Var Label_unin Var Label_input Var Dialog Var Dialog2 Var Dialog_dom Var button Var button_ad Var button_samba Var Label_dom Var Label_ccip Var Label_winsip Var Label_domadmin Var Label_dompass Var Label_dompass2 Var Label_ou Var Text_dom Var /GLOBAL Text_ccip Var Text_ccip_State Var Text_winsip Var Text_domadmin Var Text_dompass Var Text_dompass2 Var Text_ou Var UNITYOU Var CCIP Var UNITYDOMAIN Var WINSIP Var DOMADMIN Var DOMPASS Var DOMPASS2 Var drive Var path Var length Var domcheck Var ccipcheck Var winsipcheck Var tempdom Var regvar Var clnow ;------------------------------------------------------------------------------- ; Does a case sensitive searches for an occurrence of a substring in a string. ; It returns the substring if it is found; otherwise, it returns null(""). ; Used here for checking Duplicate entries in the PATH variable. ;-------------------------------------------------------------------------------- Var STR_HAYSTACK Var STR_NEEDLE Var STR_CONTAINS_VAR_1 Var STR_CONTAINS_VAR_2 Var STR_CONTAINS_VAR_3 Var STR_CONTAINS_VAR_4 Var STR_RETURN_VAR !macro StrContains UN Function ${UN}StrContains Exch $STR_NEEDLE Exch Exch $STR_HAYSTACK ; Uncomment to debug ; MessageBox MB_OK 'STR_NEEDLE = $STR_NEEDLE STR_HAYSTACK = $STR_HAYSTACK ' StrCpy $STR_RETURN_VAR "" StrCpy $STR_CONTAINS_VAR_1 -1 StrLen $STR_CONTAINS_VAR_2 $STR_NEEDLE StrLen $STR_CONTAINS_VAR_4 $STR_HAYSTACK loop: IntOp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_1 + 1 StrCpy $STR_CONTAINS_VAR_3 $STR_HAYSTACK $STR_CONTAINS_VAR_2 $STR_CONTAINS_VAR_1 StrCmp $STR_CONTAINS_VAR_3 $STR_NEEDLE found StrCmp $STR_CONTAINS_VAR_1 $STR_CONTAINS_VAR_4 done Goto loop found: StrCpy $STR_RETURN_VAR $STR_NEEDLE Goto done done: Pop $STR_HAYSTACK ;Prevent "invalid opcode" errors and keep the stack intact Exch $STR_RETURN_VAR FunctionEnd !macroend !insertmacro StrContains "" ;!insertmacro StrContains "un." ;---------------------------------------------------------------------- ; Attempt to give the UAC plug-in a user process and an admin process. ;---------------------------------------------------------------------- Function .OnInit UAC_Elevate: UAC::RunElevated StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user? StrCmp 0 $0 0 UAC_Err ; Error? StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper? Quit UAC_Err: MessageBox mb_iconstop "Unable to elevate, error $0" Abort UAC_ElevationAborted: # elevation was aborted, run as normal? MessageBox mb_iconstop "This installer requires admin access, aborting!" Abort UAC_Success: StrCmp 1 $3 +4 ;Admin? StrCmp 3 $1 0 UAC_ElevationAborted ;Try again? MessageBox mb_iconstop "This installer requires admin access, try again" goto UAC_Elevate FunctionEnd Function domtype nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog_dom ${If} $Dialog_dom == error Abort ${EndIf} ${NSD_CreateRadioButton} 20 60 100% 12u "Samba Domain" Pop $button_samba SendMessage $button_samba ${BM_SETCHECK} ${BST_CHECKED} 0 ${NSD_CreateRadioButton} 20 90 100% 12u "Active Directory Domain" Pop $button_ad nsDialogs::Show /NOUNLOAD FunctionEnd ;------------------------------------------------ ; Page leve for domtype ;------------------------------------------------ Function domtypeLeave ${NSD_GetState} $button_samba $button ;MessageBox mb_iconstop "state is : $button " ; ${NSD_SetState} FunctionEnd ;----------------------------------------------------------------------------------------- ; Function to read data from custom page. i.e. ;---------------------------------------------------------------------------------------- Function nsDialogsPage nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog ${If} $Dialog == error Abort ${EndIf} ${NSD_CreateLabel} 0 0 100% 24u "Please Enter the Following Information :" Pop $Label_input CreateFont $1 "$(^Font)" "10" "700" SendMessage $Label_input ${WM_SETFONT} $1 0 SetCtlColors $Label_input FFFFFF "transparent" ShowWindow $Label_input ${SW_HIDE} ShowWindow $Label_input ${SW_SHOW} ${NSD_CreateLabel} 102 28u 60u 12u "ClusterControl IP:" Pop $Label_ccip ${NSD_CreateLabel} 144 42u 30u 12u "WINS IP:" Pop $Label_winsip ${NSD_CreateLabel} 120 56u 50u 12u "Domain name:" Pop $Label_dom ${If} $button == 0 ${NSD_CreateLabel} 51 70u 95u 12u "OU Admin (User Name only):" Pop $Label_domadmin ${Else} ${NSD_CreateLabel} 31 70u 108u 12u "Domain Admin (User Name only):" Pop $Label_domadmin ${EndIf} ${NSD_CreateLabel} 68 85u 80u 12u "Domain Admin Password:" Pop $Label_dompass ${NSD_CreateLabel} 62 100u 85u 12u "Re-enter Password Again:" Pop $Label_dompass2 ${If} $button == 0 ${NSD_CreateLabel} 139 114u 35u 12u "OU Name:" Pop $Label_ou ${EndIf} ;----Creating Textboxes +password boxes---- ${NSD_CreateText} 130u 26u 50% 12u $Text_ccip_State ; CC_IP Pop $Text_ccip GetFunctionAddress $0 OnChange nsDialogs::OnChange /NOUNLOAD $Text_ccip $0 ${NSD_CreateText} 130u 40u 50% 12u "" ; WINS_IP Pop $Text_winsip GetFunctionAddress $0 OnChange2 nsDialogs::OnChange /NOUNLOAD $Text_winsip $0 ${NSD_CreateText} 130u 54u 50% 12u "" ; DOM_NAME Pop $Text_dom GetFunctionAddress $0 OnChange3 nsDialogs::OnChange /NOUNLOAD $Text_dom $0 ${NSD_CreateText} 130u 68u 50% 12u "" ; DOM_ADMIN Pop $Text_domadmin GetFunctionAddress $0 OnChange4 nsDialogs::OnChange /NOUNLOAD $Text_domadmin $0 ${NSD_CreatePassword} 130u 82u 50% 12u "" ; DOM_PASS Pop $Text_dompass GetFunctionAddress $0 OnChange5 nsDialogs::OnChange /NOUNLOAD $Text_dompass $0 ${NSD_CreatePassword} 130u 96u 50% 12u "" ; DOM_PASS Pop $Text_dompass2 GetFunctionAddress $0 OnChange6 nsDialogs::OnChange /NOUNLOAD $Text_dompass2 $0 ${If} $button == 0 ${NSD_CreateText} 130u 110u 50% 12u "" ; DOM_ADMIN Pop $Text_ou GetFunctionAddress $0 OnChange7 nsDialogs::OnChange /NOUNLOAD $Text_ou $0 ${EndIf} nsDialogs::Show /NOUNLOAD FunctionEnd ;------------------------------------------------------------------- ; On change of value in the textbox jump to the following functions ;------------------------------------------------------------------- Function OnChange Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_ccip,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $CCIP $0 ;${NSD_SetText} $0 $0 FunctionEnd Function OnChange2 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_winsip,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $WINSIP $0 FunctionEnd Function OnChange3 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_dom,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $UNITYDOMAIN $0 FunctionEnd Function OnChange4 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_domadmin,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $DOMADMIN $0 FunctionEnd Function OnChange5 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_dompass,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $DOMPASS $0 FunctionEnd Function OnChange6 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_dompass2,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $DOMPASS2 $0 FunctionEnd Function OnChange7 Pop $0 ; HWND System::Call user32::GetWindowText(i$Text_ou,t.r0,i${NSIS_MAX_STRLEN}) Strcpy $UNITYOU $0 FunctionEnd Section DetailPrint "Welcome" SectionEnd ;--------------------------------------- ; Check If the User Is an Admin ;--------------------------------------- Section "IsAdminCheck" ; call userInfo plugin to get user info. The plugin puts the result in the stack userInfo::getAccountType ; pop the result from the stack into $0 pop $0 ; compare the result with the string "Admin" to see if the user is admin. If matches, jump 3 lines down. strCmp $0 "Admin" +3 ; if there is no match, print message and return messageBox MB_OK|MB_ICONEXCLAMATION "Only the 'Administrator' user is allowed to run the Service Installer; Please Relogin as Administrator to Proceed: $0" ;abort return SectionEnd ;------------------------------------------------ ; To Validate and Display user Entered Information ;----------------------------------------------- Function nsDialogsverify nsDialogs::Create /NOUNLOAD 1018 Pop $Dialog2 ${If} $Dialog2 == error Abort ${EndIf} ; For Next Button Disabling GetDlgItem $R9 $HWNDPARENT 1 ; In Case of Samba domain ${If} $button == 1 Strcpy $UNITYOU "" ${EndIf} ; Checking for hypens in the beginning of domain name StrCpy $tempdom $UNITYDOMAIN 1 ;${NSIS_MAX_STRLEN} 1 ${If} $tempdom == '-' goto disable ${EndIf} ; Validation of Domain Name ( > than 9 characters not allowed) Strlen $length $UNITYDOMAIN ${If} $length > 9 goto disable ${Else} Strcpy $domcheck 0 ${EndIf} ; Checking For Validity of Domain Name - can only contain chars on the following list Push "abcdefghijklmnopqrstuvwxyz1234567890-" Push $UNITYDOMAIN Call StrCSpnReverse Pop $R0 StrCmp $R0 "" +1 disable Strcpy $domcheck 0 ; ; if value is Null Disbale install button ${If} $UNITYDOMAIN == "" goto disable ${EndIf} ; Validation of Ip Push $CCIP Call ValidateIP ${If} ${Errors} goto disable ; if error goto disable :) ${NSD_CreateLabel} 0 20u 100% 30u "ERROR: Invalid IP address. Please return to the previous page to provide the correct information" ${Else} Strcpy $ccipcheck 0 ${NSD_CreateLabel} 0 15u 100% 12u "Verifying validity of IP address...OK" ${EndIf} ; CCIP_CHECK -if error go to label: disable ${If} $CCIP == "" goto disable ${ElseIf} $CCIP == "0.0.0.0" goto disable ${ElseIf} $CCIP == "255.255.255.255" goto disable ;if error disable ${EndIf} ; Validation of Ip Push $WINSIP Call ValidateIP ${If} ${Errors} goto disable ; if error goto disable :) ${NSD_CreateLabel} 0 20u 100% 30u "ERROR: Invalid IP address. Please return to the previous page to provide the correct information" ${Else} Strcpy $winsipcheck 0 ${NSD_CreateLabel} 0 15u 100% 12u "Verifying validity of IP address...OK" ${EndIf} ; WINSIP_CHECK -if error go to label: disable ${If} $WINSIP == "" goto disable ${ElseIf} $WINSIP == "0.0.0.0" goto disable ${ElseIf} $WINSIP == "255.255.255.255" goto disable ${EndIf} ${If} $DOMADMIN == "" goto disable ${ElseIf} $DOMPASS == "" goto disable ${EndIf} StrCmp $DOMPASS $DOMPASS2 +1 disable ; Page to Verify entered Information ${NSD_CreateLabel} 0 15u 100% 12u "Please confirm the details entered:" ${NSD_CreateLabel} 0 30u 100% 12u " Domain Name : $UNITYDOMAIN" ${NSD_CreateLabel} 0 45u 150% 12u " CC IP : $CCIP" ${NSD_CreateLabel} 0 60u 150% 12u " WINS IP : $WINSIP" ${NSD_CreateLabel} 0 95u 150% 12u "Press 'Back' to edit the above information" ${NSD_CreateLabel} 0 105u 150% 12u "Press 'Install' to proceed with the Service Installation" ${If} $domcheck == 0 ${AndIf} $ccipcheck == 0 ${AndIf} $winsipcheck == 0 EnableWindow $R9 1 ; uses domcheck since both valus are same ${Else} disable: ;messageBox MB_OK "Tamted!" EnableWindow $R9 0 ; disabling window ${NSD_CreateLabel} 0 15u 100% 12u "ERROR: Verifying validity of Domain or IP address(es) failed" ${EndIf} GetFunctionAddress $clnow clearnow nsDialogs::OnBack /NOUNLOAD $clnow nsDialogs::Show /NOUNLOAD FunctionEnd Function clearnow ; nsDialogs::SetUserData /NOUNLOAD $Text_ccip $CCIP ;Function nsDialogsPageLeave ${NSD_GetText} $Text_ccip $Text_ccip_State ;FunctionEnd ;${NSD_SetText} $Text_ccip $CCIP ;Strcpy $Text_ccip $CCIP ;MessageBox mb_iconstop "$Text_ccip and this is the ccip : $CCIP" ;${NSD_SetText} ;${NSD_SetText} ;${NSD_SetText} ;${NSD_SetText} ;Strcpy $UNITYDOMAIN "" ;Strcpy $CCIP "" ;Strcpy $WINSIP "" ;Strcpy $DOMADMIN "" ;Strcpy $DOMPASS "" ;Strcpy $DOMPASS2 "" FunctionEnd ;-------------------------------------------------------------------------------- ; Function for validation of domain name - looks for characters not on the list ;--------------------------------------------------------------------------------- Function StrCSpnReverse Exch $R0 ; string to check Exch Exch $R1 ; string of chars Push $R2 ; current char Push $R3 ; current char Push $R4 ; char loop Push $R5 ; char loop StrCpy $R4 -1 NextCharCheck: StrCpy $R2 $R0 1 $R4 IntOp $R4 $R4 - 1 StrCmp $R2 "" StrOK StrCpy $R5 -1 NextChar: StrCpy $R3 $R1 1 $R5 IntOp $R5 $R5 - 1 StrCmp $R3 "" +2 StrCmp $R3 $R2 NextCharCheck NextChar StrCpy $R0 $R2 Goto Done StrOK: StrCpy $R0 "" Done: Pop $R5 Pop $R4 Pop $R3 Pop $R2 Pop $R1 Exch $R0 FunctionEnd ;-------------------- ; Firewall Setup ;-------------------- Section "Fwallsetup" GetVersion::WindowsName Pop $R0 ${If} $R0 == "XP" nsExec::ExecToLog "netsh firewall add portopening protocol=TCP port=10001 name=Unity mode=enable scope=ALL" ${ElseIf} $R0 == "Server 2003" nsExec::ExecToLog "netsh firewall add portopening protocol=TCP port=10001 name=Unity mode=enable scope=ALL" ${ElseIf} $R0 == "Server 2003 R2" nsExec::ExecToLog "netsh firewall add portopening protocol=TCP port=10001 name=Unity mode=enable scope=ALL" ${ElseIf} $R0 == "vista" nsExec::ExecToLog 'netsh advfirewall firewall add rule name="Unity" dir=in action=allow protocol=TCP localport=10001' nsExec::ExecToLog /OEM 'netsh firewall set opmode disable' ${EndIf} SectionEnd ;--------------------------- ; Deleting registry entries ;-------------------------- Section "RegEntries" DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" "AltDefaultDomainName\$UNITYDOMAIN" DeleteRegValue HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" "CachePrimaryDomain\$UNITYDOMAIN" ; Deleting Environment Variable DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "$%UNITY_DOMAIN%" DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "$%UNITY_CCIP%" DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\$UNITYDOMAIN_ldap" "file\0x1" DeleteRegValue HKLM "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List" "10001:TCP" SectionEnd ;------------------------------- ; Making Registry Entries ;------------------------------- Section "RegEntries" WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\EscDomains\$UNITYDOMAIN_ldap" "file" 0x1 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache" "$UNITYDOMAIN" "" ; Firewall disabling Rule, Terminal Server Rules etc WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile" "EnableFirewall" 0x0 ; WriteRegStr HKLM "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts" "List" "10001:TCP" ; WriteRegStr HKLM "SYSTEM\ControlSet002\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List" "10001:TCP" "10001:TCP:*:Enabled:Unity" WriteRegStr HKEY_LOCAL_MACHINE "SYSTEM\ControlSet002\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List" "10001:TCP" "10001:TCP:*:Enabled:Unity" WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Terminal Server" "fDenyTSConnections" 0x0 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" "fInheritResetBroken" 0x0 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" "fResetBroken" 0x1 ; Delete roaming Profile Sycnhronization WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" "DeleteRoamingCache" 0x1 WriteRegDWORD HKLM "SOFTWARE\Policies\Microsoft\windows\System" "DeleteRoamingCache" 0x1 WriteRegDWORD HKLM "SOFTWARE\Policies\Microsoft\windows\System" "ReadOnlyProfile" 0x1 WriteRegDWORD HKLM "SOFTWARE\Policies\Microsoft\windows\System" "LocalProfile" 0x1 ; Eula For Newsid WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLUA" "0" ; The following line disables questions regarding Shutdowns etc in w2k3 WriteRegDWORD HKLM "SOFTWARE\Policies\Microsoft\Windows NT\Reliability" "ShutdownReasonOn" "0" SectionEnd ;----------------------- ;Manual Uninstallation ;----------------------- Section "Check" SEC04 ; goto label .Unin by label address refrence IfFileExists "$PROGRAMFILES\AtlantisUnity" $label_unin Detailprint "UN is Installed. Uninstalling..." SectionEnd ;------------------- ;Native Commands ;-------------------- Section "ShellExec" SEC03 getlabeladdress $label_unin .unin .unin: ;Stop Services DetailPrint "Stopping VM Agent(s)" nsExec::ExecToLog /OEM 'net stop "Unity VM" nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\vmagent\UnityVMAgent.exe" -u' nsExec::ExecToLog /OEM 'net localgroup Administrators /DELETE unity_apa_admin' nsExec::ExecToLog /OEM 'net localgroup Administrators /DELETE $UNITYDOMAIN\unity_apa_admin' nsExec::ExecToLog /OEM 'net localgroup "Remote Desktop Users" /DELETE "$UNITYDOMAIN\Domain Users"' nsExec::ExecToLog /OEM 'net localgroup Administrators /DELETE $DOMADMIN' nsExec::ExecToLog /OEM 'net user $DOMADMIN /DELETE' nsExec::ExecToLog /OEM 'CScript $drive\WINDOWS\system32\prnmngr.vbs -d -p "Atlantis Unity Printer"' RMDir /r "C:\SeamlessRDP" RMDir /r "$PROGRAMFILES\AtlantisUnity" Delete "$INSTDIR\uninst.exe" Delete "$PROGRAMFILES\Atlantis Unity Service Installer\Uninstall.lnk" RMDir "$SMPROGRAMS\Atlantis Unity Service Installer" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose false SectionEnd ;------------------------ ; Copying/Creating Files ;------------------------- Section "main" SEC01 SetOutPath "$INSTDIR" ;Writing to File defaultdomain.reg ;Opens an Empty File and fills it FileOpen $regvar "$INSTDIR\DefaultDomain.reg" w FileWrite $regvar "Windows Registry Editor Version 5.00$\r$\n" FileWrite $regvar '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]$\r$\n' FileWrite $regvar '"DefaultDomainName"="$UNITYDOMAIN"$\r$\n' FileWrite $regvar '"AltDefaultDomainName"="$UNITYDOMAIN"$\r$\n' FileWrite $regvar '"CachePrimaryDomain"="$UNITYDOMAIN"$\r$\n' FileWrite $regvar '[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DomainCache]$\r$\n' FileWrite $regvar '"$UNITYDOMAIN"=""' FileClose $regvar ;Closes the filled file SetOutPath "$INSTDIR" File /r "C:\Documents and Settings\atlantis\My Documents\fa3\faheem-nsis-scripts\serviceinstaller-src\*.*" ;C:\Documents and Settings\isaac\My Documents\faheem-nsis-scripts\serviceinstaller-src\*.*" ; Reading Environment variable for system drive ReadEnvStr $drive systemdrive ; Reading and modifying PATH to add seamlessrdp to systemdrive-path ReadEnvStr $R0 "PATH" SetEnv::SetEnvVar "PATH" $R0 strcpy $path $R0 Push $path Push "$drive\Seamlessrdp" Call StrContains Pop $0 StrCmp $0 "" 0 +2 nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\setx" Path "$path;$drive\Seamlessrdp" -m' ;${EnvVarUpdate} $0 "PATH" "R" "HKLM" "$drive:\Seamlessrdp" ; Copying Seamlessrdp and shotcut.exe to systemdrive's root SetOutPath "$drive" CreateDirectory "$drive\Seamlessrdp" ; creating Seamlessrdp folder CopyFiles "$EXEDIR\Seamlessrdp\*.*" "$drive\Seamlessrdp\" ; source -> destination CopyFiles "$EXEDIR\Shortcut.exe" "$drive\Seamlessrdp\" Copyfiles "$EXEDIR\DefaultDomain.bat" "$drive\Documents and Settings\Administrator\Start Menu\Programs\Startup\" Copyfiles "$EXEDIR\mydocs.reg" "$drive\" SetOutPath "$INSTDIR" CreateDirectory "$INSTDIR\custom" ; creating the destination folders CopyFiles "$EXEDIR\custom\*.*" "$INSTDIR\custom\" ; This line below is needed for setting the current working directory SetOutPath "$INSTDIR\custom" SectionEnd ;-------------------------------------------------- ; Installing Services/ Misc Programs ;-------------------------------------------------- Section "ShellExec2" ;Stop Services nsExec::ExecToLog /OEM 'netsh interface ip set wins name="Local Area Connection" source=static addr=$WINSIP' nsExec::ExecToLog /OEM 'netsh firewall set opmode disable' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\setx" UNITY_DOMAIN $UNITYDOMAIN -m' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\setx" UNITY_CCIP $CCIP -m' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\setx" UNITY_OU $UNITYOU -m' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\vmagent\UnityVMAgent.exe" -i' nsExec::ExecToLog /OEM '"C:\Program Files\AtlantisUnity\Joindom" $UNITYDOMAIN\$DOMADMIN $DOMPASS $UNITYDOMAIN $UNITYOU force' DetailPrint "Installing Cutewriter" nsExec::ExecToLog /OEM '$PROGRAMFILES\AtlantisUnity\cutewriter.exe' DetailPrint "Installing Converter" nsExec::ExecToLog /OEM '$PROGRAMFILES\AtlantisUnity\converter.exe' nsExec::ExecToStack /OEM 'net user $DOMADMIN $DOMPASS /EXPIRES:NEVER /ADD' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\NETUSER.EXE" $DOMADMIN /pwnexp:y' nsExec::ExecToLog /OEM 'net localgroup Administrators /ADD $DOMADMIN' nsExec::ExecToLog /OEM 'net localgroup "Remote Desktop Users" /ADD "$UNITYDOMAIN\Domain Users"' nsExec::ExecToLog /OEM "set UNITY_DOMAIN=$UNITYDOMAIN" DetailPrint "Configuring the Printer" nsExec::ExecToLog /OEM '"cscript prncnfg.vbs -x -p "CutePDF Writer" -z "Atlantis Unity Printer" ' DetailPrint "Installing Vmware Tools" nsExec::ExecToLog 'msiexec /i "$PROGRAMFILES\AtlantisUnity\VMwareTools\VMware Tools.msi" /q /n' nsExec::ExecToLog 'regedit /s "$PROGRAMFILES\AtlantisUnity\DefaultDomain.reg"' nsExec::ExecToLog '$PROGRAMFILES\AtlantisUnity\custom\custom.bat' DetailPrint " " DetailPrint " Rebooting System..." Sleep 5000 Reboot SectionEnd Section -Post WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Function .OnInstFailed UAC::Unload ;Must call unload! FunctionEnd Function .OnInstSuccess UAC::Unload ;Must call unload! FunctionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd ;--------------- ;Uninstaller ;--------------- Section Uninstall nsExec::ExecToLog /OEM 'net stop "Unity VM Agent Listener"' nsExec::ExecToLog /OEM 'net stop "Unity VM Agent Reporter"' nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\vmagent\UnityVMAgent" -u' ; nsExec::ExecToLog /OEM '"$PROGRAMFILES\AtlantisUnity\vmagent\UnityVMAgentReporter.exe" -u' nsExec::ExecToLog /OEM 'net localgroup Administrators /DELETE $UNITYDOMAIN\unity_apa_admin' nsExec::ExecToLog /OEM 'net localgroup "Remote Desktop Users" /DELETE "$UNITYDOMAIN\Domain Users"' nsExec::ExecToLog /OEM 'net localgroup Administrators /DELETE UnityServiceAdmin' nsExec::ExecToLog /OEM 'net user UnityServiceAdmin /DELETE' ; manual removal RMDir /r "$drive\SeamlessRDP" RMDir /r "$PROGRAMFILES\AtlantisUnity" Delete "$INSTDIR\uninst.exe" Delete "$PROGRAMFILES\AtlantisUnity\Uninstall.lnk" RMDir "$SMPROGRAMS\Atlantis Unity Service Installer" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose false SectionEnd