Hi,
I need to create some files with specific content during the installation of my application.
I'm using VB 5.0.
Can I do this with VB's Setup Wizard or P&D Wizard or do I need to create my own installation program?
Printable View
Hi,
I need to create some files with specific content during the installation of my application.
I'm using VB 5.0.
Can I do this with VB's Setup Wizard or P&D Wizard or do I need to create my own installation program?
Welcome to VB Forums!
You definately can modify the setup wizard since it's VB code and I've done it myself. Just look for Setup1.vbp.
Ok I saw it!
However, when trying to execute it the following message appears: "Invalid command-line parameters. Unable to continue".
May be the project name is missing as a parameter, is this correct?
How can I test the program, inside VB and also the executable (setup1.exe)?
Thank you
If you read the comments in the Form_Load() in the frmSetup1 form, you will get your anser:Quote:
Originally Posted by myn01
VB Code:
' 'Uncomment these three lines for debugging. To debug: '1) Rebuild Setup1.exe and rebuild the cab file ' to include the new Setup1.exe. '2) Run setup.exe against the new cab '3) When the message box appears, open the Setup1 project ' in VB, paste the command line from the clipboard into the ' Project/Properties/Make/Command Line Arguments field. '4) F5 in VB. ' 'Clipboard.Clear 'Clipboard.SetText Command$ 'MsgBox Command$
I think I have a different project and I'm not sure if this one that I have is the project for SETUPWIZ.EXE... I don't have the lines that you mentioned.
I don't want to bother you with this but, could you zip the files of the original project and post it here or send it to me by email?
Thank you in advance.
Are you sure you don't have it ?
The project on my computer is here:
C:\Program Files\Microsoft Visual Studio\VB98\Wizards\PDWizard\Setup1
Those lines are not in my Setup1 project either. Here is the beginning of my frmSetup1.frm.
VB Code:
Private Sub Form_Load() ' ' Most of the work for Setup1 takes place in Form_Load() ' and is mostly driven by the information found in the ' SETUP.LST file. To customize the Setup1 functionality, ' you will generally want to modify SETUP.LST. ' Particularly, information regarding the files you are ' installing is all stored in SETUP.LST. The only ' exceptions are the Remote Automation files RacMgr32.Exe ' and AutMgr32.Exe which require special handling below ' with regards to installing their icons in a special ' program group. ' ' Some customization can also be done by editing the code ' below in Form_Load or in other parts of this program. ' Places that are more likely to need customization are ' documented with suggestions and examples in the code. ' Const strEXT_GRP$ = "GRP" 'extension for progman group Const SW_HIDE = 0 Dim strGroupName As String 'Name of Program Group Dim sFile As FILEINFO 'first Files= line info Dim oFont As StdFont gfRegDAO = False On Error GoTo MainError SetFormFont Me 'All the controls and the form are sharing the 'same font object, so create a new font object 'for the form so that the appearance of all the 'controls are not changed also Set oFont = New StdFont With oFont .Size = 24 .Bold = True .Italic = True .Charset = Me.lblModify.Font.Charset .Name = Me.lblModify.Font.Name End With Set Me.Font = oFont ' 'Initialize string resources used by global vars and forms/controls ' GetStrings ' 'Get Windows, Windows\Fonts, and Windows\System directories ' gstrWinDir = GetWindowsDir() gstrWinSysDir = GetWindowsSysDir() gstrFontDir = GetWindowsFontDir() ' ' If the Windows System directory is a subdirectory of the ' Windows directory, the proper place for installation of ' files specified in the setup.lst as $(WinSysDest) is always ' the Windows \System directory. If the Windows \System ' directory is *not* a subdirectory of the Windows directory, ' then the user is running a shared version of Windows. In ' this case, if the user does not have write access to the ' shared system directory, we change the system files ' destination to the windows directory ' If InStr(gstrWinSysDir, gstrWinDir) = 0 Then If WriteAccess(gstrWinSysDir) = False Then gstrWinSysDir = gstrWinDir End If End If ' ' The command-line arguments must be processed as early ' as possible, because without them it is impossible to ' call the app removal program to clean up after an aborted ' setup. ' ProcessCommandLine Command$, gfSilent, gstrSilentLog, gfSMS, gstrMIFFile, gstrSrcPath, gstrAppRemovalLog, gstrAppRemovalEXE gfNoUserInput = (gfSilent Or gfSMS) AddDirSep gstrSrcPath ' ' The Setup Bootstrapper (SETUP.EXE) copies SETUP1.EXE and SETUP.LST to ' the end user's windows directory. Information required for setup such ' as setup flags and fileinfo is read from the copy of SETUP.LST found in ' that directory. ' gstrSetupInfoFile = gstrWinDir & gstrFILE_SETUP 'Get the Appname (this will be shown on the blue wash screen) gstrAppName = ReadIniFile(gstrSetupInfoFile, gstrINI_SETUP, gstrINI_APPNAME) gintCabs = CInt(ReadIniFile(gstrSetupInfoFile, gstrINI_BOOT, gstrINI_CABS)) If gstrAppName = vbNullString Then MsgError ResolveResString(resNOSETUPLST), vbOKOnly Or vbCritical, gstrSETMSG gstrTitle = ResolveResString(resSETUP, "|1", gstrAppName) ExitSetup Me, gintRET_FATAL End If gstrAppExe = ReadIniFile(gstrSetupInfoFile, gstrINI_SETUP, gstrINI_APPEXE) gstrTitle = ResolveResString(resSETUP, "|1", gstrAppName) If gfSilent Then LogSilentMsg gstrTitle & vbCrLf Dim lChar As Long gsTEMPDIR = String$(255, 0) lChar = GetTempPath(255, gsTEMPDIR) gsTEMPDIR = Left(gsTEMPDIR, lChar) AddDirSep gstrSrcPath gsCABNAME = gstrSrcPath & ReadIniFile(gstrSetupInfoFile, gstrINI_BOOT, gstrINI_CABNAME) gsCABNAME = GetShortPathName(gsCABNAME) gsCABNAME = gstrWinDir & BaseName(gsCABNAME) gsTEMPDIR = gsTEMPDIR & ReadIniFile(gstrSetupInfoFile, gstrINI_BOOT, gsINI_TEMPDIR) AddDirSep gsTEMPDIR ' ' Display the background "blue-wash" setup screen as soon as we get the title ' ShowMainForm ' ' Display the welcome dialog ' ShowWelcomeForm ' ' If this flag is set, then the default destination directory is used ' without question, and the user is never given a chance to change it. ' This is intended for installing an .EXE/.DLL as a component rather ' than as an application in an application directory. In this case, ' having an application directory does not really make sense. ' If ReadIniFile(gstrSetupInfoFile, gstrINI_SETUP, gstrINI_FORCEUSEDEFDEST) = "1" Then gfForceUseDefDest = True End If ' ' Read default destination directory. If the name specified conflicts ' with the name of a file, then prompt for a new default directory ' gstrDestDir = ResolveDestDir(ReadIniFile(gstrSetupInfoFile, gstrINI_SETUP, gstrINI_APPDIR)) While FileExists(gstrDestDir) = True Or gstrDestDir = vbNullString If MsgError(ResolveResString(resBADDEFDIR), vbOKCancel Or vbQuestion, gstrSETMSG) = vbCancel Then ExitSetup Me, gintRET_FATAL End If If gfNoUserInput = True Then ExitSetup Me, gintRET_FATAL Else ShowPathDialog gstrDIR_DEST End If Wend ' ' Ensure a trailing backslash on the destination directory ' AddDirSep gstrDestDir Do ' ' Display install button and default directory. The user ' can change the destination directory from here. ' ShowBeginForm ' ' This would be a good place to display an option dialog, allowing the user ' a chance to select installation options: samples, docs, help files, etc. ' Results of this dialog would be checked in the loop below ' 'ShowOptionsDialog (Function you could write with option check boxes, etc.) ' ' ' Initialize "table" of drives used and disk space array ' InitDiskInfo SetMousePtr vbHourglass ShowStaticMessageDialog ResolveResString(resDISKSPACE) ' ' For every section in SETUP.LST that will be installed, call CalcDiskSpace ' with the name of the section ' CalcDiskSpace gstrINI_FILES 'CalcDiskSpace "MySection" 'CalcDiskSpace "MyOtherSection" ' ' If you created an options dialog, you need to check results here to ' determine whether disk space needs to be calculated (if the option(s) ' will be installed) ' 'If chkInstallSamples.Value = TRUE then ' CalcDiskSpace "Samples" 'End If ' HideStaticMessageDialog SetMousePtr vbDefault ' ' After all CalcDiskSpace calls are complete, call CheckDiskSpace to check ' the results and display warning form (if necessary). If the user wants ' to try another destination directory (or cleanup and retry) then ' CheckDiskSpace will return False ' Loop While CheckDiskSpace() = False ' ' Starts logging to the setup logfile (will be used for application removal) ' EnableLogging gstrAppRemovalLog ' ' Should go ahead and force the application directory to be created, ' since the application removal logfile will later be copied there. ' MakePath gstrDestDir, False 'User may not ignore errors here ' ' Create the main program group if one is wanted/needed. ' Const fDefCreateGroupUnderWin95 = False ' ' If fDefCreateGroupUnderWin95 is set to False (this is the default), then no ' program group will be created under Win95 unless it is absolutely necessary. ' ' By default under Windows 95, no group should be created, and the ' single program icon should be placed directly under the ' Start>Programs menu (unless there are other, user-defined icons to End Sub
The way I always tested it was to first before I did anything to copy the existing Setup1.exe and then just make a new exe and run it.
Yes, this is the project that I have. Is it the right one?
I don't have PD Wizard.
I not sure but the name may have changed to the P&D Wizrad with the release of VB6.
Weird... this is what I have:
VB Code:
Private Sub Form_Load() ' ' Most of the work for Setup1 takes place in Form_Load() ' and is mostly driven by the information found in the ' SETUP.LST file. To customize the Setup1 functionality, ' you will generally want to modify SETUP.LST. ' Particularly, information regarding the files you are ' installing is all stored in SETUP.LST. Exceptions include ' the Remote Automation files RacMgr32.Exe and AutMgr32.Exe ' and special redistributable packages such as mdac_typ.exe. ' These require special handling below. ' ' Some customization can also be done by editing the code ' below in Form_Load or in other parts of this program. ' Places that are more likely to need customization are ' documented with suggestions and examples in the code. ' ' 'Uncomment these three lines for debugging. To debug: '1) Rebuild Setup1.exe and rebuild the cab file ' to include the new Setup1.exe. '2) Run setup.exe against the new cab '3) When the message box appears, open the Setup1 project ' in VB, paste the command line from the clipboard into the ' Project/Properties/Make/Command Line Arguments field. '4) F5 in VB. ' 'Clipboard.Clear 'Clipboard.SetText Command$ 'MsgBox Command$ Const fDefCreateGroupUnderWin95 = False Dim strGroupName As String 'Name of Program Group Dim oFont As StdFont Dim lChar As Long Dim cIcons As Integer ' Count of how many icons are required. Dim cGroups As Integer ' Count of how many groups are required. Dim fCreateGroup As Boolean Dim iLoop As Integer Dim sUCASEStartMenuKey As String Dim sUCASEProgramsMenuKey As String Dim sGroup As String Dim strRemAutGroupName As String Dim strPerAppPath As String Dim iRet As Integer gfRegDAO = False On Error GoTo MainError SetFormFont Me 'All the controls and the form are sharing the 'same font object, so create a new font object 'for the form so that the appearance of all the 'controls are not changed also Set oFont = New StdFont With oFont .Size = 24 .Bold = True .Italic = True .Charset = lblModify.Font.Charset .Name = lblModify.Font.Name End With Set Font = oFont ' 'Initialize string resources used by global vars and forms/controls ' GetStrings ' 'Get Windows, Windows\Fonts, and Windows\System directories ' gstrWinDir = GetWindowsDir() gstrWinSysDir = GetWindowsSysDir() gstrFontDir = GetWindowsFontDir() ' ' If the Windows System directory is a subdirectory of the ' Windows directory, the proper place for installation of ' files specified in the setup.lst as $(WinSysDest) is always ' the Windows \System directory. If the Windows \System ' directory is *not* a subdirectory of the Windows directory, ' then the user is running a shared version of Windows. In ' this case, if the user does not have write access to the ' shared system directory, we change the system files ' destination to the windows directory ' ' Avoid Option Compare Text and use explicit UCase comparisons because there ' is a Unicode character (&H818F) which is equal to a path separator when ' using Option Compare Text. If InStr(UCase$(gstrWinSysDir), UCase$(gstrWinDir)) <> 1 Then If Not WriteAccess(gstrWinSysDir) Then gstrWinSysDir = gstrWinDir End If End If ' ' The command-line arguments must be processed as early ' as possible, because without them it is impossible to ' call the app removal program to clean up after an aborted ' setup. ' #If SMS Then ProcessCommandLine Command$, gfSilent, gstrSilentLog, gfSMS, gstrMIFFile, gstrSrcPath, gstrAppRemovalLog, gstrAppRemovalEXE gfNoUserInput = (gfSilent Or gfSMS) #Else ProcessCommandLine Command$, gfSilent, gstrSilentLog, gstrSrcPath, gstrAppRemovalLog, gstrAppRemovalEXE gfNoUserInput = gfSilent #End If AddDirSep gstrSrcPath ....
Here's the whole project:
Thank you. I tried it but it didn't work because I'm using VB 5.0 and there are some compatibility issues with VB60.
So I'll try to use the setup project included in VB 5.0 (the one that posted MartinLiss).
I still cannot pass that "Invalid command-line parameters" message.
I've copied a SETUP.LST file with a couple of files to copy, in the same folder of the compiled setup.exe, but it still appears...
How can I solve this?
This:
Is STILL valid, even for the VB5 project...VB Code:
' 'Uncomment these three lines for debugging. To debug: '1) Rebuild Setup1.exe and rebuild the cab file ' to include the new Setup1.exe. '2) Run setup.exe against the new cab '3) When the message box appears, open the Setup1 project ' in VB, paste the command line from the clipboard into the ' Project/Properties/Make/Command Line Arguments field. '4) F5 in VB. ' 'Clipboard.Clear 'Clipboard.SetText Command$ 'MsgBox Command$
To make that more understandable:
1) Copy and paste at the beginning of the code those lines:
2) compile the setup project, and override the old Setup1.exe with the new compiled oneVB Code:
Clipboard.SetText Command$ MsgBox Command$
3) Run the setup.exe with the project that you need to run it on...
4) When you get the message box, you can paste from the clipboard, the parameters passed to it.
5) Paste that string (parameters) into the Setup1 project "Project/Properties/Make/Command Line Arguments"
THEN, you can run the setup project from the Visual Basic Interface
What should be "the project that you need to run it on"?
From outside and inside VB, I've tried putting the .vbp file and also setup.lst but the message still appears...
May be I'm running the setup.exe in a wrong way.
myn01,
Why are you going through this madness. Most up-to-date installers will allow you to create additional files and content without tearing the source code apart. Why on earth would you need to do this?????
The content of this additional file is a encrypted string that the program will use to run, and if, for example, the file is already in the computer, no further installations of the program must be allowed.
I don't know if some installer can do this...
That should be a function of your app not the installer. I do that all the time. You are creating unneccessary headaches and tying your self to an out-dated installer that will never be updated. I really don't think that is in your best interest.
This is for a trial program.
I'll put some expiration date information, in a hidden file, when I install the program to avoid using the registry that can be easily searched.
This way if you uninstall the application, this hidden file is already in the computer and cannot be installed again, unless I send a program to extend the period.
There are countless ways to do this without re-inventing the wheel. That is still a function of the application not the installer. Each app should have it's own constraints. The installer will only create one constraint for all apps (maybe you will create more than one). You are locking yourself out before you even start.
My sugestion would be to check out Inno Setup (along with **********). There are all sorts of third party tools for exactly what you need to do and you don't have to re-invent the wheel. There is a tool that manages your TRIAL period software with software codes etc...
Do some research on theses things before you terminate your life-line to the current world...
Look in my signature for ********** and Inno Setup. Check out the third-party tools for Inno Setup and other tools. You will be surprised on what you find for a UP-DATED app.
Also please read Installer Problems in my signature.
Could you please give me an example about what to put in command-line to execute the program?
Could you clarify... What command line? I never mentioned a command line. What program????? :confused: :confused: :confused: :confused:
OK, let's start form the beginning...Quote:
Originally Posted by myn01
1) put the following 2 lines in the Form_Load() of Setup1 form
2) Compile the setup program. (From File menu, and choose "Make Setup1.exe")VB Code:
Clipboard.SetText Command$ MsgBox Command$
------------------------
3) Use the "Package & Deployment Wizard", and make a setup for the project that YOU made.
4) If you look at the directory where the setup/installation is build, you will see a directory "Support"
In that directory you will see a "SETUP1.EXE".
COPY the Setup1.exe (the one you compiled in step 2), and OVERRIDE the Setup1.exe from the Support/Setup1.exe of the installation.
5) RUN the installation/setup.exe
6) You will get the message box (from step 1), and you will have the parameters in the clipboard also.
7) Now go back to the Setup1 project, and paste the parameters in "Project/Properties/Make/Command Line Arguments"...
From that point on, you can run the Setup/installation from VB, so you should not get this error anymore: "Invalid command-line parameters. Unable to continue".
An you will be able to modify the Setup project to make your file you were talking about.
When done modifying the Setup Project, you have to comment the lines
Clipboard.SetText Command$
MsgBox Command$
And make the EXE of it, then replace the Setup1.exe in the installation/Support/Setup1.exe again.
Then you can publish the intallation to your users.
Finally I've got it!
Thank you