Running master bat file in invisible mode

前端 未结 2 1866
小鲜肉
小鲜肉 2021-01-26 12:33

I have a master.bat file which has...

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

I want to schedule it on my

相关标签:
2条回答
  • 2021-01-26 12:54

    CMDOW is a tool that will allow the batch to run hidden.

    It is flagged as a hack tool by various AV programs.

    0 讨论(0)
  • 2021-01-26 13:01

    For an extended view of it, check for hybrid batch / vbscript / javascript files here in stackoverflow.

    Save this as master.cmd and adapt as needed.

    @if (@This==@IsBatch) @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 讨论(0)
提交回复
热议问题