0
votes

I have a VBScript which basically calls some Informatica CLI commands. These commands will take a long time to execute and the script runs in a Windows 2003 server.

cscript //B //Nologo <script> params...

Actually, I am calling this script from a .NET Winforms application. The idea is, even when form is closed, the script continues to run. It works fine, as long as user is logged on, i.e. even when winform is closed, the script runs as a (user) process and execute the command.

The problem is however when the user logs off (or) remote system (MSTSC) times out, the (cscript) process is killed.

Is there anyway this can be run as a system process so that even when user logs off, the script continues to run?

(Please note that running the .NET EXE as a Windows service is a last option, which is currently not viable..)

1
Running the .NET exe as a Windows service is the only option. Although you can make two programs: the service and the frontend GUI which will be autolaunched on logon. - wOxxOm

1 Answers

0
votes

Only way I know to do this is a pretty dirty hack so you should at least consider the .NET service approach... Visual Studio offers great tools which allow you to make a Windows service very easily.

What you can do if that is really not an option is using the task scheduler. As long as you do not need user interactivity you can say a task should be "Run whether a user is logged on or not". If you do this you are allowed to use "SYSTEM" as the account to run the task with. So you can create your task executing your script without any trigger, and then manually trigger the task from the program.

There is no nice way to do this from C# but you can just execute schtasks /run /tn <taskname> or do a quick google search for some of the wrappers people wrote for this. The script will run (invisibly) in the background and survive user logoff if started that way.