Solved

How do I schedule a powershell script?

Posted on 2014-09-12
5
168 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:Iammontoya
ID: 40319037
I use AutoIt to script just about everything.
https://www.autoitscript.com/site/autoit/

Free and awesome.
0
 
LVL 45

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
When you upgrade from Windows 8 to 8.1 or to Windows 10 or if you are like me you are on the Insider Program you may find yourself with many 450MB recovery partitions.  With a traditional disk that may not be a problem but with relatively smaller SS…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now