VBS 脚本适用于 XP 32 位,但不适用于 7 64 位
此脚本(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."),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
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 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
网上有一些证据表明 Windows Vista(以及 Windows 7)未提供“UserAccounts.CommonDialog”。
例如,请参阅 http://www.msghelp.net/showthread.php?tid= 88579
该线程中的最后一个条目建议使用 MSComDlg.CommonDialog(但有一些注意事项),或者使用 GetOpenFileName API。
如果不是这样,请检查注册表,并在执行 CreateObject 时检查 ProcMon 中脚本的操作。您可能会遇到“位数”问题,即您的脚本在 64 位进程中运行,但试图访问 32 位 COM 对象。如果是这种情况,您也会在 CreateObject("WScript.Shell") 处看到错误。
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.
也许您需要重新注册 comdlg32.dll?
参考
Perhaps you need to re-register the comdlg32.dll?
Reference