Recent

Author Topic: Weirdness with install.exe  (Read 2780 times)

Kristi

  • Newbie
  • Posts: 6
Weirdness with install.exe
« on: February 04, 2019, 09:32:36 pm »
Hi everyone

I have made a little console mode program using Free Pascal in Windows and for some reason when I run the program it has a really long pause and then runs in a brand new console window.

The reason this is a problem is because I have a -help option to print help out to the console and it gives feedback to the console while it runs.  Typing install -help is pointless because it opens in a new window, prints, and the immediately closes the window when execution ends.

Is there a way to make this work like a normal program in Windows?  Like if I rename it to "test.exe" it works just fine but I tried both install.exe and setup.exe and it has the long pause and new window problem.  I realize this is probably Windows interfering but I wondered if there is a certain way I can compile it to stop it?

Thank you!

A simple little install.pp program can reproduce my issue:

program install;
begin
  writeln('Hello world!');
end.
« Last Edit: February 04, 2019, 09:36:43 pm by Kristi »

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: Weirdness with install.exe
« Reply #1 on: February 04, 2019, 09:55:58 pm »
Programs named install.exe or setup.exe are seen as installers in moderns windows and require admin permissions to operate.

Solution
 Use a different name.
« Last Edit: February 04, 2019, 10:31:07 pm by Xor-el »

Kristi

  • Newbie
  • Posts: 6
Re: Weirdness with install.exe
« Reply #2 on: February 05, 2019, 09:11:15 am »
Thanks for the reply.  I do realize its a Windows issue.

I am not concerned about the admin access.  I am concerned that its opening and closing in a separate console which makes having command line options and command line help unusable.

My question is whether or not there is an API call or a compiler option, or any sort of hack that I could use to get around this behavior of the application running in a separate console.  I am having trouble coming up with a reasonable word that means "install" for my filename lol

I guess I can just add a key press at the end so that at least the person running the install can see the output.
« Last Edit: February 05, 2019, 09:28:59 am by Kristi »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Weirdness with install.exe
« Reply #3 on: February 05, 2019, 09:20:18 am »
There is one way: in Lazarus you can enable the Manifest Resource in your project settings and ensure that Execution Level "asInvoker" is selected. When you rebuild your binary you'll notice that then Windows no longer displays the UAC shield on the executable and then it will run in the same user context (cause that is what's happening: Windows will execute your binary as an elevated user due to its heuristic and that means a different console except you'd use it in a console that was started with elevated rights).
If you don't use Lazarus you can also do that manually, but you'd need to research how to use resources for that.

Kristi

  • Newbie
  • Posts: 6
Re: Weirdness with install.exe
« Reply #4 on: February 05, 2019, 09:30:29 am »
This is wonderful thank you so much!  I haven't tried Lazarus yet but I will try to research more!  Thanks again :)

 

TinyPortal © 2005-2018