2013-10-26 144 views
0

我有一个master.bat文件,其中有...运行主bat文件

call file1.bat 
call file2.bat 
call file3.bat 
call file4.bat 

我想安排它在我的Windows Server 2008上以静默/无形mode.I运行'寻找一些方式来运行这个master.bat没有任何可见的用户(无窗口,CMD接口,没有任务栏名称等)。 我不想安装任何批处理exe软件。

我试图通过更改用户运行任务到“系统”,它已完成工作,但我不能在实际中做到这一点。 我发现Windows脚本宿主的run方法可以让你在不可见的模式运行一个脚本.....

Set WshShell = CreateObject("WScript.Shell") 
WshShell.Run chr(34) & "C:\Batch Files\master.bat" & Chr(34), 0 
Set WshShell = Nothing 

,但没有更多的文件,请:)任何其他建议这一点。

EDIT1

考虑available..it将确定使用Windows脚本宿主的运行方法的选择有限,但我怎么可以安排在任务调度master.vbs ..?

+0

使用脚本shell是创建CMD过程而不弹出窗口的唯一方法 – Antoniossss

+0

Tha是真的。 。 。有点 – nephi12

+0

你可以从服务器上运行一些东西,并让它与远程计算机联系,但如果你使用.BAT,实际上从最终用户的计算机运行它将显示至少最小化。使用脚本作为@Antoniossss说是唯一的方法。 – Grant

回答

1

对于它的扩展视图,在stackoverflow中检查混合批处理/ vbscript/javascript文件。

将其另存为master.cmd并根据需要进行修改。

@if (@[email protected]) @then 
@echo off 
rem **** batch zone ********************************************************* 

    rem Check if started from javascript part of script. 
    rem We are checking an environment variable set from javascript part. 
    if "%_run_hidden_%"=="true" (
     goto startBatchWork 
    ) 

    rem if not started from javascript, call javascript part to restart batch. 
    wscript //E:JScript "%~dpnx0" 
    exit /b 

:startBatchWork 

    rem Here starts the real work of the batch file 

    msg %username% "Batch file running hidden" 





    rem End of batch area. Ensure batch ends execution before reaching 
    rem javascript zone 
    exit /b 

@end 
// **** Javascript zone ***************************************************** 
// Instantiate the needed component to interact with Shell 
var shell = WScript.CreateObject('WScript.Shell'); 

    // Set the environment variable that the batch part will check to know 
    // it's running hidden 
    shell.Environment('Process').Item('_run_hidden_')='true'; 

    // start the batch part of the script calling %comspec% with the current 
    // script as parameter, hidden (0) and not waiting for it to end (false) 
    shell.Run('"' + shell.ExpandEnvironmentStrings('%comspec%') + '" /c "' + WScript.ScriptFullName + '"', 0, false); 

    // All done. Exit 
    WScript.Quit(0); 
+0

@MC ...当我将代码放入批处理区后,双击master.cmd .. CMD窗口弹出一小部分秒。上述混合批处理的优点是什么? – Sunny

+1

优点只有一个文件。如果以批处理方式启动它,则无法显示第二个cmd窗口的这一部分。但是,如果您直接以'wscript // E:JScript“c:\ where \ miBatch.cmd”'开始javascript部分,那么将不会有任何可见的窗口。 –

+0

excellent..understood ..谢谢..! – Sunny

1

CMDOW是一个允许批处理运行隐藏的工具。

它被各种AV程序标记为黑客工具。

+0

@ Foxi ..我不能去任何新的.exe安装..我说我使用Windows脚本宿主的运行方法来运行master.bat hidden..but计划该master.vbs文件,我不会需要另一个.bat文件。? – Sunny