RavuAlHemio / StartWaitTree

Launches a subprocess and then waits for it and all its descendants to terminate.
Creative Commons Zero v1.0 Universal
1 stars 1 forks source link

Don't work with Inno Setup in Windows < 10 #1

Closed Dragodraki closed 2 years ago

Dragodraki commented 2 years ago

Your software is great, but not work in Windows 7 if running through Inno Setup (the program which is used to create installer wizards). Seems as command line parameters aren't fully supported by StartWaitTree in general. Always error 0x00000005 occurs (screenshot is attached below). It's not about Inno Setup - I tried every call method with Inno Setup, but always 0x00000005. I know it's rude to ask since your software is free, but can you fix this issue and make a new version? It would be really great if that were possible.

StartWaitTree

RavuAlHemio commented 2 years ago

Hi!

This is likely a build system issue; compiling this application under a newer Windows version (or targeting a newer Windows version) generates an executable with something that breaks it on older Windows versions.

I'll try to find a way to compile it on a Windows 2000 toolset (for 32-bit Intel) and a Windows XP toolset (for 64-bit Intel) as they are the oldest supported Windows versions. Newer Windows versions tend to have very good backward compatibility with older software, but not necessarily vice versa.

Dragodraki commented 2 years ago

Thanks for your fast reply :) I compiled it with VS2017 Community with Toolset v141.

If you get your updated version compiled, can you inform me about this?

RavuAlHemio commented 2 years ago

Yup, I'll simply post in this issue!

RavuAlHemio commented 2 years ago

I've cooked up a Windows 2000 (Visual C++ 2005 & Platform SDK) build script and resulting binary.

The 64-bit version might take a while longer since I'm trying to obtain a Windows XP 64-bit installation image, but the 32-bit Windows 2000 version should work on the majority of 64-bit systems as well.

Dragodraki commented 2 years ago

Yes, thanks, but that wasn't the problem. It don't work along with calling by Inno Setup 5 at all.

If you try to define [Run] entry in Inno-Setup (StartWaitTree.exe as "Filename" and any target file as "Parameter") after compilation and executing of setup the cmd continues to show error 0x00000005. Like I said - never seen something like this before - when called it directly and no path in parameter in works as intended even in Windows 7 - but that was also the case before.

I can only assume that StartWaitTree can't handle a complete path as parameter. Maybe you can fix that parameter to an external file path will be accepted.

RavuAlHemio commented 2 years ago

Ah, I think I have a hunch what's going on here.

If the program started by StartWaitTree elevates (i.e. requests administrator privileges), it becomes impossible for StartWaitTree to monitor it because StartWaitTree itself doesn't have sufficient privileges. To work around this, I have decided to publish a modified version of StartWaitTree that requests elevation itself. (The code is the same, but the manifest resource says "I need administrator privileges, please elevate me".) This should allow attaching to elevated processes.

I have added the binary (built on Windows 2000) to the repository.

Dragodraki commented 2 years ago

I tried StartWaitTree_Admin.exe but it gives me the same error "Failed to access proccess to job object [0x0000005] Access denied". Plus, I'm 100% sure admin rights arent't the problem (and aren't neccessary in the first place). Please think about what I said: standard (no-elevated) StartWaitTree.exe is able to overwatch elevated programs when being executed manually (drag & drop on StartWaitTree or by calling with cmd) but will fail once called by Inno Setup in Windows 7 (plus, my setup and target app don't require admin rights). Strange thing... I'm programming with Inno Setup 5.5.6 for years and created about 300 own setups compatible with NT Windows versions - never an apps behaviour was different from when trying it with cmd manually.

Inno Setup v. 5.5.6-Unicode Call:

[Run] Filename: "{app}\bin\StartWaitTree.exe"; WorkingDir: "{app}\bin"; Parameters: "MyTargetApp.exe"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec runascurrentuser waituntilterminated

Executed script above in Windows 10 and above works but fails in Windows 7 and Vista. So, this isn't absolutely not a question of elevation. So, thanks for "StartWaitTree_Admin.exe" but it's obsolete.

Results: -> Works with Inno Setup in Windows 10/11 with elevated and non-elevated apps -> Works manually in Windows XP/7/10/11 (and probably in every other NT OS too) with elevated and non-elevated apps -> Inno Setup 5.5.6-unicode installers itself are full compatible backwards down to Windows 2000

=> Please can you try to make the StartWaitTree more receptive to parameters, in the code where it checks for "Failed to access proccess to job object" when it comes to Windows 7 or earlier? I'm not much of a programmer but this seems to be the culprit here.

Dragodraki commented 2 years ago

Hey, dont put yourself under pressure. I found a working solution here, which I'll go with: https://github.com/Beej126/Elevator Your app is perfect and can track proccesses childs too, Elevator might not be able to do this. But it can't handle InnoSetup and with "Elevator" I can run apps elevated additionally. You might want to close the issue. :)

RavuAlHemio commented 2 years ago

Ah, I think I found it. It pays to read the documentation, not just to skim it.

I guess Inno Setup (or Explorer or some other parent process) places StartWaitTree into a job, and on Windows versions before Windows 8, a process can only be contained in up to one job. I have modified the code such that on systems below Windows 8, the child process is started broken away from any job containing StartWaitTree, so that it can be placed into the new job created by StartWaitTree.

Dragodraki commented 2 years ago

Thanks so far for your help. I'll check it out next Monday - I haven't my equipment here right now.

Dragodraki commented 2 years ago

What I can see for now that according to your statment "compiling with Visual Studio 2017 brought it down to a singular "unsafe" warning from Cylance on VirusTotal" isn't longer true, because the current 32-bit version gets not less than five alerts on VirusTotal. https://www.virustotal.com/gui/file/bbd736e330d8232c80d8cb86919d40c1d0a2b162307d6cc3c7baac527d3b4b66?nocache=1

I don't complain about that. I'm very grateful for your help in adjusting the tool, but want you to inform you about this in case of you'd like to get rid of alerts.

Dragodraki commented 2 years ago

Thank you very much! Now, "StartWaitTree" works like a charm - even with Inno Setup or older OS versions. I appreciate your help! Very cool app, there isn't any other tool able to wait for child processes too instead of main process only!

The issue can now be marked as solved and closed #1