• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1985
  • Last Modified:

Autoplay Default DVD Program

OK, I am trying to set the default autoplay program to launch when a DVD is inserted, and in my case I'm using VideoLan VLC media Player.  To manually do this:

1) Open My Computer
2) Right click on the DVD Drive and select Properties
3) Click the Autoplay tab
4) Select DVD movie
5) Check Select an action to perform and choose a program (I am using VIdeolan VLC PLayer)

I grabbed a snapshot of the registry before hand and found the values that changed, and wrote a script that correctly changes that.  However, when you manually set the default through the GUI something else changes to apply it, but I can't locate it.  Does anyone know what I am missing?  I will attach my code below:
Option Explicit
' Create Objects
dim objNetwork: set objNetwork = CreateObject("Wscript.Network")
' Set Variables
dim strComputer: strComputer = "."
dim strSID, arrDeviceID(), i: i = 0
dim objWMIService, objAccount, colDevices, objDevice
' Connect to Computer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
' Get User SID
Set objAccount = objWMIService.Get _
    ("Win32_UserAccount.Name='" & objNetwork.UserName & "',Domain='" & objNetwork.UserDomain & "'")
strSID = objAccount.SID
' Collect CD & DVD ROMs
Set colDevices = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")
For Each objDevice in colDevices
	ReDim Preserve arrDeviceID(i)
	arrDeviceID(i) = objDevice.DeviceID
	i = i + 1
' Connect to Registry & Set DVD Autoplay Default for Each DeviceID Detected
const HKEY_USERS = &H80000003
const HKEY_CURRENT_USER = &H80000001
dim objRegistry: set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
dim strKeyPath: strKeyPath = strSID & "\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\UserChosenExecuteHandlers"
dim strValue: strValue = "VLCPlayDVDMovieOnArrival"
dim strValueName
For i = 0 to UBound(arrDeviceID)
	strValueName = "H:\\?\" & Replace(arrDeviceID(i),"\","#") & "#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}+PlayDVDMovieOnArrival"
	objRegistry.SetStringValue HKEY_USERS, strKeyPath, strValueName, strValue
	'objRegistry.SetStringValue HKEY_CURRENT_USER, strKeyPath, strValueName, strValue
Wscript.Echo "Finished"

Open in new window

  • 3
1 Solution
There is this EE post using the user.dll and rundll32 to make the changes take effect :


:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
sorry for all the posts but forgot to mention you may need to use shell in vbs to launch that command ie :

Set oShell = CreateObject("WScript.Shell")
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

something along those lines possibly however as per the link in my 2nd post it only updates the HKEY CURRENT USER Hive.

This doesn't work.  Did you find a way to get it to work?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now