VBS script works on XP 32-bit but not on 7 64-bit
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.Co开发者_StackOverflow社区mmonDialog"
. 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 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
There is some evidence online that "UserAccounts.CommonDialog" was not supplied with Windows Vista (and thus, Windows 7).
See, for example, http://www.msghelp.net/showthread.php?tid=88579
The final entry in that thread suggests the use of MSComDlg.CommonDialog, with some caveats, or use the GetOpenFileName API.
If that's not it, then examine your registry, and inspect the script's actions in ProcMon at the point it executes CreateObject. You may have a "bitness" problem, where your script is running in a 64-bit process but attempting to access a 32-bit COM object. If that's the case, you're going to see an error at CreateObject("WScript.Shell") as well.
Perhaps you need to re-register the comdlg32.dll? Reference
精彩评论