InstallShield中的TARGETDIR与INSTALLDIR变量

本文详细介绍了如何利用InstallShield软件在制作安装程序时为用户提供自定义安装路径的功能,并通过设置常量TARGETDIR实现,同时解释了在不同类型的安装包工程中如何灵活应用这一技巧。

在用InstallShield制作安装包的时候我们经常需要用到"TARGETDIR"变量 
"TARGETDIR"变量  如:我们在制作安装程序的时候需要为用户默认指定一个安装路径,基本上所有的安装包都这样来做的, 
    比如:我们在安装QQ的时候默认安装路径是C:\Program Files\qq 那么我们就可以在制作安装程序的是为C:\Program Files\qq指定一个常量TARGETDIR, 当我们需要用到这个C:\Program Files\qq的地方就写上TARGETDIR就可以了。 
    另外TARGETDIR的值是可以让用户修改的,就是说用户可以自己改变安装路径。

通常TARGETDIR是InstallScript工程中使用

而在InstallScript MSI和Basic MSI工程中,安装路径变量是INSTALLDIR。

//=========================================================================== // // File Name: Setup.rul // // Description: Blank setup main script file // // Comments: Blank setup is an empty setup project. If you want to // create a new project via. step-by step instructions use the // Project Assistant. // //=========================================================================== // Included header files ---------------------------------------------------- #include "ifx.h" #include "SdDagentInput.rul" #include "SdDbpsdInput.rul" #include "SdWebInput.rul" // Note: In order to have your InstallScript function executed as a custom // action by the Windows Installer, it must be prototyped as an // entry-point function. // The keyword export identifies MyFunction() as an entry-point function. // The argument it accepts must be a handle to the Installer database. /* export prototype MyFunction(HWND); */ //--------------------------------------------------------------------------- // OnBegin // // The OnBegin event is called directly by the framework after the setup // initializes. //--------------------------------------------------------------------------- function OnBegin() string szMsg,svResult; number nvFreeMem; begin // TO DO: you may change default non-UI setting, for example // // You may also perform your custom initialization steps, check requirements, etc. //-------------------------start zxl //替换边框上的Installshield Wizward字样 SetTitle(IFX_PRODUCT_NAME+"安装向导",0,BACKGROUNDCAPTION); //替换图标 DialogSetInfo(DLG_INFO_ALTIMAGE, SUPPORTDIR ^ "dsglogo.bmp", TRUE); Disable (BACKBUTTON); /* * <内存容量的检测> * 相关函数:GetSystemInfo() 返回目标系统的各种信息, * 如CPU类型,磁盘容量,当前日期,当前操作系统,内存容量等 */ if(GetSystemInfo(EXTENDEDMEMORY,nvFreeMem,svResult)<0)then MessageBox("内存检测失败,安装程序将终止!",SEVERE); abort; endif; if(nvFreeMem<16384)then szMsg = "该软件只能安装在16M以上内存的机器中。\n很遗憾,本机器可用内存不足16M!\n\n安装程序将终止!"; MessageBox(szMsg,SEVERE); abort; endif; //----------------------------end zxl end; //--------------------------------------------------------------------------- // OnFirstUIBefore // // The OnFirstUIBefore event is called by the framework when the setup is // running in first install mode. By default this event displays UI allowing // the end user to specify installation parameters. //--------------------------------------------------------------------------- function OnFirstUIBefore() NUMBER nResult, nSetupType, nvSize, nUser; STRING szTitle, szMsg, szQuestion, svName, svCompany,tempStr,szDlg; STRING szLicenseFile; BOOL bCustom, bIgnore1, bIgnore2; STRING szFeatureName1; //zxl STRING szFeatureName2; //zxl STRING szFeatureName3; //zxl STRING szFeatureName4; //zxl-0601 LIST list, listStartCopy; //zxl NUMBER bvOpt1,bvOpt2; //zxl STRING svDir; STRING szKey,svValue,javaPath; number nvType; string SD_IP_PATH,szFile,szFilePath; begin // TO DO: if you want to enable background, window title, and caption bar title // SetTitle( @PRODUCT_NAME, 24, WHITE ); // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION ); // Enable( FULLWINDOWMODE ); // Enable( BACKGROUND ); // SetColor(BACKGROUND,RGB (0, 128, 128)); // Added in InstallShield 15 - Show an appropriate error message if // -removeonly is specified and the product is not installed. if( REMOVEONLY ) then Disable( DIALOGCACHE ); szMsg = SdLoadString( IDS_IFX_ERROR_PRODUCT_NOT_INSTALLED_UNINST ); SdSubstituteProductInfo( szMsg ); MessageBox( szMsg, SEVERE ); abort; endif; nSetupType = TYPICAL; //欢迎界面 Dlg_SdWelcome: szTitle = ""; szMsg = ""; nResult = SdWelcome(szTitle, szMsg); if (nResult = BACK) goto Dlg_SdWelcome; szTitle = ""; svName = ""; svCompany = ""; //------------------------start zxl /* Dlg_SdRegisterUser: szMsg = ""; szTitle = ""; nResult = SdRegisterUser( szTitle, szMsg, svName, svCompany ); if (nResult = BACK) goto Dlg_SdWelcome; Dlg_SetupType: szTitle = ""; szMsg = ""; nResult = SetupType2(szTitle, szMsg, "", nSetupType, 0); if (nResult = BACK) then goto Dlg_SdRegisterUser; else nSetupType = nResult; if (nSetupType != CUSTOM) then nvSize = 0; FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize); if (nvSize != 0) then MessageBox(szSdStr_NotEnoughSpace, WARNING); goto Dlg_SetupType; endif; bCustom = FALSE; goto Dlg_SQL; else bCustom = TRUE; endif; endif; */ //----------------------------------end zxl //选择安装路径 Dlg_SdAskDestPath: svDir = "D:\\dsg\\dsync"; //nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0); nResult = SdAskDestPath(szTitle, szMsg, svDir, 0); TARGETDIR = svDir; if (nResult = BACK) goto Dlg_SdWelcome; Dlg_SdFeatureTree: szTitle = "选择安装功能"; szMsg = ""; szFeatureName1 ="dagent"; szFeatureName2 ="dbpsd"; szFeatureName3 ="dconsole"; szFeatureName4 ="web"; //if (nSetupType = CUSTOM) then --zxl nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2); if (nResult = BACK) goto Dlg_SdAskDestPath; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then //zxl ---------安装web模块环境安装NetFramework4.0.30319.exe start //MessageBox ("请安装NetFramework4.0.303191111111111111111111", WARNING); //判断是否安装了java //1.设置一下默认的注册表键值根节点为HKEY_LOCAL_MACHINE RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); //2.判断是否安装NetFramework4.0.30319.exe这个软件 if (RegDBKeyExist ("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full") < 0) then //MessageBox ("请安装NetFramework4.0.303192222222222222222222222", WARNING); //SRCDISK:指源盘,安装程序所在的盘 if(LaunchAppAndWait (INSTALLDIR + "NetFramework4.0.30319.exe","", LAAW_OPTION_WAIT)<0)then MessageBox ("当前环境未安装NetFramework4.0.30319,当前目录获取NetFramework4.0.30319.exe安装包失败,请手动安装!", SEVERE); abort; endif; //else //MessageBox ("当前环境已安装 NetFramework4.0.30319.exe!", INFORMATION); endif; //zxl ---------安装web模块环境安装NetFramework4.0.30319.exe end endif; //20230504 获取主机IP SD_IP_PATH = TARGETDIR + "IPAddress"; CreateDir(SD_IP_PATH); szFile = INSTALLDIR + "getip.bat"; szFilePath = TARGETDIR + "IPAddress\\getip.bat"; //MessageBox(szFile, WARNING); CopyFile(szFile, szFilePath); LaunchAppAndWait(szFilePath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); //获取主机IP 结束 if (FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then goto Dlg_SdDagent; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then goto Dlg_SdDbpsd; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then goto Dlg_SdWeb; endif; goto Dlg_SdStartCopy; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then goto Dlg_SdDagent; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then goto Dlg_SdDbpsd; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then goto Dlg_SdWeb; endif; //---------------zxl Dlg_SdDagent: szTitle = "配置服务端(Dagent)注册服务的IP、端口号和服务名"; szMsg = " "; szFeatureName1 ="dagent"; szFeatureName2 ="dbpsd"; szFeatureName4 ="web"; nResult = SdDagent(szTitle, szMsg); if (nResult = BACK) goto Dlg_SdFeatureTree; if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then /*//获取dagent页面的ip,填充的dbpsd页面 EzDefineDialog(szDlg, ISUSER, "", 13000 ); CtrlGetText(szDlg, 13003, tempStr); EzDefineDialog(szDlg, ISUSER, "", 14000); CtrlSetText(szDlg, 14003, tempStr); */ goto Dlg_SdDbpsd; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then /*//获取dagent页面的ip,填充的web页面 EzDefineDialog(szDlg, ISUSER, "", 13000 ); CtrlGetText(szDlg, 13003, tempStr); EzDefineDialog(szDlg, ISUSER, "", 15000); CtrlSetText(szDlg, 15001, tempStr); */ goto Dlg_SdWeb; endif; if (nResult = NEXT) goto Dlg_SdStartCopy; Dlg_SdDbpsd: szTitle = "配置服务端(Dbpsd)注册服务的IP、端口号和服务名"; szMsg = " "; szFeatureName1 ="dagent"; szFeatureName2 ="dbpsd"; szFeatureName4 ="web"; nResult = SdDbpsd(szTitle, szMsg); if (nResult = BACK) goto Dlg_SdFeatureTree; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then goto Dlg_SdWeb; endif; if (nResult = NEXT) goto Dlg_SdStartCopy; Dlg_SdWeb: szTitle = "配置web端注册服务的IP和端口号"; szMsg = " "; szFeatureName1 ="dagent"; szFeatureName2 ="dbpsd"; szFeatureName4 ="web"; nResult = SdWeb(szTitle, szMsg); if (nResult = BACK) goto Dlg_SdFeatureTree; if (nResult = NEXT) goto Dlg_SdStartCopy; //-----------------zxl /* *Dlg_SQL: * szTitle = "选择安装目录"; * szMsg = ""; * nResult = OnSQLLogin( nResult ); * if( nResult = BACK ) then * if (!bCustom) then * goto Dlg_SdAskDestPath; * else * goto Dlg_SdFeatureTree; * endif; * endif; */ Dlg_SdStartCopy: szTitle = "确认安装目录及安装功能"; szMsg = ""; //nResult = SdStartCopy2( szTitle, szMsg ); --zxl // //删除获取IP的目录 DeleteDir(TARGETDIR + "IPAddress",ALLCONTENTS); //-----------------------start zxl szFeatureName1 = "dagent"; szFeatureName2 = "dbpsd"; szFeatureName3 = "dconsole"; szFeatureName4 = "web"; //nResult = SdStartCopy2( szTitle, szMsg ); //zxl listStartCopy = ListCreate( STRINGLIST ); ListAddString(listStartCopy,"Dsync安装目录: " + INSTALLDIR,AFTER); ListAddString(listStartCopy," ",AFTER); if (FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then ListAddString(listStartCopy,"安装功能: "+szFeatureName3,AFTER); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then ListAddString(listStartCopy,"安装功能: "+szFeatureName1,AFTER); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then ListAddString(listStartCopy,"安装功能: "+szFeatureName2,AFTER); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then ListAddString(listStartCopy,"安装功能: "+szFeatureName4,AFTER); endif; nResult = SdStartCopy( szTitle, szMsg, listStartCopy ); ListDestroy(listStartCopy); //---------------------end zxl if (nResult = BACK) then goto Dlg_SdFeatureTree; endif; // Added in IS 2009 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) ); // setup default status Enable(STATUSEX); return 0; end; //--------------------------------------------------------------------------- // OnEnd // // The OnEnd event is called at the end of the setup. This event is not // called if the setup is aborted. //--------------------------------------------------------------------------- function OnEnd() //----------------------------zxl STRING szFeatureName1,szFeatureName2,szFeatureName3,szFeatureName4; STRING szDocFile; string szProgram; string szParam; string szReg; string szInstallDir; string szNewInstallDir,szBatInstallDir,szOldInstallDir; string szTmpStr,szNewStr; string szText; string szSrcFile, szTargetFile, szDir, szTargetPath; number len, nOp; string szBatPath; STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2; NUMBER bOpt1, bOpt2; string subKey; //---------------------------zxl begin szFeatureName1="dconsole"; szFeatureName2="dagent"; szFeatureName3="dbpsd"; szFeatureName4="web"; subKey = "\\Installer\\Features\\163B3B8D678BC9B4F9B2325FD3BB3873"; RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\Installer\\Products\\163B3B8D678BC9B4F9B2325FD3BB3873"; RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\Installer\\UpgradeCodes\\F57C4C15A09141749B205FA70DC747A3"; RegDBSetDefaultRoot(HKEY_CLASSES_ROOT); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Classes\\Installer\\Products\\163B3B8D678BC9B4F9B2325FD3BB3873"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Classes\\Installer\\UpgradeCodes\\F57C4C15A09141749B205FA70DC747A3"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "//SOFTWARE//Classes//Installer//UpgradeCodes//{F57C4C15A09141749B205FA70DC747A3}"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\F57C4C15A09141749B205FA70DC747A3"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\163B3B8D678BC9B4F9B2325FD3BB3873"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; //删除项//SOFTWARE//Microsoft//Wow6432Node//Microsoft//Windows//CurrentVersion//Uninstall// subKey = "\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{D8B3B361-B876-4B9C-9F2B-23F53DBB8337}"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\InstallShield_{D8B3B361-B876-4B9C-9F2B-23F53DBB8337}"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; //禁用反安装 subKey = "//SOFTWARE//Microsoft//Windows//CurrentVersion//Uninstall//" + IFX_PRODUCT_NAME; //MessageBox (IFX_PRODUCT_NAME, WARNING); //MessageBox (DISK1TARGET, WARNING); RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; //ExistsDir函数在目标系统上检测指定目录的存在性 if(!ExistsDir(DISK1TARGET)) then DeleteDir(DISK1TARGET,ALLCONTENTS); endif; subKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\F57C4C15A09141749B205FA70DC747A3"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; subKey = "\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Products\\163B3B8D678BC9B4F9B2325FD3BB3873"; RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); if (RegDBKeyExist(subKey) =1) then RegDBDeleteKey (subKey); endif; end; //--------------------------------------------------------------------------- // OnFirstUIAfter // // The OnFirstUIAfter event called by the framework after the file transfer // of the setup when the setup is running in first install mode. By default // this event displays UI that informs the end user that the setup has been // completed successfully. //--------------------------------------------------------------------------- function OnFirstUIAfter() STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2; NUMBER bOpt1, bOpt2; STRING szFeatureName1,szFeatureName2,szFeatureName3,szFeatureName4; STRING szDocFile; string szBatPath; string szProgram; string szParam; string szReg; string szInstallDir; string szNewInstallDir,szBatInstallDir,szOldInstallDir; string szTmpStr,szNewStr; string szText; string szSrcFile, szTargetFile, szDir, szTargetPath; number len, nOp; STRING szKey,svValue,javaPath; number nvType,nvSize; begin szFeatureName1="dconsole"; szFeatureName2="dagent"; szFeatureName3="dbpsd"; szFeatureName4="web"; Disable(STATUSEX); bOpt1 = FALSE; bOpt2 = FALSE; if ( BATCH_INSTALL ) then SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 ); else /* 使用sed.exe和setbat.exe修改配置文件config.bat sed.exe修改普通参数 setbat.exe修改路径 */ if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then //修改dagent的config.bat //软件包安装路径 szInstallDir = INSTALLDIR + "dagent"; //安装后bat文件所在路径 szBatInstallDir = INSTALLDIR + "dagent\\scripts"; //bat文件中需要替换掉的旧路径 szOldInstallDir = "D:\\DSG\\dsync_package\\dagent"; //setbat.exe程序所在路径 szProgram = INSTALLDIR + "dagent\\bin\\setbat.exe"; len = StrLength(szInstallDir); StrSub(szNewInstallDir, szInstallDir, 0, len - 1); //szParam = szNewInstallDir + " " + INSTALLDIR + "\dagent\scripts" + " " + "D:\DSG\dsync_package\dagent" + " " + szNewInstallDir; //szParam = szInstallDir +" "+ szlodInstallDir1 +" "+ szlodInstallDir2 +" "+ szInstallDir; szParam = szInstallDir +" "+ szBatInstallDir +" "+ szOldInstallDir +" "+ szInstallDir; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dagent\\bin\\sed.exe"; szTmpStr = SD_DAGENT_HOST; //len = StrLength(szTmpStr); //获取字符串长度 //StrSub(szNewStr, szTmpStr, 0, len - 1); //截取字符串 szParam = "-i \"s/192.168.6.11/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dagent\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dagent\\bin\\sed.exe"; szTmpStr = SD_DAGENT_PORT; //len = StrLength(szTmpStr); //获取字符串长度 //StrSub(szNewStr, szTmpStr, 0, len - 1); //截取字符串 szParam = "-i \"s/5001/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dagent\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dagent\\bin\\sed.exe"; szTmpStr = SD_DAGENT_NAME; szParam = "-i \"s/dagent+/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dagent\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); //删除Dsync不相关文件 DeleteFile(INSTALLDIR + "dagent\\bin\\sed*"); DeleteFile(INSTALLDIR + "dagent\\bin\\libiconv2.dll"); DeleteFile(INSTALLDIR + "dagent\\bin\\libintl3.dll"); DeleteFile(INSTALLDIR + "dagent\\bin\\setbat.exe"); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then //修改dbpsd的config.bat //软件包安装路径 szInstallDir = INSTALLDIR + "dbpsd"; //安装后bat文件所在路径 szBatInstallDir = INSTALLDIR + "dbpsd\\scripts"; //bat文件中需要替换掉的旧路径 szOldInstallDir = "D:\\DSG\\dsync_package\\dbpsd"; //setbat.exe程序所在路径 szProgram = INSTALLDIR + "dbpsd\\bin\\setbat.exe"; len = StrLength(szInstallDir); StrSub(szNewInstallDir, szInstallDir, 0, len - 1); szParam = szInstallDir +" "+ szBatInstallDir +" "+ szOldInstallDir +" "+ szInstallDir; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dbpsd\\bin\\sed.exe"; szTmpStr = SD_DBPSD_HOST; szParam = "-i \"s/192.168.6.11/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dbpsd\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dbpsd\\bin\\sed.exe"; szTmpStr = SD_DBPSD_PORT; szParam = "-i \"s/5002/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dbpsd\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); szProgram = INSTALLDIR + "dbpsd\\bin\\sed.exe"; szTmpStr = SD_DBPSD_NAME; szParam = "-i \"s/dbpsd+/" + szTmpStr + "/g\"" + " " + TARGETDIR + "dbpsd\\scripts\\config.bat"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); //删除Dsync不相关文件 DeleteFile(INSTALLDIR + "dbpsd\\bin\\sed*"); DeleteFile(INSTALLDIR + "dbpsd\\bin\\setbat.exe"); DeleteFile(INSTALLDIR + "dbpsd\\bin\\regex2.ddl"); DeleteFile(INSTALLDIR + "dbpsd\\bin\\libintl3.dll"); DeleteFile(INSTALLDIR + "dbpsd\\bin\\libiconv2.dll"); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then //修改web的config.bat //软件包安装路径 szInstallDir = INSTALLDIR + "web"; //安装后bat文件所在路径 szBatInstallDir = INSTALLDIR + "web\\scripts"; //bat文件中需要替换掉的旧路径 szOldInstallDir = "D:\\dsg\\dsync\\web"; //setbat.exe程序所在路径 szProgram = INSTALLDIR + "web\\bin\\setbat.exe"; len = StrLength(szInstallDir); StrSub(szNewInstallDir, szInstallDir, 0, len - 1); szParam = szInstallDir +" "+ szBatInstallDir +" "+ szOldInstallDir +" "+ szInstallDir; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); //修改application.properties文件中的端口 szProgram = INSTALLDIR + "web\\bin\\sed.exe"; szTmpStr = SD_WEB_PORT; szParam = "-i \"s/9090/" + szTmpStr + "/g\"" + " " + TARGETDIR + "web\\bin\\application.properties"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); //修改application.properties文件中的IP szProgram = INSTALLDIR + "web\\bin\\sed.exe"; szTmpStr = SD_WEB_HOST; szParam = "-i \"s/192.168.24.243/" + szTmpStr + "/g\"" + " " + TARGETDIR + "web\\bin\\application.properties"; LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); /* *szProgram = INSTALLDIR + "web\\bin\\sed.exe"; *szTmpStr = SD_WEB_NAME; *szParam = "-i \"s/web+/" + szTmpStr + "/g\"" + " " + TARGETDIR + "web\\scripts\\config.bat"; *LaunchAppAndWait(szProgram, szParam, LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); */ //删除Dsync不相关文件 DeleteFile(INSTALLDIR + "web\\bin\\libiconv2.dll"); DeleteFile(INSTALLDIR + "web\\bin\\libintl3.dll"); DeleteFile(INSTALLDIR + "web\\bin\\msvcr100d.dll"); DeleteFile(INSTALLDIR + "web\\bin\\msvcp140d.dll"); DeleteFile(INSTALLDIR + "web\\bin\\regex2.ddl"); DeleteFile(INSTALLDIR + "web\\bin\\libintl3.dll"); DeleteFile(INSTALLDIR + "web\\bin\\libiconv2.dll"); DeleteFile(INSTALLDIR + "web\\bin\\ucrtbased.dll"); DeleteFile(INSTALLDIR + "web\\bin\\vcruntime140d.dll"); DeleteFile(INSTALLDIR + "web\\bin\\regex2.dll"); DeleteFile(INSTALLDIR + "web\\bin\\pthreadGC2.dll"); DeleteFile(INSTALLDIR + "web\\bin\\sed.exe"); DeleteFile(INSTALLDIR + "web\\bin\\sed*"); DeleteFile(INSTALLDIR + "web\\bin\\setbat.exe"); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then javaPath= INSTALLDIR + "web\\java\\bin"; //环境变量在注册表中所在位置 szKey = "SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment"; //如果Path存在 if(RegDBGetKeyValueEx(szKey,"Path",nvType,svValue,nvSize)=0)then //MessageBox (svValue, WARNING); if(svValue!="") then //如果path还没有jre\bin的路径信息 if(StrFind ( svValue, javaPath )<0) then //添加路径信息,此时要带上分号 svValue=svValue+";"+javaPath; //MessageBox (svValue, WARNING); endif; else svValue= javaPath; //如果键值为空,则直接添加即可,事实上键值为空的情况不会出现,这句话是无用的判断 endif; else svValue= javaPath; //如果没有这个键值,把值也直接添加进去,事实上这个情况也不会出现,因为path在操作系统安装完毕后就存在了,//除非你手动删除了,但是那样操作系统也会有问题了 endif; if(!MAINTENANCE)then Disable(LOGGING); //添加或者重设键值 if(RegDBSetKeyValueEx(szKey, "Path", REGDB_STRING_EXPAND, svValue, -1)<0) then MessageBox ("Path create failed, please set it manually!", SEVERE); endif; Enable(LOGGING); endif; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then if(FeatureIsItemSelected(MEDIA, szFeatureName2)=1 | FeatureIsItemSelected(MEDIA, szFeatureName3)=1 | FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then //Disable(STATUSEX); ShowObjWizardPages(NEXT); bOpt1 = TRUE; bOpt2 = TRUE; szMsg1 = SdLoadString(IFX_SDFINISH_MSG1); szTitle=""; szMsg1=""; szMsg2=""; szOpt1="是否创建桌面快捷方式dsync?"; szOpt2="是否启动并注册服务?"; //SdFinishEx(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); SdFinish(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); if(bOpt2=TRUE) then //执行bat脚本注册并启动服务 if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then szBatPath = INSTALLDIR + "dagent\\scripts\\start_dagent.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then szBatPath = INSTALLDIR + "dbpsd\\scripts\\start_dbpsd.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then szBatPath = INSTALLDIR + "web\\scripts\\start.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; endif; if(bOpt1=TRUE) then szDocFile = TARGETDIR^"dconsole\\dconsole.exe"; LongPathToQuote(szDocFile, TRUE ); //AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir,szIconPath, nIcon, szShortCutKey, nFlag); AddFolderIcon(FOLDER_DESKTOP, "dsync" , szDocFile, TARGETDIR^"dconsole" , TARGETDIR^"dconsole\\dconsole.exe" , 0 ,"" , REPLACE ); endif; endif; endif; if ( FeatureIsItemSelected(MEDIA, szFeatureName4)=1 | FeatureIsItemSelected(MEDIA, szFeatureName2)=1 | FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then if(FeatureIsItemSelected(MEDIA, szFeatureName1) != 1) then //Disable(STATUSEX); ShowObjWizardPages(NEXT); bOpt1 = TRUE; bOpt2 = TRUE; szMsg1 = SdLoadString(IFX_SDFINISH_MSG1); szTitle=""; szMsg1=""; szMsg2=""; szOpt1=""; szOpt2="是否启动并注册服务?"; //SdFinishEx(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); SdFinish(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); if(bOpt2=TRUE) then //执行bat脚本注册并启动服务 if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then szBatPath = INSTALLDIR + "dagent\\scripts\\start_dagent.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName3)=1) then szBatPath = INSTALLDIR + "dbpsd\\scripts\\start_dbpsd.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName4)=1) then szBatPath = INSTALLDIR + "web\\scripts\\start.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; endif; endif; endif; if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then if(FeatureIsItemSelected(MEDIA, szFeatureName2) != 1) then if(FeatureIsItemSelected(MEDIA, szFeatureName3) != 1) then if(FeatureIsItemSelected(MEDIA, szFeatureName4) != 1) then //Disable(STATUSEX); ShowObjWizardPages(NEXT); bOpt1 = TRUE; bOpt2 = TRUE; szMsg1 = SdLoadString(IFX_SDFINISH_MSG1); szTitle=""; szMsg1=""; szMsg2=""; szOpt1=""; szOpt2="是否创建桌面快捷方式dsync?"; //SdFinishEx(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); SdFinish(szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bOpt1, bOpt2); if(bOpt2=TRUE) then szDocFile = TARGETDIR^"dconsole\\dconsole.exe"; LongPathToQuote(szDocFile, TRUE ); //AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir,szIconPath, nIcon, szShortCutKey, nFlag); AddFolderIcon(FOLDER_DESKTOP, "dsync" , szDocFile, TARGETDIR^"dconsole" , TARGETDIR^"dconsole\\dconsole.exe" , 0 ,"" , REPLACE ); endif; endif; endif; endif; endif; //SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bOpt1 , bOpt2 ); endif; end; //--------------------------------------------------------------------------- // OnMaintUIBefore // // The OnMaintUIBefore event is called by the framework when the setup is // running in maintenance mode. By default this event displays UI that // allows the end user to add or remove features, repair currently // installed features or uninstall the application. //--------------------------------------------------------------------------- function OnMaintUIBefore() NUMBER nResult, nType; STRING szTitle, szMsg, svDir, svResult, szCaption; STRING szFeatureName1; //zxl STRING szFeatureName2; //zxl STRING szFeatureName3; //zxl STRING szFeatureName4; //zxl LIST list, listStartCopy; //zxl NUMBER bvOpt1,bvOpt2; //zxl string szBatPath,szDir1,szDir2,szDir3,szDir4; begin // TO DO: if you want to enable background, window title, and caption bar title // SetTitle( @PRODUCT_NAME, 24, WHITE ); // SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION ); // SetColor(BACKGROUND,RGB (0, 128, 128)); // Enable( FULLWINDOWMODE ); // Enable( BACKGROUND ); szDir1 = INSTALLDIR + "dagent"; szDir2 = INSTALLDIR + "dbpsd"; szDir3 = INSTALLDIR + "dconsole"; szDir3 = INSTALLDIR + "web"; //-----------------------zxl //卸载已安装的功能 Disable( DIALOGCACHE ); nType = REMOVEALL; nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO ); if (nResult != IDYES ) then abort; endif; ComponentRemoveAll(); // Added in IS 2009 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) ); /* if (ExistsDir(szDir1) = 0) then szBatPath = INSTALLDIR + "dagent\\scripts\\uninstall_dagent.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); DeleteDir(szDir1,ALLCONTENTS); endif; if (ExistsDir(szDir2) = 0) then szBatPath = INSTALLDIR + "dbpsd\\scripts\\uninstall_dbpsd.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); DeleteDir(szDir2,ALLCONTENTS); endif; */ /* if (ExistsDir(szDir1) = 0) then DeleteDir(szDir1,ALLCONTENTS); endif; if (ExistsDir(szDir2) = 0) then DeleteDir(szDir2,ALLCONTENTS); endif; */ /* if (ExistsDir(szDir3) = 0) then DeleteDir(szDir3,ALLCONTENTS); endif; */ Enable(STATUSEX); //-----------------------zxl /* Dlg_Start: // Added in Version 9.5 - Support for REMOVEONLY option. if( !REMOVEONLY ) then // In standard mode show maintenance dialog Disable(BACKBUTTON); nType = SdWelcomeMaint(szTitle, szMsg, MODIFY); Enable(BACKBUTTON); else // Hide the initial progress dialog as otherwise the user can // click on it, and hide the MessageBox. Disable( DIALOGCACHE ); // In RemoveOnly mode, set to remove. nType = REMOVEALL; endif; // Show Uninstall Confirmation Dialog if ( nType = REMOVEALL ) then nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO ); if (nResult != IDYES ) then if( REMOVEONLY ) then // In REMOVEONLY mode, abort the setup. abort; else // In non-REMOVEONLY mode, redisplay the previous dialog. goto Dlg_Start; endif; endif; endif; nResult = NEXT; Dlg_SdFeatureTree: if (nType = MODIFY) then szTitle = ""; szMsg = ""; szFeatureName1 = "dagent"; szFeatureName2 = "dbpsd"; szFeatureName3 = "dconsole"; nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2); if (nResult = BACK) goto Dlg_Start; endif; switch(nType) case REMOVEALL: //------------------zxl //清理环境前先卸载进程 if (FeatureIsItemSelected(MEDIA, szFeatureName1)=1) then szBatPath = INSTALLDIR + "dagent\\scripts\\uninstall_dagent.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; if (FeatureIsItemSelected(MEDIA, szFeatureName2)=1) then szBatPath = INSTALLDIR + "dbpsd\\scripts\\uninstall_dbpsd.bat"; LaunchAppAndWait(szBatPath, "", LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN); endif; //------------------zxl ComponentRemoveAll(); // Added in IS 2009 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) ); case REPAIR: ComponentReinstall(); // Added in IS 2009 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) ); case MODIFY: // Added in IS 2009 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) ); endswitch; Enable(STATUSEX); */ end; 如果是我的这个脚本 应该怎么修改
最新发布
12-11
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值