Removing program settings with nullsoft uninstaller - c#

I have a C# program that is installed using Nullsoft installer script and I have discovered that the program is littering files :) .
The program is using:
Properties.Settings.Default.Save
to store settings. These settings seems to end up in a folder with a very nontrivial name like:
$user/appdata/local/$publisher/myprogram_Url_sad546a5s4d6a5sd1adsd6/$version/
So my question is:
How do I find this name from NullSoft so I can remove the files?
A quick and dirty solution would of course be to remove every older containing the name "myprogram" but that would prevent having several versions of the program.

You can search for files/folders with the ${Locate} "$localappdata\$publisher" "/L=D /G=0 /M=myprogram_*" MyCallbackfunc macro and check in MyCallbackfunc if that folder contains a $version folder. You can also call FindFirst directly if you don't want to use a macro...

Related

Add sound files to build, and find path? C#

In my console based program I am wanting to use a sound file at the end of it, I was able to get that to work however when I publish the project and try send it to others I can't get it to include the sound file, how would I accomplish this?
There are many potential solutions. One of them could be embedding the sound file as a resource.
I recommend writing an installer. Sooner or later you'll need one anyway. Maybe you have seen one of them before. It's that thing that always asks for administrator permissions and you click on the Next button until everything is installed properly.
I'd like to point you to InnoSetup, which is a free, text based installer. That's great to use with version control systems. I especially like it, because I can modify every necessary detail in my build script: just write a line of text to that file with the version number and it simply works.
It's very simple to learn and there are plenty of examples available online. The documentation is great and complete.
What you need is the [Files] section, something like
[Files]
Source: "MYPROG.EXE"; DestDir: "{app}"
Source: "MYSOUND.WAV"; DestDir: "{app}"
And then you can just access the music from the same directory as your executable.
See also the question "List of InnoSetup pages in order with parameters and screenshot" which gives you an impression of the capabilities of InnoSetup.
Add the WAV file to your project (right-click your project in Solution Explorer, select Add | Existing Item...)
In Solution Explorer go to the properties for the file you added,
and for Build Action select "Embedded Resource".
Add the following code to your console app:
Code:
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream s = a.GetManifestResourceStream("<assemblyname>.<wavfilename>.wav");
SoundPlayer player = new SoundPlayer(s);
player.PlaySync();
replacing <assemblyname> with the name of your assembly, and <wavfilename> with the name of the WAV file that you added.
For my test code, that line looked like this:
System.IO.Stream s = a.GetManifestResourceStream("ConsoleApp3.tada.wav");
because my assembly name is "ConsoleApp3" and the wav file was called "tada.wav".
Note you will also need to add a using System.Media; to the source code file.

Edit App-V archive file

I'm trying to replace a file in a .appv archive file.
I know you can just rename the file to .zip extract and replace the file.
But when I zip it again and rename it back to .appv the file size is different and i get the following error when opening.
Im trying to change the AppxManifest.xml file or a setting within that without having to open via the UI(cmd, c# or powershell).
Thanks
Open up your sequencer and choose "Modify"
"Update"
Then I am skipping the steps where you upload your .appv file and installer (if you don't need the files from installer, you can always ignore it)
"Continue to modify"
Close the last page and it will automatically jumps to this page
Now, you can open up your package, expand the folder and add files if you want
The best option is to use one of the application packaging tools that supports editing of App-V package. Apart from Advanced Installer that has been already mentioned, take a look at AdminStudio and PACE Suite - both support editing App-V. There may be even more than those two I know.
You cannot zip a package back and expect to work, this is not supported by Microsoft.
Starting with App-V 5.1 the Sequencer from Microsoft can export and import the manifest file from the package, so you can modify it, but from what I know you cannot script this, it must be done from the GUI. The list of powershell cmdlets for the sequencer is quite short.
Also, Advanced Installer can also create and edit App-V packages much easily and faster than the sequencer, but again only from the GUI.
You can also try a free tool, called TweakApp-V, here's an example of you can use it. It has predefined commands to add/delete files and registry.

Install app which uses .dll with IExpress Wizard

I have two applications which will be installed by a single executable. The problem I'm facing is that one of them uses a .dll. And whenever the IExpress package tries to run the first executable it says that the .dll could not be found, even tough I added the .dll inside and outside the package.
There is any way to make it work with IExpress, which has the required characteristics?
There is any alternative to my problem, as a similar software, for instance?
This sounds vaguely similar to this question:
Iexpress is extracting to %temp% folder... How do I prevent this?
As I mentioned in my answer, check: (1) is long file name (LFN) support enabled? and (2) is the .dll actually in the archive?
If checking those things doesn't resolve it, I would use Process Monitor to see which directories the executable is searching to locate the .dll file. It should ideally be looking in the extraction directory (eg %temp%\IXP000.TMP), since that's the current directory when the executable is running.
Of course there are several other utilities that do what IExpress does that you might try instead: 7-Zip, Inno Setup, NSIS, WinRAR, WiX – just to name a few.

Windows Shell: How to associate different xml-files with different apps?

I have many kinds of xml-files (all with extension .xml) with different root element name and namespace. I want to associate each type with a different application and also make it possible to have different file-icons for each type. Can this be done using C# .NET?
The only way to handle this is in a similar way to that which Visual Studio uses to handle .sln files which is the Visual Studio Version Selector. This application is the one that gets associated with .sln files and handles providing an icon and an eventual process to handle the specific .sln file. Assuming you have Visual Studio installed, take a look in the registry at HKEY_CLASSES_ROOT\VisualStudio.Launcher.sln to see how it's done.
So basically you need to:
Write an executable that can decide what to do with .xml files
Register the process as the one responsible for handling .xml files
Place logic in your executable, or in configuration that your executable consumes, that decides what to do on a per file basis.
For icons, take a look at the subkey ShellEx\IconHandler. You'll see that it points to (on an x64 machine with Visual Studio 2010 installed) HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{9A2B23E4-2A50-48DB-B3C3-F5EA12947CB8} which lists under InprocServer32 a DLL that is responsible for providing icons for files, in this instance C:\Program Files (x86)\Common Files\Microsoft Shared\MSEnv\VSFileHandler.dll. You'll need to implement a similar DLL that shares the configuration/logic of your launcher process to determine what icon to show on a per file basis.
The usual caveat: Writing shell extensions in managed code has always been a big "no no" because shell extensions get loaded into any process that shows the common file dialogs. This can cause merry chaos as, up until .net 4.0, only one version of the CLR can be loaded into a process, so you have to be very sure before doing this. Given that .net 4.0 supports in-process side by side, this may not be an issue for you.
No. To Windows, an XML file is an XML file. The OS doesn't look inside to see what namespace is associated with it; it's just an XML file.
Windows associates file types with their extension, so again, all XML files are XML files. You can see this for yourself: rename a normal .txt file that contains absolutely no XML, and then refresh the view of it's folder in Explorer. You'll see the icon change from a text file image to an XML file image.
There isn't a way that you can do this without having custom extensions or an intermediary program.
Maybe one option would be to have a custom applicaiton which is assigned to handle XML files. When this is program is spawned it works out what the "type" of the file is using one of the XML tags and spawns the correct process accordingly. It's unlikely, however that you can give different "types" different icons.

Burn setup project to CD

I've never burnt a visual studio program to a CD before. I've made a setup project with all my program files, and it works fine. Do I simply need to burn the following installer files onto the CD and give it to someone?
The installer is a folder containing:
-DotNetFX35 (Folder): Contains .net requirements for my program.
-WIndowsInstaller3_1 (Folder): WindowsInstaller-KB893803-v2-x86.exe
-setup.exe
-My Installer.msi
Sorry for the seemingly easy question. I'm double checking as I have one CD and an impatient employer.
Thanks!
You will need to add an autorun.inf if you want autorun to work. Put the contents of the install folder at the root of the disk, create a simple text file called "autorun.inf" at the root of the disk and add the following contents:
[autorun]
open=setup.exe
This will instruct the operating system to run setup.exe when the disk has inserted (and consented to it).
There are other tricks you can do with autorun.inf too. As many have mentioned in the comments, the best way to test this is by creating an ISO and testing it, or buying a stack of blank disks. They are pretty cheap these days.
If you don't care about auto run, then you can put anything on the disk itself, it's just content, the user would just need to go into the contents himself and click setup.

Categories

Resources