Run schtask locally using jenkins - windows

I have a task to run a bat file locally to schedule a task to open a website i used jenkins to automate it i used start cmd.exe /c SCHTASKS /CREATE /TN "myftp" /TR %TN% /SC daily /ST 14:48:00 it is creating with local cmd but not jenkins windows
batch shell

Related

Tasks in task scheduler not running from cmd

I am using command line to create tasks, run them as well as delete. I am able to create tasks in the scheduler with no issue but when i run it via command line it immediately gets stuck as "queued". But when i go to task scheduler GUI and click "run" the tasks run properly. What could i be doing wrong? I am using windows 10. After running it on cmd it outputs "SUCCESS: Attempted to run the scheduled task "_a"." But still nothing happens unless i go the GUI of task scheduler and run it from there.
Here is a code i tried to schedule notepad:
schtasks /create /ru yanic /sc daily /tn "note" /tr C:\windows\system32\notepad.exe
SCHTASKS /RUN /TN "note

How to update a Windows Task Scheduler task from an updater/script running as admin

I'm writing an updater for my application and want to change my "Windows Task Scheduler" task configured by:
schtasks /create /sc once /tn my_task /tr MyApp.exe /rl highest /st 00:00
The updater is running "with highest privileges" and I mainly want to change the path of MyApp.exe.
I've tried:
schtasks /Change /tn my_task /tr MyUpdatedApp.exe (But it asks: Please enter the run as password for... even though the script already runs as admin. And so is not user friendly or even working in my scripted update.)
A powershell script using Get-/Set-ScheduledJob (But it says: A scheduled job definition with Name my_task could not be found. The help text even states Although jobs that are created by using the Register-ScheduledJob cmdlet appear in Task Scheduler, Get-ScheduledJob gets only scheduled jobs. It does not get scheduled tasks created in Task Scheduler.)
How can I updated my scheduled task from my updater/script without user interaction?
I've resorted to exporting and recreating the task using an XML file with the following command:
schtasks /create /f /tn my_task /xml C:\somewhere\my_task.xml
I create the my_task.xml file by exporting it by hand in the GUI and storing it as part of my application.

executing a batch file into a new command window using windows task schedular

I have test_run.bat file to be scheduled to run at specified time and date. I have added this into a task scheduler using following comand:
set testfile=%%~dp0%test_run.bat release
schtasks /create /tn "test_run" /tr "%testfile%" /sc weekly /d * /mo 1 /st %tt% /sd %dd%
here I'm planning to run "test_run.bat" with "release" as an argument to it. When this task starts, it runs in the background. I want this to open a new command window (starting into a folder where this batch file exists) and run this batch file.
How can I achieve this? Are above mentioned two lines correct(considering release as an argument)?
Using start:
set testfile=start /c %%~dp0%test_run.bat release
schtasks /create /tn "test_run" /tr "%testfile%" /sc weekly /d * /mo 1 /st %tt% /sd %dd%
I this correct?
The start command creates a new command window.
At its very simplest, the command
start test.bat
will create a new command window and run the batch file in it.

how to schedule a non-hidden task with schtasks?

I've been trying to create a scheduled task from the command prompt. The task is created, but it runs hidden. Is there any way of running it in a non-hidden way? The process is very long and I would like to see what is going on...
I'm running it on a Vista, but the task is meant to run on pre-vista OS as well...
SCHTASKS /Create /RU \"NT AUTHORITY\SYSTEM\" /SC DAILY /ST 00:00 /TN Backup /TR \"C:\Sis\Backup\Backup.vbs\" /F /V1
Tks,
Filipe Scur
Running as NT AUTHORITY\SYSTEM means it is a system task and will run hidden.
Try run as a different username.

Ngrok windows autostart

How can i autostart ngrok on Windows ? Scheduled tasks command do not work.
schtasks /create /tn "start" /sc onstart /delay 0000:30 /ru system /tr "C:\ngrok-stable-windows-amd64\ngrok.exe http 80"
Create a text file with the command you want to run. Save it as a bat file in the same folder as the ngrok exe file. Create a shortcut of the bat file in the windows startup folder (Windows Key + R, type shell:startup).

Resources