cscript.exe 打开一个窗口 [英] cscript.exe opens a window
问题描述
我有一个需要在 32 位上运行的 vbs 文件,即使我运行的是 64 位 Windows 7.我可以用命令启动这个文件
I have a vbs file that need to be run in 32-bit, even though I am running Windows 7 64-bit. I can launch this file with the command
C:\Windows\SysWOW64\cscript.exe my-file.vbs
这很好用,但它给我留下了一个多余的命令提示符窗口,我每次都必须手动关闭它.把这个vbs文件作为启动项运行起来也很麻烦.
and that works fine, but it leaves me with a redundant command prompt window that I have to close manually each time. It also makes it very cumbersome to run this vbs-file as a startup item.
有没有办法在后台启动我的 32 位 vbs 文件?
Is there a way to start my 32-bit vbs-file in the background?
推荐答案
针对 64 位问题试试这个,如果可行,您可以将其与其他答案结合起来
Try this for the 64bit problem, if it works you can combine it with the other answers
这里有一个更深入地探讨 32/64 位问题的问题
here a question that goes more in depth on the 32/64 bit issue
如何检查wscript/cscript 在 x64 主机操作系统上运行?
这里是修改后的版本,请确保脚本在64位平台上运行
here the modified version, should make sure the script runs on 64bit platform
On Error Resume Next
Dim WshShell, OsType
Set WshShell = CreateObject("WScript.Shell")
OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")
If OsType = "x86" then
wscript.echo "Windows 32bit system detected"
else
wscript.echo "Windows 64bit system detected"
If InStr(LCase(WScript.FullName),"system32") Then
CreateObject("WScript.Shell").Run """%systemroot%\SysWOW64\wscript.exe"" """ & WScript.ScriptFullName & """"
Wscript.Quit
End If
end if
Msgbox("I ran..")
这篇关于cscript.exe 打开一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!