Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 180
  • Last Modified:

How do I schedule a powershell script?

I have this simple script to stop and start an application at 12:00 AM daily.

I want to schedule it, but it will not run all the commands on my script.

It kills the application, but never starts it again.

taskkill /F /IM A5ApplicationServer.exe; 
Start-Sleep -s 10;
Start-Process C:\"Program Files\a5V11 ApplicationServer"\A5ApplicationServer.exe;

Open in new window


I am open to a different route in order to achieve this, even if it's via dos or vbscript.

Thank you.
0
Sikhumbuzo Ntsada
Asked:
Sikhumbuzo Ntsada
1 Solution
 
Kash2nd Line EngineerCommented:
why not have 2 separate scripts one to shut down and one to start and then reference them in another so that they work together.

Also, have them set in task scheduler. Just my 2 pence
0
 
MontoyaProcess Improvement MgrCommented:
I use AutoIt to script just about everything.
https://www.autoitscript.com/site/autoit/

Free and awesome.
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Have you tried to increase de Start-Sleep parameter? Maybe to 30 seconds or so?
And I'm assuming that you are using Windows Schedule Task for schedule the script.
0
 
Sikhumbuzo NtsadaSenior IT TechnicianAuthor Commented:
Hi,

I added the following code before the path of the script, it worked like a charm.

-nologo -command "& (C:\Temp\StopRestart.ps1)"
tsksch
Thanks
0
 
Sikhumbuzo NtsadaSenior IT TechnicianAuthor Commented:
Solved it myself.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now