+ Post New Thread
Results 1 to 10 of 10
Windows Thread, Change File Association in Technical; HI I need a script or a way to change the file association for .wmv files to Windows media player, ...
  1. #1
    Newton's Avatar
    Join Date
    Oct 2007
    Posts
    179
    Thank Post
    59
    Thanked 5 Times in 5 Posts
    Rep Power
    9

    Change File Association

    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

  2. #2
    Newton's Avatar
    Join Date
    Oct 2007
    Posts
    179
    Thank Post
    59
    Thanked 5 Times in 5 Posts
    Rep Power
    9
    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

  3. #3

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    6,192
    Thank Post
    151
    Thanked 946 Times in 737 Posts
    Rep Power
    197
    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"
    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\""
    Run the registry files silently using:

    Code:
    regedit /S \\servername\share\REGFILE.reg

  4. #4
    Newton's Avatar
    Join Date
    Oct 2007
    Posts
    179
    Thank Post
    59
    Thanked 5 Times in 5 Posts
    Rep Power
    9
    Cheers, I was looking along the right lines with the registry, but got distracted and the curry last night hasn't helped.

  5. #5

    Join Date
    Apr 2007
    Location
    York
    Posts
    469
    Thank Post
    6
    Thanked 4 Times in 4 Posts
    Rep Power
    13
    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.

  6. #6

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    6,192
    Thank Post
    151
    Thanked 946 Times in 737 Posts
    Rep Power
    197
    Logon/startup scripts are run with full administrator rights as far as I am aware.

  7. #7
    DMcCoy's Avatar
    Join Date
    Oct 2005
    Location
    Isle of Wight
    Posts
    3,049
    Thank Post
    9
    Thanked 382 Times in 328 Posts
    Rep Power
    88
    Quote Originally Posted by Michael View Post
    Logon/startup scripts are run with full administrator rights as far as I am aware.
    Only startup/shutdown scripts. Logon are run as the user.

  8. #8

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    6,192
    Thank Post
    151
    Thanked 946 Times in 737 Posts
    Rep Power
    197
    Surely you'd need some form of administrator access rights to the registry? I have registry files which install silently through logon scripts.

  9. #9

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,003
    Thank Post
    192
    Thanked 413 Times in 300 Posts
    Rep Power
    136
    Quote Originally Posted by Michael View Post
    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.

  10. #10
    cookie_monster's Avatar
    Join Date
    May 2007
    Location
    Derbyshire
    Posts
    4,085
    Thank Post
    329
    Thanked 271 Times in 233 Posts
    Rep Power
    68
    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.

SHARE:
+ Post New Thread

Similar Threads

  1. *All change*
    By GrumbleDook in forum General Chat
    Replies: 29
    Last Post: 6th June 2008, 07:53 PM
  2. Using assoc to change file associations
    By cookie_monster in forum Windows
    Replies: 4
    Last Post: 23rd April 2008, 02:59 PM
  3. Which file do I need to edit to change front page graphics?
    By reggiep in forum EduGeek Joomla 1.0 Package
    Replies: 2
    Last Post: 22nd April 2008, 02:18 PM
  4. VBS Change File on a Certain Line?
    By Samson in forum Scripts
    Replies: 7
    Last Post: 31st August 2007, 10:52 AM
  5. Replies: 4
    Last Post: 23rd March 2006, 07:27 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •