Run any application in background

后端 未结 2 615
梦如初夏
梦如初夏 2021-01-24 12:29

Again a VBScript problem.

Here is a working code

Set WshShell = WScript.CreateObject(\"WScript.Shell\") 
WshShell.Run \"\"\"C:\\Program Files\\TrueCrypt\         


        
相关标签:
2条回答
  • 2021-01-24 12:48

    .Run starts a console ('DOS Box') to execute some other process/program. You can control the display mode of that console (e.g. hide it by passing SW_HIDE == 0 as param 2), but what this other program does to your screen is up to this process. Programs meant to be executed silently (should) accept arguments like --headless or /nogui, or (should) provide a suitable IPC (e.g. COM) interface. So how to start other programs 'in the background' can't be answered in a 'one strategy for all' way. AFAIK, the players offer COM/OCX interfaces, and using these certainly beats Sendkeys voodoo. So google for "iTunes.Application vbscript" or "Wmplayer.OCX." to get some hints about how to use these COM objects.

    0 讨论(0)
  • 2021-01-24 12:58

    Instead of using the Shell Run method you could try the Create method of the WMI Win32_Process provider.
    The example on this MSDN page creates a configuration object to set the process option ShowWindow to SW_NORMAL (i.e. 1) for a GUI executable - NOTEPAD.EXE.
    On this page it looks like SW_HIDE (with a value of 0) is also an option.

    0 讨论(0)
提交回复
热议问题