Programmatically detect if Windows Media Player is installed - c++

Anybody have any advice on how to programmatically detect if Windows Media Player is installed?
I know about the registry setting look up, but don't trust it since it's more than a little misleading (uninstalled may not remove it). And I've considered just launching a video, but an error could be caused by something other than Media Player not being installed, so it's not conclusive either.
Ideally, I'd prefer a solution which could be used from both my C++ application AND my NSIS installer. But my the C++ app is the most important, I'm willing to live with the registry hack in the installer.

Look at the IsInstalled value under key HKLM\Software\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}. It is 1 if installed, 0 otherwise.
See Detecting Windows Media Player from an Application.

(You don't say whether you're checking for an embeddable (i.e. OCX) player to embed in your app or the EXE to launch extenally from your app.)
How about checking the HRESULT on CoCreateInstance against CLSID {22d6f312-b0f6-11d0-94ab-0080c74c7e95} / ProgID "MediaPlayer.MediaPlayer.1" in your app? (CLSIDs from http://technet.microsoft.com/en-us/library/bb676121.aspx)
In your installer just check for HKEY_CLASSES_ROOT\CLSID{22D6F312-B0F6-11D0-94AB-0080C74C7E95}, and perhaps also that the path at the InprocServer32 subkey exists.

If the uninstall fails to remove both the EXE and the registry entry then I highly doubt it uninstalled anything...
So, I would suggest you check the registry under HKLM\Software\Microsoft\MediaPlayer\ and if it exists, grab the value of the Installation Directory or Installation DirectoryLFN (default is %ProgramFiles%\Windows Media Player) and check that wmplayer.exe exists within that directory. If it does, then you will know that WMP is installed.

Related

Outlook: VSTO does not show its initial window

I had developed a VSTO module to Outlook using VB.NET and VS2017-Community.
At the first installation, it asked for an user authorization to install, showing the Product name and the Vendor/Manufacturer data, based on the ClickOnce compilation (I guess).
Everything rans ok...
But now I uninstalled completely this AddIn and, when I call the SETUP again (due to a newer version), the Outlook does not show this window anymore - the Ribbon is updated automatically, my custom ribbon appears, etc.
In other words: my new version is installed into Outlook seemless and runs perfectly; except for the fact of the VSTO window does not appear anymore during the Outlook load (which would be like I saw before at the 1.0.0 version of my software).
I would like to see a CLEAN installation, I mean, exactly what a user which had never installed my software would see.
Some data to enlight the problem:
1- I'm using MSI installation and uninstall. Everything runs 100%.
2- The uninstall clears all the registry keys and the application folder.
3- I saw %User%/AppData/Local/Apps/2.0 folder and, also, there are no references to my project.
4- I open REGEDIT and check the following keys. All of them are cleared (no references to my AddIn):
HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\16.0\Outlook\Resiliency\AddinList
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Outlook\Addins\
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\1x.0\Outlook\Resiliency\DisabledItems
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\1x.0\Outlook\Resiliency\CrashingAddinList
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\1x.0\Outlook\Resiliency\DoNotDisableAddinList
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\1x.0\Outlook\Resiliency\NotificationReminderAddinData
(there are no Local_Machine key created here, my Office is 32-bit not running as Admin/Local_Machine).
So, how can I make a clean installation like I saw before?
I appreciate any help.
I found the solution!
We must clean the references also in:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\1x.0\Outlook\AddInLoadTimes
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSTO\SolutionMetadata
HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSTO\Security\Inclusion (keys and subkeys)
That's it! :)

VS2017 Installer Project - Cannot Make Uninstaller

I have been able to successfully install a simple program using an Installer Project on Visual Studio Community 2017. However, I can't find out how to create a fully working deployable uninstaller for an end user.
The Installer Project was set up to only create an Application Folder (in C:\Program Files...) with the Program .exe, and nothing else. This it does successfully. I would like an installer because later I plan to make some registry keys upon installation.
To test uninstallation, I have run the original .exe file built by the Installer Project with the "Uninstall" option. This removes the Application Folder but does not remove the program from the Add/remove programs list in Windows - Leading me to believe there are other registry entries that have not been removed.
I have tried to uninstall purely from the Add/remove programs list, but then I get an error:
C:\WINDOWS\system32\msiexec.exe
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item."
In Visual Studio, I can click "Uninstall" from the Installer Project right-click menu which does successfully remove both the Application Folder and the Add/Remove Programs Item, but this is not a deployable solution.
Notes:
OS: Windows 10
Using Visual Studio 2017 Community
Looking at the application Folder, there is neither an install nor uninstall .exe file in it. The Installer Project .exe is only in the original build location, and I cannot find how to get a copy in the Application Folder (not sure if a copy there would work).
I have tried configuring the Installer Project as x86 and x64 with no change.
I have tried using both Debug and Release build configurations with no change.
From looking around, WiX seems to have more features and flexibility, but I haven't yet dug into that. Is there an easier solution?
Has this issue occurred to anyone else? My hopes were that Installer Projects were the simple way to learn and handle installation.
Looks like I jumped to conclusions in the comment above, however I think I found the issue: I cannot uninstall the program from the Windows Apps & Features window in System Settings, but uninstalling from Control Panel\Programs\Programs and Features works fine.
When typing in "Remove" using the windows start button, the default item that comes up is "Add or Remove Programs" in System settings (This looks like a Windows 10 thing). When you click that, it forwards you to the "Apps & features window. I am now learning that for some reason this has different functionality than the control panel window. Or maybe it has lower permissions, although I am the admin and only user of this computer...
Because it can be uninstalled from Control Panel, I think this would be the preferred solution. My assumptions about the other window in system settings was my real issue. I just wish the Apps & features window aligned its functionality/permissions with control panel.
I also learned that uninstall is successful when I run msiexec.ex /I{PACKAGEID} in cmd. Not sure how relevant this is, but documenting here.
Installs and uninstalls are transactional, they either work completely or roll back completely. If you do an uninstall but the entry remains in Add/Remove Programs then it's likely that the uninstall did not in fact work.
When you do the install, if it has a UAC elevation dialog then the install is running with elevation and installing files/registry entries to locations prohibited to limited users. Removing files from those locations also requires elevation. You haven't said exactly how your uninstall works, but most likely it requires elevation to succeed, and your program isn't running elevated. If your program uninstalls silently the uninstall will fail silently, so it's possible that your program isn't actually checking that the uninstall worked.
I'd also guess that your Visual Studio session may be running elevated so uninstall from there works fine.
Apart from privileges, an uninstall from a running installed program tends not to work very well because the uninstall process cannot remove your running program or its folder because it's in use. So while you could get it to work (with elevation) you might find that your program and its folder are left behind until the next reboot. If people really want to do this, one of the strategies is to copy an uninstall program to the temp folder and fire it off asynchronously, so everything can be removed.
Uninstalls from Add/Remove Programs&Features generally work fine. Without some context that error message doesn't mean much. It's not a message that comes out of Windows Installer, so it's perhaps coming out of a custom action. Otherwise it may be an issue specific to the test machine.
There is never an uninstall exe in a Windows Installer setup. When you remove a product the system just calls the Windows API to remove the product. Windows Installer is part of the Windows OS with API support for everything that needs doing. Only non-MSI setups require an install and uninstall exe to do anything.
None of these issues seem to be related to your choice of tool. They all create MSI files and if an MSI design is not optimal it doesn't matter what tool you use. There's nothing wrong with WiX, but to install literally a few files it's overkill compared to Visual Studio.

Digital signing halts with the error "SetDllDirectory function in Pyinstaller is not currently supported by Windows UWP applications"

When I try to create a Windows AppX with Advanced Installer at the digital signing stage the program stops saying "The application calls the SetDllDirectory function which is currently not supported by windows UWP applications. A digitally unsigned exe or msi installer works perfectly but the AppX, as not digitally signed, does not run! Is there a work around to this problem? I searched the Pyinstaller docs and also asked a question on the Pyinstaller Google groups. They did not even list my question.
according to Microsoft the SetDllDirectory function which is used by Pyinstaller is currently no supported by UWP and according to Pyinstaller experts there is no provision to change this in the near future. So right now this is not the way to go. If there is anyone who knows something better now is the time to speak up..

Cannot uninstall my tool after adding entry to the 'Uninstall' registry key

I'm developing a simple win32 tool. I'd the tool to be easily uninstalled by the user so I've added a subkey to:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall
called MyTool and added all the necessary keys such as: DisplayName,UninstallString,DisplayVersion,DisplayIcon
So far so good. I can see that during the install process of my tool, the new subkey was added and everything is as expected.
Problem
When I come to uninstall my tool and press uninstall I get the following error:
You do not have sufficient access to uninstall MyTool. Please contact your system administrator
Notes
My process is 32 bit. However, Wow6432Node related topic is irrelevant since I've encounter this issue both in 32 & 64 bit systems.
Question
Did I do something wrong with the way I've added the registry subkey?
This is the kind of time-wasting bugs that are so stupid.
The issue was, believe it or not, the path separator used in key's value: UninstallString.
Generating error
"C:/Program Files (x86)/MyTool/my_tool.exe" /uninstall"
Working
"C:\Program Files (x86)\MyTool\my_tool.exe" /uninstall
Regardless of whether or not it is my fault as a developer, why would windows error out in this case?

Installing iCloud on XP PC

I'm trying to install iCloud on my Windows XP Pro (SP3) PC. Officially it's supported only for Vista and later, but this hack is widely claimed to work:
Open iCloudSetup.exe file and unzip its files including
Navigate to and open the iCloud.msi with Orca.
In the left table select LaunchCondition. Then change in the right table “VersionNT> = 600” to “VersionNT> = 200” and Save.
Run modified iCloud.msi and install.
Run iCloud Control Panel, located in the Windows Control Panel, and set up as you want.
I tried that promising solution in vain. It seemed to successfully install iCloud, but whenever I try to run it I get
this obscure error
After much fruitless searching I've not found out how to proceed from there and would appreciate advice please.
That trick worked with only the firs versions of iCloud Panel, the v1.0.
For the v2.1 doing the trick the installer ran ok, but when trying to run the iCloud Panel it showed the error you're refering to.
I had some computers running with that older version without any problem.
Try downloading the v1.0 version here:
http://icloud-control-panel-for-windows.uptodown.com/descargar/22412
If you want to try the trick with the v2.1 you have the installer here:
http://icloud-control-panel-for-windows.uptodown.com/
Remember you need to extract the MSI from the exe to do the trick. After running the exe check the %TEMP% folder to get the MSI file.