Hello to you, enlightened monks. First of all, the technical environment : Consider the following snippet :
use strict; use warnings; use Win32::API; use Win32::TieRegistry; sub setWPUsingAPI { my($pic) = @_; my $SPI_SETDESKWALLPAPER = 20; my $SPIF_UPDATEANDSENDINI = 3; my $syspinf = Win32::API->new('user32','SystemParametersInfo', 'II +PI', 'I') or die "Could not import function SystemParametersInfo.\n"; $syspinf->Call($SPI_SETDESKWALLPAPER, 0, $pic, $SPIF_UPDATEANDSEND +INI); } sub setWPUsingRegistry { my($pic) = @_; $Registry->Delimiter('/'); $Registry->{"HKEY_CURRENT_USER/Control Panel/Desktop//TileWallpape +r"} = 1; $Registry->{"HKEY_CURRENT_USER/Control Panel/Desktop//WallpaperSty +le"} = 1; $Registry->{"HKEY_CURRENT_USER/Control Panel/Desktop//Wallpaper"} += $pic; } my $wallpaper = $ARGV[0]; setWPUsingAPI($wallpaper); setWPUsingRegistry($wallpaper);
The previous script (called test.pl) is called through a scheduled task w/ the following options :

When running the scheduled task, a taskeng.exe pops up briefly and the wallpaper is displayed correctly w/ the registry keys TileWallpaper, WallpaperStyle and Wallpaper all correctly set.

But if I change the run mode to Run whether the user is logged on or not to avoid any pop up, the registry keys are correctly set according to the setWPUsingRegistry subroutine but the setWPUsingAPI subroutine is not applied.

I thought there was an issue w/ the account running the scheduled task in Run whether the user is logged on or not mode (which is AFAIK SYSTEM) but I don't know how to set up the task to circumvent this issue (maybe a runas but then, what would be the point of the Run w/ highest privileges option ?).

I even wrapped the whole code in a batch file but to no avail.

Do you wise monks see where the problem could be ? Thanks in advance.


In reply to Trigger refresh after changing wallpaper when called from scheduled task by ice94

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.