Backgrounding a scheduled task
beretboy
created: 2006-08-05 17:57:43
I have written a perl script to do some fairly lengthy operations at boot up via the Windows XP scheduled tasks daemon. This will be running in a computer lab, and I don't want users to close the terminal window that currently pops up on boot. How can I run my script in the background, preventing it from opening a command prompt window?


"Sanity is the playground of the unimaginative" -Unknown
Re: Backgrounding a scheduled task
created: 2006-08-05 18:00:53

Start it with wperl.exe instead of perl.exe, assuming that you have ActiveState Perl.

Your users still can kill this task via the task manager or other programs if they have the according privileges. You should consider running your programs as a different user than the logged on user if you want to prevent that.

Re^2: Backgrounding a scheduled task
created: 2006-08-05 18:04:59
Iam using ActiveState, and I actually tried the wperl suggestion (someone told me earlier in the CB) and it doesn't seem to work. I get a "Could not start" message when I schedule the following task: wperl C:\bootscript\bootscript.pl Thanks for reminding me to run this as a different user, I've done that now.


"Sanity is the playground of the unimaginative" -Unknown
Re^3: Backgrounding a scheduled task
created: 2006-08-05 18:19:50

Perhaps a silly question, but is wperl.exe on the path and accessable to the user?


DWIM is Perl's answer to Gödel
Re^4: Backgrounding a scheduled task
created: 2006-08-05 18:24:58
Not silly at all, but no, that is not the problem, I've tried it with the full path and tested it on the command line.


"Sanity is the playground of the unimaginative" -Unknown
Re: Backgrounding a scheduled task
created: 2006-08-05 19:27:50

In the CB bart suggested looking at node 192421 and further commented "open2 and open3 work, too.".

Kudos to bart.


DWIM is Perl's answer to Gödel
Re: Backgrounding a scheduled task
created: 2006-08-06 10:28:42
You could try having a very small perl script which simply ran:
system(1,"/path/to/real/script.pl");
On Windows, the leading 1 should cause the script to run in the background, and your foreground script can immediately exit. Untested, but worth a try anyways...

perlmonks.org content © perlmonks.org and beretboy, Corion, GrandFather, sgifford

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03