【问题标题】:How to combine a batch file and a vbs script into one .exe如何将批处理文件和 vbs 脚本合并为一个 .exe
【发布时间】:2013-10-30 20:41:39
【问题描述】:

我希望能够将我为批处理文件制作的 vbs 脚本合并到一个供最终用户使用的 .exe 中,这样我就可以为其分配一个图标。我一直在尝试在网上寻找一种方法,但找不到任何有用的东西。

我想结合这个vbs脚本:

Set oShell = CreateObject ("Wscript.Shell") 
Dim strArgs
strArgs = "cmd /c CheckIn.bat"
oShell.Run strArgs, 0, false

有了这个批处理文件:

@echo off

REM A message to ask the user to save their Outlook emails they have open

mshta javascript:alert("Please be sure to save any emails that you need in Outlook. Click OK to continue.");close();

REM This will stop DM, Email Marker, Email Filer, Interceptor, Papihost, and Outlook.
taskkill /IM DM.exe /F
taskkill /IM DMMarkEmail.exe /F
taskkill /IM EmailAutoBulkFiling.exe /F
taskkill /IM Interceptor.exe /F
taskkill /IM OUTLOOK.EXE /F
taskkill /IM PAPIHost.exe /F

REM This will delete the DM cache in Appdata under the current user
RMDIR /s /q "%userprofile%\Appdata\Roaming\OpenText\DM\Cache"

REM This will start all of the programs that were closed

REM DM and Interceptor restart when Outlook starts back up
START OUTLOOK.EXE

REM Commenting the Marker and Filer since some users don't want it

REM START DMMarkemail.exe
REM START Email AutoBulkFiling.exe
REM START "C:\Program Files\Open Text\DM Extensions\DM.exe"
REM START "C:\Program Files\Open Text\DM Extensions\Interceptor.exe"
REM START PAPIHost.exe
@echo off

我不确定目前是否有一种简单的方法让我无法理解,在此先感谢您的反馈。

【问题讨论】:

    标签: windows batch-file vbscript


    【解决方案1】:

    如果你在没有 /f 的情况下发送 taskkill,它就像一个正常的关闭。应提示用户保存电子邮件。您可以稍后使用 /f 发送它以强制关闭。

    实现您想要的一种方法是将批处理命令放入 vbs oShell.Run 命令中。在执行命令之前无需将命令放入变量中,这会使您的代码混乱。

    EG

    oShell.Run "taskkill /IM DM.exe /F", 0, false
    

    然后看这篇关于如何转换为exe的帖子

    How can I convert a VBScript to an executable (EXE) file?

    PS:您应该能够直接将脚本作为 vb.net 程序运行,而不是在脚本控件中运行它。只需将 vb.net 页眉和页脚放入即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多