Jump to content
Basil62

Program restart on ending script

Recommended Posts

I want a program to always run on my computer. Is there a script that forces a program to restart after its process has been stopped?

Thanks in advance

Share this post


Link to post
Share on other sites

Hi @Basil62,

Please try to modify this script to make sure that your application is always running.

@ECHO OFF

QPROCESS "notepad.exe" >nul 2>&1 && (
    echo process notepad.exe  is running
) || (
    notepad.exe
    echo process notepad.exe  is started
)

Note: If you will execute this script via Pulseway, then this application will be launched in the session zero with no GUI interface.

Therefore I would suggest you to create the scheduled task which will run on your system every minute and check if this process is running and start it if the process is not running (you may remove the echo statements from this script)

Share this post


Link to post
Share on other sites

Hello Chris and thank you for replying to my question. Just a followup, since this is the first time I actually associate with scripts. This is a Windows PowerShell script, right? To clarify, I am running Pulseway on Windows 10.

Edited by Basil62

Share this post


Link to post
Share on other sites

Sorry for another follow up question. So only by making a .bat file? The Batch option, as shown in the screenshot, won't do?

sciprt.png

Share this post


Link to post
Share on other sites

 If you will execute this script via Pulseway, then this application will be launched in the session zero with no GUI interface. Therefore I suggested you to use the Windows scheduler to make sure, that the TeamViewer.exe is running on your system at this time.

Another thing is - please use the full path for the executable and remove those echo statements.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Francis
      Hi,
      I think it misses the ability to monitor bandwidth on servers and users computers. It would be nice to have a history of several weeks and the services used.
    • By Finzsoft
      I am trying to upgrade some software using PowerShell and I am not sure if my parameters are correctly formatted .  See highlighted text
       
      # Silent Install Secure Secure Authentication
      # http://repository.eset.com/v1/com/eset/apps/business/esa/windows/v2/2.7.32.0/esa_nt64_enu.msi
      # Path for the workdir
      $workdir = "c:\scripts\"
      # Check if work directory exists if not create it
      If (Test-Path -Path $workdir -PathType Container)
      { Write-Host "$workdir already exists" -ForegroundColor Red}
      ELSE
      { New-Item -Path $workdir  -ItemType directory }
      # Download the installer
      $source = "http://repository.eset.com/v1/com/eset/apps/business/esa/windows/v2/2.7.32.0/esa_nt64_enu.msi"
      $destination = "$workdir\esa_nt64_enu_v2.msi"
      # Check if Invoke-Webrequest exists otherwise execute WebClient
      if (Get-Command 'Invoke-Webrequest')
      {
           Invoke-WebRequest $source -OutFile $destination
      }
      else
      {
          $WebClient = New-Object System.Net.WebClient
          $webclient.DownloadFile($source, $destination)
      }
      Invoke-WebRequest $source -OutFile $destination
      # Start the installation
      msiexec.exe /i "$workdir\esa_nt64_enu_v2.msi" ADDLOCAL="Credential_Provider" /qb /L*v "c:\esa_install_log.txt"
      # Wait XX Seconds for the installation to finish
      Start-Sleep -s 35
      # Remove the installer
      rm -Force $workdir\esa_nt64*
    • By Basil62
      Hello and good day. Is there any way for Pulseway to notify me when the monitored system reaches a specific % threshold of RAM or CPU usage?
    • By Wannes Vande Wiele
      Hello!

      Recently I've been experimenting a bit using scripts that contain variables that the user should enter.
      For example, a very simple one to shutdown a computer after X-amount of time: (example use-case:  I download large files during the night, so it doesn't count towards my ISP data-usage)

      @echo off
      set /p time=Enter time in seconds:
      shutdown /s /t %time%
      timeout /t 3 /NOBREAK
      exit

      however, upon executing said script, the app doesn't request for the variable to be filled out. (I guess it's not made for such uses)
      Obviously, i can manually enter the command using CMD, but i don't want to be typing the command every time i need it. (you can call me lazy :p)

      Any ideas how to do this correctly?
    • By dpbklyn
      Is there a way to kick off an automated task based on a notification or alert.  For Example, if we get a notification of a disk getting full, I would want the automation to run: 
      <Open a ticket>--> <add predetermined note>--> <add 15 minutes>--><run task to clean drive>--><send notification that task has completed>--><close ticket>
      Is this possible now, or should this be a feature request?
      Thank you,
      dp
×