【问题标题】:Run batch silently by hotkey (permissions issue?)通过热键静默运行批处理(权限问题?)
【发布时间】:2016-03-15 14:51:21
【问题描述】:

我正在尝试在不切换窗口的情况下从游戏内部控制 Spotify 音量。为此,我执行了以下操作:

A.从 NirSoft 发现 nircmd.exe 可以控制 Windows 中的单个程序卷 B.写了一个批处理来执行命令 C. 编写了这个 .vbs 脚本以静默地挂接到批处理中:

Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "Spotify App Volume Up.bat" & Chr(34), 0
Set WshShell = Nothing 

^ 使用这个 .vbs sn -p 来完成静默运行非常受欢迎。 这在我自己单击 .vbs 时有效。我遇到的问题是我需要一种从另一个程序执行此操作的方法。当我尝试从任何热键程序或 AutoHotKey 之类的程序执行时,它会给我这个错误:

ActiveX 组件无法创建对象 'WScript.Shell' 代码:800a01ad

我尝试将所有相关文件的安全性设置为所有人,完全控制。它没有帮助。在我看来,Windows 试图通过阻止脚本被其他程序初始化来保护我。有什么建议?否则有人知道如何用另一种方法静默执行吗?

编辑:

AutoHotKey 的运行命令会这样做: run "mybat.bat",, Hide 但是,有谁知道如何使用 .vbs 解决此问题?我很好奇。

【问题讨论】:

  • how to get around this behavior with .vbs 到底是什么意思?

标签: batch-file vbscript autohotkey volume remote-execution


【解决方案1】:

我相信你所有的脚本、vbscript 和你的批处理文件都可以在 Ahk 中本地编写,但我会这样启动你的 vb 脚本。

x:: ; press x
sc := ComObjCreate("ScriptControl")

sc.Language := "VBScript"

script =
(
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run chr(34) & "Spotify App Volume Up.bat" & Chr(34), 0
Set WshShell = Nothing 
)

sc.ExecuteStatement(script)

return

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-10
    • 2018-08-03
    • 1970-01-01
    • 2014-05-15
    • 2017-07-01
    相关资源
    最近更新 更多