home *** CD-ROM | disk | FTP | other *** search
Wrap
' ^^^^^^^^^^ ' This program is configured in table part: Choose radio button Table ' ' Hint: ' You're allowed to use this script or parts of changed or unchanged in your StepOne ' installation. ' This script features professional installations for Windows and is full of hints and ' examples for your work with StepOne. ' If you change the table part (view: Table) of the script to your needs, ' you have a very good installation. ' One of the highlights of StepOne is the possibility to improve this installation script with ' the powerful script language, so you have full control of the whole installation process. ' ' If you start this program without making changes, a new path will be created. ' If you edit the tables of the Table part corresponding to your needs you get a full installation. ' If you start this script within StepIt, the StepOne FastCodeBuilder, you have to set the path ' of the to be copied files with menue FASTCODE - SETTINGS - COMMANDLINE, i.e. 'a:'. ' If the path is followed with a space and -1, you're abled to get the information that ' StepOne was started within StepIt. ' *************************************************************************************************** ' *************************************************************************************************** ' The command line (View: FastCode - Settings - Commandline)which StepIt.exe or Install.exe (FirstStep) ' passes through is saved in a variable. Len "ln", "{_command}" If "{ln}" = "0" Label "NoSourcePath" PathBox "command", "Please choose the path of the to be installed files.", "Choose source path", "{_bootdrv}\", "\", "*.*", "0", "&OK;&End" if "{command}" = "" end endif Else Let "command", "{_command}" EndIf DirExist "res", "{command}" If "{res}" = "0" Goto "NoSourcePath" EndIf Split "sourcepath", "{command}"," ","1" Split "StepIt", "{command}"," ","2" Let "prgname", "{prginfos[1;1]}" Let "mainprg", "{prginfos[2;1]}" ' Look if program runs GoSub "CheckPrg","{mainprg}" ' Welcome the user and give hints of using the installation GoSub "Welcome" ' Checking VBX files if they are loaded or installed in the Windows directory GoSub "CheckLibraries" Label "copyloop" ' The user can choose the installation path GoSub "GetTargetPath", "{prginfos[3;1]}" ' Create the choosen path GoSub "CreatePath" If "{path}" = "0" ' If create operation fails or user choosed anything other Goto "CopyLoop" EndIf ' Install files GoSub "Copying" If "{space}" = "-1" ' Copying failed because of unsufficient disk space. ' User has to choose another drive. Goto "CopyLoop" EndIf ' Add icon(s) in Program Manager group GoSub "ProgMan" ' Add Extension(s)in Registration Database GoSub "RegBase" ' Edit program INI file(s) GoSub "PrgINIs" If "{prginfos[4;1]}" = "-1" GoSub "ShareExe" EndIf ' Inform user about end of installation. ' Name of program is passed through to give user the possibility to start program immediately. GoSub "PrgEnd" ' End of installation End ' ************************************************************* Sub "Welcome" ' Show main window Window "-1", "{prgname} Installation", "Welcome", "Welcome to installation of {prgname}. Installation program will lead you through all neccessary steps.{_nl}{_nl}Press Continue to start installation.{_nl}{_nl}Press keys Ctrl and C together to cancel installation.", "", "43;23;960;888", "9" GetUserInput "&Continue" EndSub ' *************************************************************************************************** Sub "GetTargetPath" Parameter targetpath Window "-1", "", "Choose target path", "Please select the path where {prgname} should be installed to." Label "GetTargetPath1" ' If {ret} is a complete path, 'pathbox' uses only the part after the last backslash. ' In example 'c:\windows\system' will be used from 'PathBox' paramter 'Additional Path' as 'system'. ' PathBox parameter DefaultPath can contain a relative path, i.e.: 'c:\windows\..' get to 'c:\'. PathBox "targetpath", "Please choose the path for {prgname}.", "", "{_windowsdir}\..", "{GetTargetPath:targetpath}", "", "0", "&OK;&Cancel" If "{targetpath}" = "" ' User has choosed 'Cancel'. AskEnd asks the user if he want to end the program. 'If user chooses 'Yes', AskEnd works like End. AskEnd Goto "GetTargetPath1" EndIf EndSub ' *************************************************************************************************** ' New VBX and DLL files can be installed if they aren't loaded. Sub "CheckLibraries" ' If installation program is started within StepIt, check for libraries ' isn't neccessary. StepIt uses ' cscombo.vbx, csdialog.vbx, csform.vbx, ss3d.vbx, ss3d2.vbx, qpro200.dll ' Some installation programs would fail at this point. ' If you don't use the libraries you should set the if selection as remark. If "{StepIt}" <> "-1" ' Gets number of elements GetTableElementCount "number_vbx", "vbxtable" For "i", "1", "{number_vbx}" FileExist "wfound", "{_windowsdir}\{vbxtable[1;i]}" If "{wfound}" = "-1" GoSub "CorrectVBX", "{i}" EndIf Next EndIf EndSub ' ********************************************************************************************* Sub "CorrectVBX" Parameter "iVbx" Label "Active" 'Copies a common used file from windows to system directory to force version control 'It isn't checked if any of the common used files are installed anywhere on the users 'system. So, nevertheless version conflicts may occure. But this procedure 'fixed the common mistake to install vbx and dll in the windows directory. IsTaskActive "res", "{vbxtable[1;i]}" If "{res}" = "-1" MsgBox "res", "'{vbxtable[1;i]}' is in use. Please exit the application which uses the file and try it again.{_NL}If you aren't sure which application uses the library please exit all applications except of the Program Manager and this program.", "", "&Retry;&Program End" If "{res}" = "2" AskEnd Else Goto "Active" EndIf Else MsgBox "correct", "'{vbxtable[1;i]}' was found in your Windows directory. {_nl}Libraries like '{vbxtable[1;i]}' should be installed in System directory.{_nl}Should installation program '{vbxtable[1;i]}' correct the problem? To be sure that '{prgname}' runs correctly you should choose 'Correct'!", "", "&Correct;&Ignore" If "{correct}" = "1" Copy "{_windowsdir}\{vbxtable[1;i]}", "{_systemdir}\{vbxtable[1;i]}", "2" If "{_err}" = "0" Del "{_windowsdir}\{vbxtable[1;i]}" Else OutBox "'{vbxtable[1;i]}' couldn't be moved to System directory. If '{prgname}' doesn't run you should repeat the installation." EndIf EndIf EndIf EndSub ' *************************************************************************************************** Sub "CheckPrg" Parameter "p" Label "CheckPrg2" IsTaskActive "res","{CheckPrg:p}" If "{res}" = "-1" MsgBox "ret", "{CheckPrg:p} is active. To install a newer version you have to close it first, to be sure that version control works correct. Should installation program close {PrⁿfePrg:p} for you?", "", "&Task close;&Retry;&Program end" If "{ret}" = "1" TaskStop "{CheckPrg:p}" EndIf If "{ret}" = "3" End EndIf Goto "CheckPrg2" Else Goto "CheckPrg1" EndIf Label "CheckPrg1" EndSub ' *************************************************************************************************** Sub "CreatePath" DirExist "res", "{targetpath}" If "{res}" = "0" MsgBox "res", "'{targetpath}' doesn't exist.{_nl}Do you want to create the path?", "", "&Create;Change &selection;&Program end" If "{res}" = "3" End EndIf If "{res}" = "2" Let "directory", "0" Goto "CreatePath1" EndIf MkDir "{targetpath}" If "{_err}" = "-1" OutBox "During creation of path '{targetpath}' an error occurs. Please choose another path." Let "directory", "0" Else Let "directory", "-1" EndIf Else Let "directory", "-1" EndIf Label "CreatePath1" EndSub ' *************************************************************************************************** Sub "Copying" Window "-1", "", "Copying...", " " SplitPathName "todrv", "{targetpath}", "5" ' StepOne calcs the total of all file lengths and substracts the sum of ' the file lengths which will be overwritten. The minimum isn't 0 ' indeed it is the length of the longest file, which should be installed ' if the installation is on the same drive as temp drive. CalcFileTable "targetbytes", "targettable", "{sourcepath}", "{targetpath}", "3" CalcFileTable "systembytes", "systemtable", "{sourcepath}", "{_systemdir}", "3" ' Checks if two given paths have the same drive name If "{_systemdir}" := "{targetpath}" Compute "tofreebytes","{tofreebytes}" + "{targetbytes}" Else GetDiskFree "systemfreebytes", "{_systemdir}" If "{systembytes}" > "{systemfreebytes}" OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. {systembytes} bytes free space required.{_nl}Please free enough space on drive and retry installation." End EndIf EndIf GetDiskFree "tofreebytes", "{targetpath}" If "{targetbytes}" > "{tofreebytes}" OutBox "On drive{_nl}'{todrv}'{_nl}isn't enough space free. Please choose another drive." Let "space", "-1" Goto "Copying_end" Else Window "-1", "", "Copying...", "Please be patient..." GetTableLineCount "number_copy", "targettable" If "{number_copy}" > "0" CopyFileTable "targettable", "{sourcepath}", "{targetpath}", "1", "0" If "{_err}" = "-1" MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end" If "{res}" = "2" End EndIf EndIf EndIf If "{StepIt}" <> "-1" GetTableLineCount "number_copy", "systemtable" If "{number_copy}" > "0" Window "-1", "", "Copying system files..." CopyFileTable "systemtable", "{sourcepath}", "{_systemdir}", "1", "0" 'Make sure, dialog will be closed CopyFileTable If "{_err}" = "-1" MsgBox "res", "During copying occurs errors. Do you want to continue installation nevertheless?", "", "&OK;&Program end" If "{res}" = "2" End EndIf EndIf EndIf EndIf Let "space", "0" EndIf Label "copying_end" EndSub ' *************************************************************************************************** Sub "ProgMan" ' Get number of elements GetTableLineCount "number_prg", "prgmantable" If "{number_prg}" > "0" Window "-1", "", "Installing icons...", "Please be patient..." Let "i", "1" Let "tmp","" Label "ProgMan1" If "{tmp}" <> "{prgmantable[i;1]}" Let "tmp", "{prgmantable[i;1]}" DDEExecute "ProgMan", "ProgMan", "", "[creategroup({prgmantable[i;1]})]" If "{_err}" = "-1" OutBox "Group '{prgmantable[i;1]}' couldn't be created in Program Manager." EndIf EndIf GoSub "icon","{prgmantable[i;1]}","{targetpath}\{prgmantable[i;2]}","{prgmantable[i;3]}" Compute "i", "{i}" + "1" If "{i}" <= "{number_prg}" Goto "ProgMan1" EndIf EndIf EndSub ' *************************************************************************************************** Sub "Icon" Parameter "group","name","title" ' Sets the group window so that 'replaceitem' can find the group window DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]" DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},2)]" ' Deletes icon and saves position... DDEExecute "ProgMan", "ProgMan", "", "[replaceitem({icon:title})]" ' ... Additem can use it DDEExecute "ProgMan", "ProgMan", "", "[additem({icon:name},{icon:title},,)]" If "{_err}" = "-1" OutBox "'{prgname}' icon couldn't be installed in Program Manager." EndIf ' Brings group window on top, so user can find it immediately. DDEExecute "ProgMan", "ProgMan", "", "[showgroup({icon:group},1)]" EndSub ' *************************************************************************************************** Sub "RegBase" ' Gets number of elements GetTableLineCount "number_reg", "regbasetable" If "{number_reg}" > "0" Let "i", "1" Label "RegBase1" RegBaseWrite "{regbasetable[i;2]}", "{regbasetable[i;3]}" RegBaseWrite "{regbasetable[i;3]}", "{regbasetable[i;4]}" RegBaseWrite "{regbasetable[i;3]}\shell\open\command", "{targetpath}\{regbasetable[i;5]}" If "{regbasetable[i;1]}" <> "CMD" RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec", "{regbasetable[i;6]}" RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\application", "{regbasetable[i;7]}" RegBaseWrite "{regbasetable[i;3]}\shell\open\ddeexec\topic", "{regbasetable[i;8]}" EndIf Compute "i", "{i}" + "1" If "{i}" <= "{number_reg}" Goto "RegBase1" EndIf EndIf EndSub ' *************************************************************************************************** Sub "PrgINIs" ' Gets number of elements GetTableLineCount "number_ini", "initable" If "{number_ini}" > "0" Let "i","1" Label "PrgINIs1" INIWrite "{initable[i;1]}","{initable[i;2]}","{initable[i;3]}","{initable[i;4]}" Compute "i", "{i}" + "1" If "{i}" <= "{number_ini}" Goto "PrgINIs1" EndIf EndIf EndSub ' *************************************************************************************************** Sub "ShareExe" If "{_locking}" = "0" MsgBox "addlocking", "'{prgname}' needs a network or SHARE for his database. Installation program can install SHARE in your AUTOEXEC.BAT and restarts your system after end of installation to let the changes effect. Do you want to add SHARE? To make the changes on yourself choose 'Not install'.", "SHARE.EXE", "&Install;&Not install" If "{addlocking}" = "1" AddShareExe EndIf EndIf EndSub Sub "PrgEnd" Window "-1", "", "Ready!", "It's completed. Installation of '{prgname}' is finished." GetUserInput "&OK" If "{addlocking}" = "1" MsgBox "reboot", "Installation program has add SHARE.EXE to your AUTOEXEC.BAT. To let the changes effect you've to restart your system. Should installation program makes a restart?", "Warmstart", "&Restart;&No Restart" If "{reboot}" = "1" ReBoot "3" Else OutBox "Before start of {prgname} you've to restart your system." EndIf EndIf EndSub