我有一个小脚本,我时不时地运行它,它从来没有出现过任何问题。我在 Windows 7 上也用过它。它依赖于 WScript.Shell。
几天前我运行了它并返回了以下消息:
---------------------------
wscript.exe - Bad Image
---------------------------
C:\Windows\system32\wshom.ocx is either not designed to run on Windows
or it contains an error. Try installing the program again using the original
installation media or contact your system administrator or the software vendor
for support.
---------------------------
OK
---------------------------
随后出现 WScript 错误:
---------------------------
Windows Script Host
---------------------------
Script: C:\tools\videoconverter.vbs
Line: 9
Char: 1
Error: Could not create object named "WScript.Shell".
Code: 800700C1
Source: WScript.CreateObject
---------------------------
OK
---------------------------
我尝试了以下方法:
- 进行了干净启动,关闭了所有非 MS 服务。错误仍然相同。
- 当我尝试注册 wshom.ocx 时,我得到了
[窗口标题]
RegSvr32[内容]
模块“C:\Windows\system32\wshom.ocx”可能与您正在运行的 Windows 版本不兼容。请检查该模块是否与 x86(32 位)或 x64(64 位)版本的 regsvr32.exe 兼容。[好的]
我的 Windows 版本是 x86 - 我如何查看 Wshom.ocx 与哪个版本兼容?实际上,既然它在过去的某个时间是兼容的,那么怎么会不兼容呢?
编辑:在脚本中添加:
infolder = "c:\tools\music_input"
outfolder = "c:\tools\music_output"
Dim objFSO
Dim ofolder
Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("scripting.filesystemobject")
Dim objCurrentFolder
Set objCurrentFolder = objFSO.getfolder(infolder)
Dim tempval
Dim nFile
For Each file In objCurrentFolder.Files
nFile = outfolder & "\" & file.Name & ".mp3"
If objFSO.FileExists(nFile) Then
Else
tempval = "c:\tools\ffmpeg\bin\ffmpeg.exe -i " & chr(34) & file & chr(34) & " " &
chr(34) & nFile & chr(34)
WshShell.Run tempval
WScript.Sleep 15000
End If
Next