Skip to content

Instantly share code, notes, and snippets.

@imoutsatsos
Last active May 7, 2023 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imoutsatsos/068e8e8e509e0a74dc6a1073760293c5 to your computer and use it in GitHub Desktop.
Save imoutsatsos/068e8e8e509e0a74dc6a1073760293c5 to your computer and use it in GitHub Desktop.
# As generated by ChatGPT-Does NOT work
# there is no 'User' option but can try 'Principal'
# Define the path to the Java executable and the arguments to pass to it
$javaPath = "C:\Program Files\Java\jre1.8.0_281\bin\java.exe"
$javaArgs = "-Dcantaloupe.config=cantaloupe.properties -Xmx2g -jar cantaloupe-5.0.5.war"
# Define the name of the scheduled task and the user account to run it as
$taskName = "Cantaloupe"
$taskUser = "DOMAIN\USERNAME"
# Create a new scheduled task that runs on startup
$action = New-ScheduledTaskAction -Execute $javaPath -Argument $javaArgs
$trigger = New-ScheduledTaskTrigger -AtStartup
$task = New-ScheduledTask -Action $action -Trigger $trigger -User $taskUser -TaskName $taskName
# Register the task with Windows Task Scheduler
Register-ScheduledTask -InputObject $task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment