1 Attachment(s)
[RESOLVED] Setup and conditions with .Net installer?
Hi everyone, I searched everywhere but I can’t find the answer to my problem. I am upgrading the Screen Shot application in my signature and I decided to add a option in the .Net installer to install the shortcut to the desktop. For example if the user checks the checkbox then the shortcut is installed otherwise it is not. How would I go about this? I used some custom actions for some other staff but for this I need to set a condition for the shortcut, but the shortcut doesn’t have condition property.
Thanks for any input!
VBDT
Re: Setup and conditions with .Net installer?
Quote:
Originally Posted by VBDT
the shortcut doesn’t have condition property.
Exactly. You'll have to create your shortcut's in code using a Custom Action. That way you can add them only under certain conditions. VS Setup projects are relatively limited when it comes to customisation.
Re: Setup and conditions with .Net installer?
Thanks Jmcilhinney for the reply and suggestion. I guess I’ll pass this one.;) Sorry I can’t give you rep, I need to spread some before I give it to you.
Re: Setup and conditions with .Net installer?
Is this for a non-vs setup project solution? I could have sworn that you can do it in the "User's Desktop" section of the setup. Just right click on the right hand pane and the context menu popups with "Create New Shortcut"
Re: Setup and conditions with .Net installer?
Quote:
Originally Posted by RobDog888
Is this for a non-vs setup project solution? I could have sworn that you can do it in the "User's Desktop" section of the setup. Just right click on the right hand pane and the context menu popups with "Create New Shortcut"
That's quite correct Rob, but the problem here is that that shortcut is created no matter what. There's no way to give the user the option whether to create the shortcut or not, as many installers do.
Re: Setup and conditions with .Net installer?
Yup, just realized it too as I was thinking about the condition to conditionally create the User Desktop folder instead of the shortcut file.
Re: Setup and conditions with .Net installer?
Hi Rob, this is vs setup project. I don’t have any problems for adding the shortcut but the problem is that it seems I can’t give the user an option to not install the shortcut if they choose. I hope in the next vs version MS would include this functionality in installer.
Thanks for replies!
Re: Setup and conditions with .Net installer?
No prob. Just use the custom action like John said and retrieve the checked value or unchecked value from the checkbox dialog and execute your action.
Re: Setup and conditions with .Net installer?
Quote:
Originally Posted by RobDog888
Yup, just realized it too as I was thinking about the condition to conditionally create the User Desktop folder instead of the shortcut file.
Good suggestion but I tried it too and it didn’t work. May be I am not setting the condition statement right, I don’t know. But when I think about it, it makes since that it doesn’t work because the user desktop is there and it is not matter if we create the folder or not the shortcut is going to be installed anyways.
Re: [RESOLVED] Setup and conditions with .Net installer?
Actually using a Custom Action may be wrong for this scenerio. Custom actions are only carried out at the end of the installation.
Using the Checkbox Dialog added to your setup (which I believe you are using)....
Quote:
Originally Posted by MSDN Help File
Retrieving User Choices with Checkboxes Dialog Box Properties
When the installer containing the Checkboxes dialog box is run, the user can change the value of any visible check boxes; you can then use that choice to control another phase of installation.
For example, you might create a Checkboxes dialog box that gives the user a choice of installing two optional files, File A and File B. In this case, you would set the Checkbox1Label property to "Install File A" and the Checkbox2Label property to "Install File B". You would also set the Checkbox3Visible and Checkbox4Visible properties to false, since you only need two check boxes.
If you thought that users would usually want to install File A, you could set the Checkbox1Value property to Checked so that it would be checked by default.
In the File System Editor, you would set the Condition property for File A to the value of the Checkbox1Property property, and the Condition property for File B to the value of the Checkbox2Property property.
During installation, the Condition property for each file will be evaluated. If the user checks the check box, the condition will evaluate to true and the file will be installed; otherwise, it will not be installed.
Re: [RESOLVED] Setup and conditions with .Net installer?
Using a Custom Action is the correct choice. When the user checks or not one of the check boxes on your installer dialogue it sets the value of a variable. You can pass that variable value to your InstallerClass and there you decide whether to create the shortcut or not based on that value.
Re: [RESOLVED] Setup and conditions with .Net installer?
Yes that is what I am doing Rob, but the shortcut doesn’t have the Condition property, files do:confused:cool:
Re: [RESOLVED] Setup and conditions with .Net installer?
Quote:
Originally Posted by jmcilhinney
Using a Custom Action is the correct choice. When the user checks or not one of the check boxes on your installer dialogue it sets the value of a variable. You can pass that variable value to your InstallerClass and there you decide whether to create the shortcut or not based on that value.
I do believe that using the Custom Action is the right way but it has some limitation to since I think I tried it before. For example: let say that the user accidentally deletes some file in the application directory, then if I used the installer shortcut and the user double clicks the shortcut the deleted files are being restored. But if I create the shortcut in the installer class then it won’t have that future and I have to restore these files from somewhere.
Re: [RESOLVED] Setup and conditions with .Net installer?
I guess the easy way is not so easy lol.
What about pre-creating the shortcut file with placing % macro paths in the target property?
Re: [RESOLVED] Setup and conditions with .Net installer?
Quote:
Originally Posted by RobDog888
I guess the easy way is not so easy lol.
What about pre-creating the shortcut file with placing % macro paths in the target property?
I defiantly will give it a try Rob and post the result if I come with one. Thanks again guys for your help.
VBDT
Re: [RESOLVED] Setup and conditions with .Net installer?
You could always create the shortcuts the normal way and delete them if the user unchecks the boxes, although that's a bit of a hack. I think you may find that running the app would reinstate the shortcuts each time then though, which can be a very annoying "feature". Also, I think that anyone who accidentally deletes files from a program folder deserves to have to reinstall manually to teach them a lesson for being a bit of a moron.
Re: [RESOLVED] Setup and conditions with .Net installer?
:lol: John you always have a way with words. :)
One more question: Since using the setup project is still a bit cumbersome for your needs, what about some other third party installer program?
Re: [RESOLVED] Setup and conditions with .Net installer?
Quote:
jmcilhinney
Also, I think that anyone who accidentally deletes files from a program folder deserves to have to reinstall manually to teach them a lesson for being a bit of a moron.
I agree!:bigyello:
Quote:
RobDog888
One more question: Since using the setup project is still a bit cumbersome for your needs, what about some other third party installer program?
Well, Rob this application is not for distribution and it is a simple one so I don’t want to spend any money on this.
As I mentioned in my first post I created it and posted in the UtilityBank forum for the members of VBForums to have an easy way of capturing screen shots.
I updated and posted the application in the same thread so if anyone needs it then you can find it in here.
Re: [RESOLVED] Setup and conditions with .Net installer?
We always appreciate the hard work member put into apps so when they post them here for sharing its even more appreciated. :thumb:
Well there are free installers/packagers out there but since it sounds like it was just for convienance so then it seems its going to be too much trouble?
Re: [RESOLVED] Setup and conditions with .Net installer?
You could have a look at NSIS at http://nsis.sourceforge.net/Main_Page, it's free and OpenSource and has a tonne of examples on how to accomplish all sorts of things during and after installs. I haven't used it myself but it looks great. It was started by the WinAmp guys, IIRC.
Gr,
Mightor
Re: [RESOLVED] Setup and conditions with .Net installer?
Quote:
Originally Posted by jmcilhinney
Also, I think that anyone who accidentally deletes files from a program folder deserves to have to reinstall manually to teach them a lesson for being a bit of a moron.
You are assuming that the moron in question will actually learn from it? My experience tells me that most morons will make the same mistake over and over again. I applaud you for your optimism, though!:D
Gr,
Mightor