Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Autoplay Default DVD Program

Posted on 2007-11-29
6
Medium Priority
?
1,982 Views
Last Modified: 2013-12-03
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
Next
 
' 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
Next
 
Wscript.Echo "Finished"

Open in new window

0
Comment
Question by:deadite
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 23

Accepted Solution

by:
gecko_au2003 earned 2000 total points
ID: 20498338
There is this EE post using the user.dll and rundll32 to make the changes take effect :

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22890008.html

:: Make the changes effective immediately
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 20498578
0
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 20498585
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.

0
 
LVL 1

Expert Comment

by:gacus
ID: 25129785
This doesn't work.  Did you find a way to get it to work?
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question