2

Is there a way to execute a desktop shortcut on a scheduler? I've tried the task scheduler but when I specify the shortcut, it changes it automatically to the underlying exe file.

Rod
  • 535

2 Answers2

2

Requested Way

To accomplish what you requested, when you add the Action to the scheduled task, you need to enter the following (here I am launching PuTTY):

cmd.exe /c "C:\Users\username\desktop\putty.lnk"

This will accomplish what you requested. (Note: the /c "C:\users\username\desktop\putty.lnk" goes into the "Add Arguments:" field.

The Better Way

What you are describing is normal behavior, and is what I would expect to happen. To give a bit of information, when you run a shortcut you are actually running the executable and possibly specifying additional parameters. To verify this right click on the shortcut in question | Select Properties and look at the "Target" field. For example this is the target for my Chrome shortcut:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

If you need to add additional parameters to the scheduled task, you can add in the Add Arguments (Optional) field. For example I have a PowerShell script set up as a scheduled task and add the -ExecutionPolicy Bypass parameter in the Add arguments field.

Scheduled Task

Here is an additional resource if you need to pass multiple arguments in the scheduled task.

1

Create a shortcut with the following:
schtasks /run /tn "taskname"

Additionally, you could use python to completely bypass the command prompt.

from subprocess import Popen, DEVNULL, CREATE_NO_WINDOW

Popen([ 'schtasks.exe', '/run', '/tn', 'Cheat Engine', ], stdout = DEVNULL, stderr = DEVNULL, creationflags = CREATE_NO_WINDOW).wait()

This runs Cheat Engine under an Administrator role and uses Task Scheduler to bypass the UAC prompt.

phpjunkie
  • 143