ice94 has asked for the wisdom of the Perl Monks concerning the following question:
The previous script (called test.pl) is called through a scheduled task w/ the following options :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);
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Trigger refresh after changing wallpaper when called from scheduled task
by silent11 (Vicar) on Mar 27, 2015 at 16:47 UTC | |
|
Re: Trigger refresh after changing wallpaper when called from scheduled task
by dasgar (Priest) on Mar 27, 2015 at 18:53 UTC | |
|
Re: Trigger refresh after changing wallpaper when called from scheduled task
by ice94 (Novice) on Mar 28, 2015 at 13:34 UTC |