Solved

Running a powershell task to call exe while logged off

Posted on 2016-09-09
8
120 Views
Last Modified: 2016-09-12
So I have been researching for hours and tried various solutions, I am still having trouble getting an exe to run while logged off.   This is a utility for a 3rd party program called sync.exe.  It will not run when called directly in task scheduler.

So we are trying a powershell script which works fine when logged in an running it manually outside task scheduler.  But once we set it as a scheduled task, the script apparently runs but the exe that it calls does not start.

We have tried running as a admin group and also privileged AD account.  I am using the start-process command in the script and pointing directly to sync.exe.  It is located on a local drive so it is not networked.

We cannot figure out why the exe does not run while logged off.
0
Comment
Question by:bigeven2002
[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
  • 4
  • 3
8 Comments
 
LVL 40

Expert Comment

by:footech
ID: 41791798
It seems likely to me that the program either requires a GUI or a user profile environment.   Either one would mean that it can't run as a scheduled task with an account that is not logged in.
0
 
LVL 17

Author Comment

by:bigeven2002
ID: 41791907
Thanks for the reply.  The strange thing is, this sync.exe file was supposed to be designed to run as a task and it has no overhead or interface.  If double clicking to run the sync, the process will show up in task manager and do its thing. There is no window for it.  And when it is finished it auto terminates.
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 41791987
I would leave calling it from PowerShell out, that just adds another layer of complication and doesn't add any ability to run it as a task.

If you set up a task to run the sync.exe, but set it to run only when user is logged on, does it work?  If so, then it's likely dependent on something in the user profile.  But from there I'm not sure it there's any way to determine what exactly.  Perhaps running Process Explorer or Process Monitor while the program runs could tell you, but especially with ProcMon, it's a lot to sort through.

Can the product maker provide any guidance?
0
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.

 
LVL 17

Author Comment

by:bigeven2002
ID: 41792808
I had been working with the maker and that is how we ended up with the powershell script.  The exe will work when set to run when logged in but not when logged out, even though it is supposed to be able to.  I am still working with them as it may just be a bug.  The exit code for the exe is 1 instead of 0 when it finishes so that too may be a bug.

I just didn't know if powershell can circumvent this issue  by forcing it to run under session 0.
0
 
LVL 40

Expert Comment

by:footech
ID: 41793298
Being very familiar with PowerShell, I can't think of any way that it would help the situation.  I wouldn't say it can't definitively, but I would be extremely surprised.

What does the program do?  Where does it get its config (assuming it's not hard-coded into the program)?  What resources does it try to access?

Have you tried it on other machines and OSes?
0
 
LVL 17

Author Comment

by:bigeven2002
ID: 41793437
Yes we have tried server 2008 r2 and server 2012 r2 as those are the only OSes available to try.  I think it is hard coded, I used procmon to dump the strings but didn't find any usable parameters.  We have the 3rd party program installed in multiple office servers that is client data management and this sync utility is provided by that program to synchronize the data across those servers.  

It is meant to be ran from a primary server whereas the others are secondary.  At present we are running the utility manually by logging in and double clicking it.  The 3rd party program even provides a way to setup this utility as a scheduled task so that is how we know it is supposed to work.  I am still leaning more towards bug if it cannot be ran otherwise.

But the reason for powershell was because that was their latest suggestion.  I should be able to find out more later this week when they get back with me.
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 41793560
I agree PowerShell cannot do anything for you here, unless you are using it to change privileges, make sure to run elevated, check parameters or similar.
However, what it can do is to run procmon, the sync utility, and then stop procmon again (not sure about that last part).
ProcMon with a filter of Process PowerShell.exe and sync.exe, with registry and file monitoring active.
0
 
LVL 17

Author Closing Comment

by:bigeven2002
ID: 41795215
Thanks for the replies.  After further information available today, it is a bug and so a user profile login is currently required for it to run.  The maker is going to fix it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

627 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