cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
amosrinat
Engaged Sweeper
Hi,
Deploying a script that creates a scheduled task, creates the task but it cannot be run manually.
I am deploying as system because many remote computers may be running without a logged on user.
The same task runs OK when I run the already deployed (copied) script manually.
I have also tried to use Psexec (not from Lansweeper) and the results were good.
I have tried executing the below from LS deployment -
{PackageShare}\psexec -u [user] -p {Pass} -h cscript "C:\Windows\temp\5-WU_Weekly_schedule-DEV.vbs".
This too works when running locally but doesn't work when running by LS deployment.
What makes the difference between Psexec and Lansweeper?
Any suggestions?

Amos
2 REPLIES 2
TassieTrooper
Engaged Sweeper II
Amos wrote:
Hi,
Deploying a script that creates a scheduled task, creates the task but it cannot be run manually.
I am deploying as system because many remote computers may be running without a logged on user.
The same task runs OK when I run the already deployed (copied) script manually.
I have also tried to use Psexec (not from Lansweeper) and the results were good.
I have tried executing the below from LS deployment -
{PackageShare}\psexec -u [user] -p {Pass} -h cscript "C:\Windows\temp\5-WU_Weekly_schedule-DEV.vbs".
This too works when running locally but doesn't work when running by LS deployment.
What makes the difference between Psexec and Lansweeper?
Any suggestions?

Amos


Deploy a LS package 'createFooBarSystemSchedTask.PS1' script and deploy with 'Run mode - System account and it will (should) make the task...PS Script example:

#createFooBarSystemSchedTask.PS1
$action = New-ScheduledTaskAction -Execute 'foobar.exe' -Argument '"C:\Temp\foobar.txt"'

$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Friday -At 4pm

$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 30) -ExecutionTimeLimit (New-TimeSpan -Hours 1) -Priority 5

$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest

Register-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings -TaskName "my system context scheduled task" -Description "OK I hope this works."
steveb
Champion Sweeper
Have you considered using a GPO instead?