Task Scheduler WorkItem Not Running

2019-08-14 04:35发布

I have a very specific problem that I need fixing. The major issue is that I don't exactly know how to properly search the remnants of my problem on google. Therefore I am coming to StackOverflow for advice in hopes that someone will assist me.

Summary

So I am writing an application which is to be PCI-compliant for the company which I am starting. The application involves IPC (Inter-process communication) and two "watch-dog" apps which monitor the status of the main application. One of these "watch-dog" applications is an updater (sends an HTTP Request to the server looking for updates of the application).

So! This method which I am using to check the server if the application is up-to-date is using the WinInet library and InternetOpen() to send the request. Then read the response of the page and use GetCookie() to store the response in a buffer. It shall then parse the response accordingly.

If the response says that the current version of my application is less than the version located on the server. It will then tell the customer (user) that their application is out of date, and ask them whether or not they want to update the software. If they choose to update the software, it will perform a Download And Execute from the internet and launch the update-installer on the user's PC.

The Problem

Unfortunately, windows is very "secure" when it comes to having an "unauthorized" application send an HTTP Request to an outgoing url, let alone download something from the server then execute it on the users PC.

My conclusion to this issue was to add the watch-dog programs to the Task Scheduler. That way after the main application is run, it will spawn the watch-dog programs and check if they are running with NTAUTHORITY privileges (which are granted by the Task Scheduler).

After implementing the code to create the task and point it to the location of the watch-dog programs, naming it, writing a description and everything. I executed the program. It ran without errors though here the REAL PROBLEM:

1) Programs executes

2) Spawns watch-dog programs

3) Watchdog program checks for new version

4) Version is found

5) Installer is downloaded, execute ... but

6) The installer does not appear on the screen!


When I run my 'Process Hacker' application to monitor all process actions. I can see that the new installer is download & executed. It is running as NTAUTHORITY/SYSTEM just like the watch-dog programs but it doesn't appear on the system.

I made sure that in my code the status of the window is set to SW_SHOWNORMAL not SW_HIDE. I also made sure that all flags are set accordingly. Though it doesn't appear on the screen!

When I run the application without adding it to the Task Scheduler as my user without NTAUTHORITY/SYSTEM status and just regular user status. It executes (obviously since I am already running as administrator) -- everything works fine. But after adding it to Task Scheduler and having it run with SYSTEM level privileges. The window doesn't appear on the screen visually. Why's that?

I would greatly appreciate anyone that is able to assist me with this problem. Thank-you!

edit 1

Can anyone help me understand how this user applied his fix in the registry? By reading the problem I can somewhat interpret that he had the same issue as me.

App is invisible if started from Task Scheduler without any user logged in

In any case, I am trying to use the advice that Gisley gave me to run the application in Interactive Mode. Possibly going to try to give that a try. Still looking for more answers but I am going to be working no this none-the-less in the meantime.

edit 2

I tried setting the INTERACTIVE FLAG and it had no effect unfortunately.

Allow me to just emphasize my problem:

For example I write a program which has message boxes and put it in a loop.

for

message box

get current pid

make process in the task scheduler

spawn new process as the task scheduler proc with NTAUTHORITY/SYSTEM

kill last proc pid

end for

Then when I execute it:

I get the message box. Then after new process opens with NTAUTHORITY/SYSTEM the message box does not appear anymore.

Same for if I open a calculator for example.

System("cmd.exe start /c calc.exe")

Program runs... opens calculator Program gets NTAUTHORITY/SYSTEM status ON the next loop it executes the calc.exe I see it in my task manager but it doesnt appear on the screen

I hope the above helped emphasize the core of my issue. I dont see the processes opened by the task scheduler process id with NTAUTHORITY/SYSTEM rights... I dont see the procs executed by it on my screen, though I see them in the task manager | process hacker and they are running with NTAUTHORITY/SYSTEM privileges too.

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-08-14 05:13

A shot in the dark - try running the task in interactive mode, but you'll need to have a user logged on.

https://superuser.com/questions/616206/run-interactive-task-even-if-user-is-not-logged-on-windows

Alternatively, or additionally, pass parameters to the installer so that it installs silently.

Silent installation of a MSI package

查看更多
登录 后发表回答