Solved

How do I schedule a powershell script?

Posted on 2014-09-12
5
172 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
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 47

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SCCM 2012 R2 client migration to new site 2 95
Windows Server 2012 R2 -- "RemoteApps" CAL cost ? 2 52
local administrator password solution 26 93
PL SQL Developer 7 32
The password reset disk is often mentioned as the best solution to deal with the lost Windows password problem. In Windows 2008, 7, Vista and XP, a password reset disk can be easily created. But besides Windows 7/Vista/XP, Windows Server 2008 and ot…
Issue: One Windows 2008 R2 64bit server on the network unable to connect to a buffalo Device (Linkstation) with firmware version 1.56. There are a total of four servers on the network this being one of them. Troubleshooting Steps: Connect via h…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
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…

786 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