【发布时间】:2015-09-12 21:28:27
【问题描述】:
我整天都在努力让这个脚本工作!
以下是关于我的情况的一些事实......
- 我的“C:\Windows\System32\”文件夹中有一个名为“ffmpeg.exe”的程序。
- 我的“C:\Windows\SysWOW64\”文件夹中没有该程序。
目前这是我的脚本...
Option Explicit
Dim oFSO, oShell, sCommand
Dim sFilePath, sTempFilePath
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFilePath = "C:\test\in_video.mkv"
sTempFilePath = "C:\test\out_video.mp4"
sCommand = "%comspec% /k ffmpeg -n -i """ + sFilePath + """ -c:v copy -c:a copy """ + sTempFilePath + """"
WScript.Echo sCommand
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.Run sCommand, 1, True
Set oShell = Nothing
Set oFSO = Nothing
如果我在命令提示符下手动运行此脚本,那么它似乎工作得很好。但是,如果我让另一个应用程序运行它(例如在本例中为 uTorrent),它会按预期运行脚本,但是当它尝试处理 oShell.Run 命令时,它会在 32 位环境中运行它!然后我得到这个...
如果我尝试打开一个新的命令提示符(没什么特别的),我似乎默认为 64 位环境,然后我可以输入“ffmpeg”,它会按预期显示帮助内容。
所以由于某种原因,我无法让脚本在 64 位环境中运行应用程序(特别是 CMD)。有谁知道我怎么能做到这一点?
更新
看来我的脚本实际上是在 32 位模式下运行的!虽然脚本标题栏写着“C:\Windows\System32\cscript.exe”,是64位环境!!
我用下面的脚本确定它是在32位环境下运行的……
Dim WshShell
Dim WshProcEnv
Dim system_architecture
Dim process_architecture
Set WshShell = CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("Process")
process_architecture= WshProcEnv("PROCESSOR_ARCHITECTURE")
If process_architecture = "x86" Then
system_architecture= WshProcEnv("PROCESSOR_ARCHITEW6432")
If system_architecture = "" Then
system_architecture = "x86"
End if
Else
system_architecture = process_architecture
End If
WScript.Echo "Running as a " & process_architecture & " process on a " _
& system_architecture & " system."
【问题讨论】:
-
运行 c:\windows\sysnative\cmd.exe
-
C:\Windows\system32\cmd.exe已经是 64 位命令提示符(32 位在C:\Windows\SysWOW64中)。如果您更改为sCommand = "%comspec% /k set path",会输出什么?那么sCommand = "%comspec% /k where ffmpeg"呢?您的administrator可以使用另一个环境变量池... -
Next 应该足够了:在您的脚本打开的 CLI 中并出现
'ffmpeg' is not recognized...错误消息,尝试where ffmpeg和set path命令。全部在显示的当前目录C:\Users\Administrator\Desktop下。也许调用应用程序破坏了您的path或pathext环境变量...
标签: vbscript ffmpeg windows-server-2008-r2