Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Console app opens new window



Permlink Replies: 5 - Last Post: Dec 14, 2017 3:53 PM Last Post By: Remy Lebeau (Te...
Ed Dressel

Posts: 42
Registered: 10/10/99
Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 13, 2017 5:42 PM
I have a very simple console app written using Seattle that when it runs Windows first asks me if I want to let it run (it is from an unknown publisher) and then opens the application in a new console window.

How can I get it to run in the current console?

Ed Dressel
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 13, 2017 7:45 PM   in response to: Ed Dressel in response to: Ed Dressel
Ed Dressel wrote:

when it runs Windows first asks me if I want to let it run (it is from
an unknown publisher)

That is not why you are getting prompted, though. Windows happily runs
unsigned apps all the time. The real reason for the prompt is that the
console app is marked as requiring elevated permissions that are higher
than the console's current permissions. So UAC asks if the app can
run, and if so then creates a new console window for it. Code-signing
doesn't play into UAC, but the UAC prompt does shows publisher
information if the app is signed.

How can I get it to run in the current console?

If you are executing the app from an existing console, it DOES NOT open
a new console window UNLESS the new process needs to run in a different
privilege level than the existing console. Such as when running an
elevated console app from a non-elevated console window. In which
case, UAC requires a new console window. Nothing you can do about
that. Either run the elevated app from an elevated console, or
re-write the console app to run without elevated permissions.

--
Remy Lebeau (TeamB)
Ed Dressel

Posts: 42
Registered: 10/10/99
Re: Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 14, 2017 8:14 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy:

Thank you for your response. I understand what you are saying.

I am not sure how the application got marked to require elevated permissions--it was a brand new console app and I didn't do anything fancy: I added some class structures to it, and when I had the problems, I removed everything form the console app including the uses clause to see if that would fix it. It just contained a simple Writeln statement. This did not fix it.

How do I fix this?

Ed Dressel
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 14, 2017 3:21 PM   in response to: Ed Dressel in response to: Ed Dressel
Ed Dressel wrote:

I am not sure how the application got marked to require elevated
permissions

There is only one way I know - if it has a manifest that specifies
"requestedExecutionLevel=requiresAdministrator".

Check the project settings, recent IDE versions have a setting for
setting the Execution Level.

--
Remy Lebeau (TeamB)
Ed Dressel

Posts: 42
Registered: 10/10/99
Re: Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 14, 2017 3:29 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
There is only one way I know - if it has a manifest that specifies
"requestedExecutionLevel=requiresAdministrator".

Check the project settings, recent IDE versions have a setting for
setting the Execution Level.

Remy:

Again, thanks for the reply.

It is a blank project. No manifest, no resource, just a DPR with a WriteLn and ReadLn.

I did fine the problem, but let me explain first: the program is used to upgate a Firebird database from one file structure to another. I named it "FBDBUpdater.exe". When I changed the name not to include the word "Update", it no longer required escalation.

Thanks for your help.

Ed Dressel
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Console app opens new window
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 14, 2017 3:53 PM   in response to: Ed Dressel in response to: Ed Dressel
Ed Dressel wrote:

I did fine the problem, but let me explain first: the program is used
to upgate a Firebird database from one file structure to another. I
named it "FBDBUpdater.exe". When I changed the name not to include
the word "Update", it no longer required escalation.

Ah, OK, I forgot about that one. That is UAC's "Installer Detection"
feature. When there is no "requestedExectionLevel" available, UAC
performs various hieristics on the EXE to figure out whether it may be
an installer or not, based on known criteria that is common to
installers.

https://technet.microsoft.com/en-us/library/dd835540.aspx#BKMK_InstDet

Installer detection technology

Installation programs are applications designed to deploy software.
Most installation programs write to system directories and registry
keys. These protected system locations are typically writeable only by
an administrator in Installer detection technology, which means that
standard users do not have sufficient access to install programs.
Windows 7 heuristically detects installation programs and requests
administrator credentials or approval from the administrator user in
order to run with access privileges. Windows 7 also heuristically
detects updates and programs that uninstall applications. One of the
design goals of UAC is to prevent installations from being run without
the user's knowledge and consent because installation programs write to
protected areas of the file system and registry.

Installer detection only applies to:

- 32-bit executable files.

- Applications without a requested execution level attribute.

- Interactive processes running as a standard user with UAC enabled.

Before a 32-bit process is created, the following attributes are
checked to determine whether it is an installer:

- The file name includes keywords such as "install," "setup," or
"update."

- Versioning Resource fields contain the following keywords: Vendor,
Company Name, Product Name, File Description, Original Filename,
Internal Name, and Export Name.

- Keywords in the side-by-side manifest are embedded in the executable
file.

- Keywords in specific StringTable entries are linked in the executable
file.

- Key attributes in the resource script data are linked in the
executable file.

- There are targeted sequences of bytes within the executable file.

Note
The keywords and sequences of bytes were derived from common
characteristics observed from various installer technologies.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02