Avoid batch script from being closed?

Discussion in 'Scripting' started by juanmanuelsanchez, Dec 31, 2019.

  1. juanmanuelsanchez

    juanmanuelsanchez MDL Junior Member

    Aug 21, 2009
    51
    1
    0
    hi all ! I have a script batch file that calls a powershell script on startup (already minimized)

    I need a way to avoid users from closing the script window file. Or if its closed a way to restart it...

    The batch is file cotains:
    Code:
    powershell.exe -window minimized -noexit -file "%USERPROFILE%\Desktop\UNB\script\UNBILLING.ps1" 
    Any help is appreciated.
     
  2. Tux 528

    Tux 528 MDL Novice

    Apr 20, 2020
    6
    2
    0
    Hi!
    By default, it is impossible to prevent the closing of a script, be it a Batch or PowerShell script. However, you can completely convert your Batch/PowerShell file into an "invisible" executable file, which means that your script will run silently, without the user being able to interfere with the process, all using specific software.
    Can you specify which type of script cannot be closed, so that you can choose the right software?
    Best regards
     
  3. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    11,437
    49,915
    340
    SilentRun.vbs
    Code:
    Set WshShell = CreateObject^("WScript.Shell"^) : WshShell.Run "Full_Path_To_Batch_File.cmd", 0
    then create schedule task to run SilentRun.vbs
     
  4. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,144
    956
    60
    A PowerShell variant :

    Code:
    @powershell "Start-Process powershell -window hidden '-file \"%USERPROFILE%\Desktop\UNB\script\UNBILLING.ps1\"'"