?
Solved

How do I schedule a powershell script?

Posted on 2014-09-12
5
Medium Priority
?
176 Views
Last Modified: 2014-09-20
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
Comment
Question by:Sikhumbuzo Ntsada
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 19

Expert Comment

by:Kash
ID: 40319028
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
 
LVL 19

Expert Comment

by:Montoya
ID: 40319037
I use AutoIt to script just about everything.
https://www.autoitscript.com/site/autoit/

Free and awesome.
0
 
LVL 51

Expert Comment

by:Vitor Montalvão
ID: 40319086
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
 
LVL 17

Accepted Solution

by:
Sikhumbuzo Ntsada earned 0 total points
ID: 40319358
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
 
LVL 17

Author Closing Comment

by:Sikhumbuzo Ntsada
ID: 40334187
Solved it myself.
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question