Windows 7 VBS脚本适用于XP 32位,但不适用于7 64位
此脚本(Rob van der Woude的一个修改)在XP 32位上运行良好,但在7 64位上在Windows 7 VBS脚本适用于XP 32位,但不适用于7 64位,windows-7,scripting,vbscript,Windows 7,Scripting,Vbscript,此脚本(Rob van der Woude的一个修改)在XP 32位上运行良好,但在7 64位上在Set objDialog=CreateObject(“UserAccounts.CommonDialog”)上失败,错误类似于(从荷兰语翻译)ActiveX无法创建对象“UserAccounts.CommonDialog”。是否有其他方法使其与Windows 7兼容 MsgBox("Your input avi MUST be 60fps, or this script will not work
Set objDialog=CreateObject(“UserAccounts.CommonDialog”)
上失败,错误类似于(从荷兰语翻译)ActiveX无法创建对象“UserAccounts.CommonDialog”
。是否有其他方法使其与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
也许您需要重新注册comdlg32.dll?
有一些在线证据表明,Windows Vista(以及Windows 7)没有提供“UserAccounts.CommonDialog” 比如说, 该线程中的最后一个条目建议使用MSComDlg.CommonDialog,但有一些警告,或者使用GetOpenFileName API
如果不是这样,那么检查您的注册表,并在执行CreateObject时检查ProcMon中脚本的操作。您可能存在“位”问题,即您的脚本在64位进程中运行,但试图访问32位COM对象。如果是这种情况,您还将在CreateObject(“WScript.Shell”)上看到一个错误 您是否有CreateObject失败的错误代码?可能与@David Heffernan、@neurolysis:部分内容是正确的。。。您不能直接从VBScript调用本机Windows API函数,因此
GetOpenFileName
不起作用。没有“比特”问题,UserAccounts.CommonDialog
只是一个丑陋的黑客,只在WindowsXP中有效MSComDlg.CommonDialog
也不是一个好的解决方案。前一段时间提出并回答了一个试图解决根本问题的问题:。