VBS script works on XP 32-bit but not on 7 64-bit

Posted by neurolysis on Super User See other posts from Super User or by neurolysis
Published on 2011-01-06T20:28:49Z Indexed on 2011/01/06 20:56 UTC
Read the original article Hit count: 289

This script (a modification of one of Rob van der Woude's) works fine on XP 32-bit, but fails on 7 64-bit at Set objDialog = CreateObject( "UserAccounts.CommonDialog" ), with something similar to the error (translated from Dutch) ActiveX cannot create the object "UserAccounts.CommonDialog". Is there some different way that I have to do this for it to be compatible with Windows 7?

MsgBox("Your input avi MUST be exported at 60fps, or this script will not work."),0,"IMPORTANT!"

MsgBox("Please select the location of your AVI."),0,"AVI location"

WScript.Echo GetFileName( "", "AVI files (*.avi)|*.avi" )

Function GetFileName( myDir, myFilter )

    Dim objDialog
    Set objDialog = CreateObject( "UserAccounts.CommonDialog" )
    If myDir = "" Then
        objDialog.InitialDir = CreateObject( "WScript.Shell" ).SpecialFolders( "MyDocuments" )
    Else
        objDialog.InitialDir = myDir
    End If
    If myFilter = "" Then
        objDialog.Filter = "All files|*.*"
    Else
        objDialog.Filter = myFilter
    End If

    If objDialog.ShowOpen Then
        GetFileName = objDialog.FileName
    Else
        GetFileName = ""
    End If
End Function

© Super User or respective owner

Related posts about windows-7

Related posts about Windows