How can I programmatically uninstall a font in Windows? - c#

I have tried searching for an answer to this but I cannot find anything on SO which is much to my surprise, I thought for sure this must have been asked in the past...
I have a requirement to remove/uninstall a font from the windows directory using a C# .Net (version 4) application. The font in question is usually found somewhere like: C:/Windows/Fonts
My initial thoughts was that I can just delete the file (using File.Delete(...)), but I am unsure if this is enough? My worry comes from the installation of fonts... if you copy a file to the font folder then you get a dialog saying the font is installing.
If deleting the file is enough then I am happy to do so, or is their a more recommended way that this should be done?
If it makes any difference then the OS is Windows XP and the fonts are custom fonts but I am not sure what the original install method was
As clearly posting on StackOverflow with a tag of C# isn't apparently enough... I want to do this from a C# .Net (version 4) application.

arccording to this http://support.microsoft.com/kb/314960 deleteing the font file should be enough

Related

Select .app Files in MacOS File Browser using C#/DotNet

I'm working on a MacOS application built in Unity3D. I'm using a native file browser plugin to open native MacOS file dialogs for selecting files.
In order to generate PDFs, my app relies on using Chromium's Headless/command line functionality.
On Windows, I can easily get the path to the included Microsoft Edge as that's standard, but on Mac, unless I guess and check (which I already do), there isn't a way to guarantee a Mac user has a Chromium-based browser installed.
So I intend on allowing the user to set the path manually by selecting the .app file with a file dialog. But even when I specify .app to be a valid extension, they still don't appear selectable.
I assume this is some sort of MacOS-specific limitation or default permissions, though I can't find much info on this online.
Using C#/DotNet s there any way of allowing this behavior as needed?
For some more info: I'm just running the application using System.Diagnostics.Process.Start() with command line arguments.
Based on my experiments searching for Google Chrome (though Edge or Opera are just as usable), the path I'm looking for is:
/Applications/ {{APP NAME}}.app/Contents/MacOS/{{APP NAME}}
Because Contents isn't accessible by most users, I figured I would just automatically go in and grab the binary with the correct name.
I know I could include some lightweight version of ChromeDriver with my app, but I'd rather keep everything as self-contained as possible, especially as so many people already have Chrome (or Opera, Edge, etc) installed. The challenge is that not everyone has it installed in the same place, hence my need to make it customizable.
Any ideas or help would be appreciated!
Thanks!
After doing some testing: It seems that this limitation is only when running inside the Unity Editor. Once the app is built into a standalone Mac application, the file dialog does allow the selection of .app files and it works as expected.
Not a 100% solution to this problem, but definitely clears up some concerns.

How can I reduce the size of a 1GB MSI file using Orca?

I have written a C# WPF application. I have now created an MSI that will install the application. However, the file size is gigantic. The application contains many video and image files, which have combined to make the MSI a whopping 1GB in size.
I have tried to reduce the file size with Orca. I have used "Save As" to create a brand new MSI and have also exported the database tables and then imported them to another MSI. In both cases, the file size is reduced to less than 1MB, but then the installer doesn't work at all. Looks like it's not compressing the content, but rather removing it entirely.
How can I use Orca to reduce the MSI file size without stopping the installation from actually working? If there's another way to do it, I'm open to any suggestions.
First, build your installation package with the cabs external (not embedded) in your MSI. That will show you how large the MSI is in relation to the rest of your installation. Chances are you'll find the MSI size is insignificant compared to the content in the cabinet files. My guess is that the video and images are not compressing well in the cabinets.
If my hypothesis is correct, then your goal is to find the optimal compression for the files in the cabinets.
Note: If you use the WiX Toolset to build your MSI, we already do the tricks to ensure the MSI portion is as small as possible. You are not likely to find significant optimizations on top (and if you do, let us know at wix-devs#lists.wixtoolset.org, we'd love to improve :).
Online: Can you put some videos online? Youtube? Easier to manage and update over time as well. And easier access for people who do not have your product downloaded? Better for marketing? It depends if the content is help material or the actual product you are trying to sell. You can install low-res versions of the videos and images as a fallback mechanism if Internet is not available? Maybe see this older answer?
Compression: You are using WiX? No? On selecting an MSI tool. If you are using WiX, then you can try to use the highest compression level for the MSI? (MSI compression levels). This means you have to rebuild it with the new setting. There are alternative elements to do so:
Media Element (CompressionLevel)
MediaTemplate Element (CompressionLevel)
WiX: In WiX it is easy to set the compression level:
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />
A little crash course in minimal WiX markup to compile an MSI can be found here: Transparent aluminum! The markup towards the bottom with inline comments is usually enough for people to get going. See other resources here: installdude.com (my own experimental site - expand help section in left navigation pane). Also check "WiX Samples" in quick search section towards top.
I forgot the WiX quick-start tips answer.
Links:
What is the compression method used by MSI files?
How to generate msi/exe installer file in visual studio 2017 for a project of over 24 GB files?

Segoe UI Symbol Windows 7

Had anyone been able to release wpf applications to Windows 7 users and use this font? I have looked all over the place and can't see a solution.
I have downloaded the font family and placed as a resource in my project
FontFamily="/Helpdesk;component/Fonts/seguisym.ttf#Segoe UI Symbol"
This works on my computer however taking off the Segoe UI Symbol in the above gives me a square box.
Any help would be gratefully accepted.
Scott
According to http://www.microsoft.com/typography/fonts/font.aspx?FMID=2027 it's already part of Windows7.
Are you testing against a corporate or an otherwise modifed version of Windows7?
it looks like there is an update for it;
http://support.microsoft.com/kb/2729094
and also there is a similar question to yours in here;
http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_update/segoe-fonts-appear-as-boxes-after-kb2729094/dbafb137-211e-425e-93f8-d3259d3cee92?auth=1
it say it may related to conflicted with updates and another software.
I had the same problem and finally found a way to use the newer version of "Segoe UI Symbol" even when older version is installed (i.e. on Windows 7). The idea is to create a copy of the font file with a different name. This approach works also in ClickOnce installation and requires no bootstrapping.
It is posted on this link: Embedded Font in WPF not working

Problem with "add reference" under Visual C# 2008 Express Edition after switching from XP to Windows 7

I suddenly have a big problem I didn't have before.
In my current project, I want to add a reference to "Microsoft.Office.Interop.OneNote". When I open the .NET tab of the "Add Reference" dialog, the "Microsoft.Office" assemblies aren't available like they used to be; on my machine, the next assembly after "Microsoft.JScript" is called "Microsoft.SqlServer.ConnectionInfo"; no trace of any of the "Microsoft.Office" assemblies. I used to be able to do this under Windows XP, but made the switch to Windows 7 a couple of weeks ago. I don't know whether that has anything to do with it.
I already checked whether the assemblies are installed on my machine, but I found all of the office assemblies safe and sound in "windows\assembly". Oddly enough, the reference to "Microsoft.Office.Interop.OneNote" in a previous project continues to work; I just can't add any new references with the "add references" dialog, as they aren't shown in the list of .NET references anymore.
Any help will be appreciated.
Kind regards,
Rainer
Pardon the perhaps stupid question.
Have you installed MS Office since you switched from XP to windows 7?
I'm only asking because I forgot to install it after the same upgrade and I spent a good half hour last week trying to figure out why my project that used Powerpoint was complaining.
the content of the dialog you see with ´Add Reference´ is actually not loaded from the GAC. It´s some registry-folder settings for visual studio.
Maybe you installed in such a way that the libraries are not part of this set. Then VS will not show them in the dialog.
for more info on how to add entries to your ´add reference´ dialog see
http://support.microsoft.com/kb/306149
I think I have got it. For the benefit of anyone who runs into the same problem, there was an interesting lesson to be learned about some lesser known features of Windows:
The link Marvin mentioned above...
http://support.microsoft.com/kb/306149
...says:
To display your assembly in the Add Reference dialog box, you can add a registry key, such as the following, which points to the location of the assembly
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssemblies]#="C:\\MyAssemblies"
where MyAssemblies is the name of the
folder in which the assemblies reside.
So I did just that, replacing "myAssemblies" with "C:\Windows\Assembly".
Nothing happened.
I changed the value of the empty standard key to "C:\Windows\Assembly".
Nothing.
I tried some variations of the theme: double backslashes, ending with a backslash, the return of the son of the backslash. No cigar.
So I tried to work the other way around by trying to copy the necessary dll from c:\windows\assembly into one of the directories that are being watched by the "add reference" dialog. On my machine, these paths are conveniently listed under
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\v2.0.50727\AssemblyFoldersEx]
When I tried to copy the dll from c:\windows\assembly, there was no "copy" option in the context menu. Drag'n'drop didn't work either. For this problem, I found several alternative solutions here:
http://geekswithblogs.net/pavelka/archive/2006/05/05/WindowsExplorerAndTheGlobalAssemblyCache.aspx
I opted for solution 2:
Add DisableCacheViewer Registry Key
Another way to disable to create a new dword key under HKLM\Software\Microsoft\Fusion\ with the nane DisableCacheViewer and set it’s [DWORD] value to 1.
After I had done that, I could see the real directory structure below c:\windows\assembly; almost each and every dll has its own subdirectory. As soon as DisableCacheViewer was set, I could
traverse the real directory tree that was hidden under c:\windows\assembly
copy dlls and paste them to one of the directories listed under "AssemblyFoldersEx"
deduce the correct path to my dlls and create a fresh key to that path just below "AssemblyFoldersEx".
Thank you very much to everyone who answered, and a special thanks goes to hannes pavelka, whose blog entry helped to solve my problem.
P.S.: I'm almost certain that I never had to do this under Windows XP. IIRC, all of the interop assemblies were available without this kind of registry fumbling.

Best solution for making an Autorun application?

For my work I need to create a Autorun application for a CD for our client. The problem is all I'm a C# programmer by trade and .NET does not make for the best autoruns since not all computers will have .NET installed on them.
What is a good solution that will work on Win98-Vista computers?
The answer to this question is really one of preference. Technically, anything can be instructed to open as an autorun. The autorun.inf file is simply an instruction file that Windows knows how to read in order to determine what it should do when a CD is inserted. That could be an application (written in any language you choose), a powerpoint presentation, opening a link to a website, etc. As long as you follow the rules of the autorun.inf file:
http://autorun.moonvalley.com/autoruninf.htm
There are many small autorun-utils (some free) that are configurable. I would go for one of those.
http://www.ezau.com/latest/articles/083.shtml
You need two things:
Follow this steps (http://support.microsoft.com/kb/324733 OR http://support.microsoft.com/kb/888469)
When your application is ready (with bootstrapper), you'll have to create a autorun.inf file on CD root path. Search 'autorun.inf create' on your favorite Search Engine.
It is possible using Mono's bundling feature:
"The resulting executable is self contained and does not need the Mono runtime installed to run."
Mono is an Open Source .Net clone and should be able to run most .Net applications. See "Bundles" section here: http://www.mono-project.com/Guide:Running_Mono_Applications
You could use .hta file on CD to launch as splash page, and from there detect if .NET is installed (using COM from HTA file) and then run your custom executable.
.hta files are what Microsoft SQL Server (and most of their others) installation cd uses from memory, easy to make them look very professional (its just html in the background basically)
You can include the runtime with the CD, but you'll have to install it before running your app. You might look into just popping open an html file from the CD.
Otherwise, you can look at writing a small native program that can prompt to install the runtime if it's not there, or run your .NET app if it is.
Try Delphi; it's by far the best way to create native win32 application nowadays.
It creates slick stand-alone .exe files with rich GUI's that don't need any runtime libraries or other annoying dependencies. Works on any windows machine.
There was a program from Macrovision called "Demoshield" that worked well back in the day. I'm not sure if its available anymore, but it was an alright program for creating the auto-run programs.

Categories