HI
I need a script or a way to change the file association for .wmv files to Windows media player, something automatic that works though GP or start up script, tryed looking at Ftype but couldn't get it right.
Cheers
My Google skills have improved in the last ten minutes, found the answer!
Option Explicit
Dim objShell
set objShell = WScript.CreateObject ("WScript.Shell")
'----------------------------------------------------------------
' Don't edit above here
'
' Below is an example of associating PDF files with AcroRd32.exe
' You can change this to whatever you need, and just
' copy and paste the line over again to add more associations.
'-----------------------------------------------------------------
addFileAssociation ".wmv", "wmplayer.exe"
'-------------------------
' Don't edit below here
'-------------------------
Sub addFileAssociation( fileExt, whichApp )
If ( Left(fileExt, 1) <> "." ) Then
fileExt = "." & fileExt
End If
objShell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Ex plorer\FileExts\" & fileExt & "\Application", whichApp
End Sub

I've done this before using registry entries which run silently through a logon script. Firstly manually create the new file association, then go into the registry.
I exported the four entries for a custom JBR file extension:
Code:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\.jbr] @="jbr_auto_file"Code:Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\jbr_auto_file] @="" [HKEY_CLASSES_ROOT\jbr_auto_file\shell] [HKEY_CLASSES_ROOT\jbr_auto_file\shell\open] [HKEY_CLASSES_ROOT\jbr_auto_file\shell\open\command] @="\"C:\\jetsoft\\COUNTIT.EXE\" \"%1\""Code:Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.jbr] @="jbr_auto_file"Run the registry files silently using:Code:Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jbr_auto_file] @="" [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jbr_auto_file\shell] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jbr_auto_file\shell\open] [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\jbr_auto_file\shell\open\command] @="\"C:\\jetsoft\\COUNTIT.EXE\" \"%1\""
Code:regedit /S \\servername\share\REGFILE.reg
Cheers, I was looking along the right lines with the registry, but got distracted and the curry last night hasn't helped.
Thanks for that info too. If you run a reg file on logon, will it still work with student permissions? tried a printer script before but didn't work on student logon.

Logon/startup scripts are run with full administrator rights as far as I am aware.

Surely you'd need some form of administrator access rights to the registry? I have registry files which install silently through logon scripts.

As far as I know you can change the HKEY_CURRENT_USER part of the registry with a logon script, but not the HKEY_LOCAL_MACHINE and other parts normally, unless the user running the script has the rights to do this. W
With a machine startup script you can change any part of the registry using a script, as the script is run under the system account (same account that most windows services run under) which has rights to do this.
I think I'm correct on this anyway.
Mike.
startup/shutdown scripts run under the local system account, logon scripts run under the current user account so HKCU can be written to by any user as it's their hive but other hives e.g. HKLM can only be written to if the logon script is run by an admin user (possibly a power user as it's a subset of admins rather than a superset of users and has all sorts of odd permissions).
Newton: also take a look at the assoc command
http://support.microsoft.com/kb/184082
Last edited by cookie_monster; 11th July 2008 at 08:52 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)