Notification

Icon
Error

Creating a schduled task on remote computer

Posted: Sunday, February 21, 2021 10:57:02 AM(UTC)
Amos

Amos

Member Original PosterPosts: 1
0
Like
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
steveb
#1steveb Member Posts: 35  
posted: 2/26/2021 7:44:48 PM(UTC)
Have you considered using a GPO instead?
TassieTrooper
#2TassieTrooper Member Posts: 3  
posted: 4/12/2022 8:49:36 AM(UTC)
Originally Posted by: Amos Go to Quoted Post
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."

Active Discussions

Lansweeper Windows user activity tracking
by  DaveP   Go to last post Go to first unread
Last post: 6/28/2022 6:57:09 PM(UTC)
Lansweeper Report showing app even after it has gone
by  Andy.S  
Go to last post Go to first unread
Last post: 5/30/2022 3:19:37 PM(UTC)
Lansweeper Creating a schduled task on remote computer
by  TassieTrooper   Go to last post Go to first unread
Last post: 4/12/2022 8:49:36 AM(UTC)
Action Internet history of an user (IE and Firefox)
by  Tizi@no  
Go to last post Go to first unread
Last post: 4/1/2022 1:32:49 PM(UTC)
Action Remote Uninstaller
by  Tizi@no   Go to last post Go to first unread
Last post: 4/1/2022 9:29:17 AM(UTC)
Lansweeper uVNC Config
by  RatWolf  
Go to last post Go to first unread
Last post: 3/17/2022 3:16:53 PM(UTC)
Lansweeper Change computer name by custom field
by  Don  
Go to last post Go to first unread
Last post: 3/4/2022 3:44:08 AM(UTC)