Washizu has asked for the wisdom of the Perl Monks concerning the following question:

I have some scripts I need to run periodically on my Windows machine (recently upgraded to 7 from XP) and I ran into a problem. The scripts run fine if I run them via the command line, but in the scheduler they can't seem to find any packages outside of C:\Perl\lib or C:\Perl\site\lib

It can't even see a .pm file located in the same folder as the script. I played around with use lib "C:\path\to\my\script";, but that didn't seem to work either. Any ideas?

All these scripts worked fine with the XP task scheduler

-----------------------------------
Washizu

Replies are listed 'Best First'.
Re: packages and Windows 7 Task Scehduler
by Corion (Patriarch) on Jan 29, 2010 at 17:07 UTC
    use lib "C:\path\to\my\script";

    likely won't do what you think it does. \t expands to a tab in double quotes.

    I prefer to use forward slashes in path specifications:

    use lib "C:/path/to/my/script";

    Also, I like to launch my Perl programs through a .cmd script on Windows:

    @rem Change the directory to where this .cmd lives: cd /d %~dp0 @rem Launch the script perl -w myscript.pl %*

    That way, I have a defined working directory, which also makes relative paths work again.

      Thanks! This helped me debug the problem. It looks like Windows 7's Task Scheduler runs everything by default from C:\Windows\System

      There's an entry when creating a task for where you want to script to run from. Once I set that to the proper place, it worked fine.

      For tasks you already created, open the script properties and go to Actions, Edit, and change the value of Start In (optional).

      -----------------------------------
      Washizu