Set WMP as default player for known video file types with script

Hi

I am trying do script Windows Media Player as default video player for .WMV and .AVI files. As per default my users get a list of Multi Media programs they can choose from the first time they click on a video. I would like that choice to be made per default via script. It works fine with picture file types like .png, .jpeg and bmp. It seems like Windows Media Player plays by other rules.

This is the code I have at the moment:

REM *** SET Windows MediaPlayer as Default player for .WMV
REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wmv" /f
REG DELETE "HKEY_CLASSES_ROOT\.wmv" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wmv" /v "Application" /t REG_SZ /d "wmplayer.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.wmv\OpenWithList" /v "g" /t REG_SZ /d "wmplayer.exe" /f
assoc .wmv=WMP11.AssocFile.WMV

REM *** SET Windows MediaPlayer as Default player for .AVI
REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi" /f
REG DELETE "HKEY_CLASSES_ROOT\.avi" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi" /v "Application" /t REG_SZ /d "wmplayer.exe" /f
REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\OpenWithList" /v "g" /t REG_SZ /d "wmplayer.exe" /f
assoc .avi=WMP11.AssocFile.AVI

Any help to this issue will be very much apprec

December 18th, 2014 8:00am

Hi,

According to your description, the main goal you want to achieve is forcing users to open  .WMV and .AVI files with Windows Media Player. I made a test in my machine, the main issue is related with the following registry keys (take .avi as example)

HKU\S-1-5-21-......(userSID)\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi

By default, there's only one registry entry "OpenWithProgids"under ".avi", when user manually change the default program, another two entries will be created under the ".avi", so what I did is deny the user's permisssions on the "UserChoice", then OK. press F5 to refresh registry, then, the default program for .avi will be forced on Windows Media Player 

If you want to achieve this via script, you can use command line "Regini" to chaneg the permissions

Ref:

http://technet.microsoft.com/en-us/library/hh875566.aspx

https://support.microsoft.com/kb/264584

http://support.microsoft.com/kb/245031

Free Windows Admin Tool Kit Click here and download it now
December 22nd, 2014 2:42am

Hi,

In my opinion, it would be better to post this thread at Windows Script Center forum for further assistance:

Contact Scripting Forum:

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?category=scripting

Thanks for your understanding.

December 22nd, 2014 5:06am

Hi Yolanda

What I am trying to do is to remove the Choice from the user as per default, but they are very welcome to change it later if they want to use another player. I guess your solution denies them to change player? That is not what I want.

The first time my user open a media file e.g. an .avi file the are presented with a list of programs that are able to open this filetype. In my case it is: VLC, Video, Windows Media Player and for some reason Photos. Not all my uses knows what to do here and will call support for help because they don't want to do anything wrong. I just want to make the choice for them in advance. My script above works fine with picture extensions like jpg, gif, png and bmp, but for some reason it is more complex with Windows Media Player.

This is the question I don't want my end users to deal with:

Free Windows Admin Tool Kit Click here and download it now
December 22nd, 2014 5:15am

Point take
December 22nd, 2014 5:20am

Hi,

As I know, by default, .avi (for example) is automatically opened with Video or Windows Media Player in Windows 8\8.1, and we don't need to make any additional settings to achieve this. According to your description, there's no default program for .avi in your situation, so something must be corrupted.

For example, I just delete registry key 

HKU\S-1-5-21-......(userSID)\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\UserChoice

then, when I want to open a .avi file, I was prompted to choose a program to open avi.

After I manually add the "UserChoice" registry, and set WMP as value of  "ProgId", the avi is automatically opened with WMP. (I have a clean system, and it only has the "UserChoice" key under HKU\S-1-5-21-......(userSID)\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi, when I open .avi file the first time, it is opened automatically with the default program, so the main issue is the "UserChoice" registry key, while it is not included in your script.)

Free Windows Admin Tool Kit Click here and download it now
December 24th, 2014 1:00am

Hi

It is correct I am only deleting the UserChoice key, but  not setting it again. When I use the UI to set a default application for a file type, Windows create a key named Hash with a random value, that I can't figure out. It seems like it has to be there to make it work. How do you create that key?

January 2nd, 2015 3:43am

Hi,

Yes, it's a random Hash in different system which is specific important in this case, in my test, I export the ".avi" key to my desktop, then delete the "UserChioce"key, refresh registry, test the avi file, then re-import the ".avi" key to accomplish the "UserChoice", test the avi file again. So it seems that it is unavailable to control this widly, bad news.   Anyway,  Windows 8\8.1 use Video or WMP as default application, so we don't need any additional actions to achieve this. system has the hash value by default, if you accidently delete the "UseChoice" key, I'm afraid that you will need to manually select the WMP in the options to regain the value, after you selected the option, the files will be automatically opened by WMP all the time unless you change it.

Free Windows Admin Tool Kit Click here and download it now
January 6th, 2015 10:25pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics