Skip to main content
InSource KnowledgeCenter

TN Appsvr999 How to start and close a program from an application server script

Description

 

How to start and close a program from an Application Server script

  • Author: Mike Viteri
  • Published: 6/8/2017
  • Applies to: Application Server

Details

There might be a situation where you want Application Server to execute a program for you. If you don't close each program every time Application server opens a program,multiple instances of the program will show in your task manager. This situation can affect computer performance.(Notepad in this example)

Closescript.JPG

 

Below is an example of script that will launch the program you want to run(Notepad). It waits 5 seconds while the program executes and then close the program. This makes sure multiple instances of the program will not build up in task manager.

Note:Since Wonderware is calling the program it will not show on the Windows desktop only in Taskmanager.

Closescript2.JPG

 

 

Here is the example of the code:

dim myprocess as System.Diagnostics.Process;
myprocess = System.Diagnostics.Process.Start("notepad");
System.Threading.Thread.Sleep(5000);
myprocess.Kill();