?
Solved

How to make Task Scheduler run a .ps1 script on Windows 8.1 Pro? (When it doesn't want to.)

Posted on 2014-07-13
13
Medium Priority
?
434 Views
Last Modified: 2014-09-23
I replaced a Windows XP computer with a Windows 8 computer.
This computer sits in a corner and prints documents that it finds in a specific folder.
Previously the Powershell scripts were run by batch files that in turn were called by Task Scheduler.  The scripts sent the documents to the default printer and then moved them to an archive folder.
On the Windows 8 computer, the scripts run when played manually, both directly and from the batch files. But it seems that Task Scheduler does nothing with .bat, .cmd or .ps1 files.

I have administrator privileges and have explored the following:-
    Run as Administrator
    Set-ExecutionPolicy -Scope CurrentUser
    Set-ExecutionPolicy remotesigned
    Set-ExecutionPolicy unrestricted
    Unblock-File C:\Users\Sion\Desktop\np.ps1
    There are no quotation marks in the batch files.

This problem is also demonstrated (repeatable) with the simple task of opening Notepad on the Surface 2 Pro that I am using to write this.
My responsibility is for software so my IT abilities are limited.
What am I missing, any suggestions will be gratefully received?
0
Comment
Question by:SionSR
13 Comments
 
LVL 57

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 40193517
First suggestion is to tick the box in the Task Scheduler task that says "Run with highest privileges"

Task Scheduler run elevated
It is in the Properties>General tab. Regards, Joe
0
 
LVL 16

Expert Comment

by:Dale Harris
ID: 40193536
If I were you, I would run any sort of code in a script block from the batch file to test and see if it's something to do with the calling of PowerShell.  If you can run a simple script block, then it's the file itself that it doesn't like to call.

http://stackoverflow.com/questions/6037146/how-to-execute-powershell-commands-from-a-batch-file
0
 

Author Comment

by:SionSR
ID: 40193622
Thank you for the suggestions, guys.
I believe that I have explored all the privileges options, short of editing the registry. The stackoverflow article endorses this idea in the case of internet settings. I have had a quick look through the registry and found no clue as to what might be changed. However my experience in registry management is somewhere between very limited and non existent.
It does seem that this is some deep rooted permission feature.
I wonder if there is a third party scheduler available.
Another work around would be to 'sleep' the application at a low priority level and accept the loss of performance.
Still open to that magical solution, thank you again.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
LVL 57

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 40193629
Have your tried it with "Run only when user is logged on" and  "Run with highest privileges" both ticked? If so, how is it failing?

Ironically, here's an EE thread from earlier today on the same issue:
http://www.experts-exchange.com/Software/Backup_Restore/Q_28474638.html

A web search for "third-party task scheduler" turns up plenty of hits, but nothing that I can personally recommend, as Windows TS has always worked perfectly for me (and I use it a lot). Every bone in my body says you can get it working. Regards, Joe
0
 

Author Comment

by:SionSR
ID: 40193773
Thanks Joe. The first thing I did was clear those two! I t never occurred to me to try checking them. I'll do that on site tomorrow.
Cheers,
Sion
0
 

Author Comment

by:SionSR
ID: 40193777
Sorry I got that wrong. I have been running with highest privileges but not with "Run only when user is logged on" checked.
0
 
LVL 57

Expert Comment

by:McKnife
ID: 40193938
Hi.

"This problem is also demonstrated (repeatable) with the simple task of opening Notepad" - so let's solve that, it's no powershell problem. What did you set as executor in your notepad task? What happens, does notepad show in task manager?

[normally those problems arise because people don't use task scheduler correctly]
0
 

Author Comment

by:SionSR
ID: 40195825
Thanks for Your input McK. This is still work in progress.
0
 

Author Comment

by:SionSR
ID: 40200691
My IT colleague solved this.
The problem resulted because files had been moved without my knowledge. It has also prompted us to tighten up our permissions.
Thank you for your helping me with this.
0
 
LVL 57

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 40200702
You're welcome. Happy to help! I'm glad you got it sorted. And thanks to you for letting us know what caused the problem. Regards, Joe
0
 
LVL 57

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 earned 1500 total points
ID: 40207542
SionSR,
One other thing. Now that the problem has been solved, please close this question. If you want to give some credit (points) for the Experts who tried to help, you may mark your own post as the Accepted Solution, which will result in zero points for you, and other posts (as many as you want) as Assisted Solutions, which will result in points for the Experts. You may also delete the question, but I don't think that's a good idea, as it would then not be in the PAQ (Previously Asked Question – the database of all questions with solutions). Since there are some good suggestions here by the Experts, as well as your own post with the solution, I recommend not deleting it, so that other EE members with the same, or similar, problem will find it in the PAQ. Regards, Joe
0
 

Author Closing Comment

by:SionSR
ID: 40340642
Thanks, Joe
0
 
LVL 57

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 40340704
You're welcome. And thanks to you for closing it — and for the points! Regards, Joe
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

862 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