Recent

Author Topic: Windows Permissions  (Read 23733 times)

ffejrobins30

  • New Member
  • *
  • Posts: 10
Windows Permissions
« on: January 04, 2011, 04:29:33 am »
I have spent the last couple of days looking for a solution to my problem. It's been quite a while (10 years) since I programmed seriously, so I'm a little out of the loop. The last environment I used was Delphi 5 on Win 2K.

What I'm looking for is way to request admin privileges when the program launches. This is a Windows only program by design, so multiplatform does not interest me.

I've searched for the last 2 days for an answer, but have been unable to find one. If there is a link that someone knows about, it would be great if you could direct me there.

Windows 7 platform

Thanks,
Jeff

Edit-> Ok, so I've figured out that I need to request the permissions in the manifest file, but evertime I edit it, then compile, it gets changed back to "asInvoker" for the permissions request. How can I include the manifest file without haveing the compiler auto-create the manifest evertime I try to compile.
« Last Edit: January 04, 2011, 05:53:47 am by ffejrobins30 »

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: Windows Permissions
« Reply #1 on: January 04, 2011, 09:42:11 am »
1) modify your manifest to change the "asInvoker" to the value you want
2) in Project Options, uncheck the "Use manifest file to enable themes (windows only)" checkbox.

It shouldn't change it anymore
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

ffejrobins30

  • New Member
  • *
  • Posts: 10
Re: Windows Permissions
« Reply #2 on: January 04, 2011, 10:04:07 pm »
Ok, I have edited the manifest file and unchecked the "use manifest file to enable themes" checkbox in Project Options, but the problem with that is that it does not bother including the manifest file information in the build without that option selected.

if the option is seleted, then the manifest is overwritten with the default information, then the xml is embedded into the .res package when it's compiled. If the option is not selected, the files remains as I have saved it and is not compiled into the .res file. It also does not give me the UAC Permission request screen when the application is launched, either by the IDE or manually, which is another clue that it is not including the manifest information.

Any other suggestions???

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Windows Permissions
« Reply #3 on: January 04, 2011, 10:11:35 pm »
Make a feature request on BugTracker.

ffejrobins30

  • New Member
  • *
  • Posts: 10
Re: Windows Permissions
« Reply #4 on: January 04, 2011, 10:19:24 pm »
Ok, I will, but is there a work around for it now? I have the app ready for deployment and this is the only thing hanging me up.

ffejrobins30

  • New Member
  • *
  • Posts: 10
Re: Windows Permissions
« Reply #5 on: January 05, 2011, 07:47:01 am »
I find it hard to believe that no one has made a program that requires elevated access in windows. So far I have tried a bunch of things. I looked in the bugtracker and found that there is one other guy that asked about the exact same thing and was told to create the manifest as a resource file and include it using {$R Whatever.res}, but whenever I do this and compile, the debugger comes to a screeching halt and won't continue. Even manual starting of the app doesn't work.

What am I missing???

Am i building the resource wrong? What's the correct way to do this???

lainz

  • Guest
Re: Windows Permissions
« Reply #6 on: March 03, 2011, 04:40:22 am »
I have spent the last couple of days looking for a solution to my problem. It's been quite a while (10 years) since I programmed seriously, so I'm a little out of the loop. The last environment I used was Delphi 5 on Win 2K.

What I'm looking for is way to request admin privileges when the program launches. This is a Windows only program by design, so multiplatform does not interest me.

I've searched for the last 2 days for an answer, but have been unable to find one. If there is a link that someone knows about, it would be great if you could direct me there.

Windows 7 platform

Thanks,
Jeff

Edit-> Ok, so I've figured out that I need to request the permissions in the manifest file, but evertime I edit it, then compile, it gets changed back to "asInvoker" for the permissions request. How can I include the manifest file without haveing the compiler auto-create the manifest evertime I try to compile.

I'm lazy to read all comments :)

1) go to project options and uncheck 'use manifest to enable themes'

2) crete a text file 'manifest.rc' and copy this code inside:

Code: [Select]
1 24 "manifest.xml"
3) create the 'manifest.xml' with 'asAdministrator'

4) in the Form1 or MainForm or Project.lpr add this:

Code: [Select]
implementation

{$R manifest.rc}

5) testing:

change the name of the .exe or copy and paste the .exe generated in the compilation, because Windows saves the manifest options in 'some place' (I'm not secure if registry) and next time you run the .exe  read the configuration (not from exe manifest, weird)..

I has this problem when i want to make High DPI applications.. (succes =D http://wiki.lazarus.freepascal.org/High_DPI ).

w click

  • Full Member
  • ***
  • Posts: 131
Re: Windows Permissions
« Reply #7 on: March 03, 2011, 10:22:05 am »
I find it hard to believe that no one has made a program that requires elevated access in windows.
Hang on, do we want programs to have elevated access on our machines?

lainz

  • Guest
Re: Windows Permissions
« Reply #8 on: March 03, 2011, 05:24:57 pm »
I find it hard to believe that no one has made a program that requires elevated access in windows.
Hang on, do we want programs to have elevated access on our machines?

Piriform Defraggler.

w click

  • Full Member
  • ***
  • Posts: 131
Re: Windows Permissions
« Reply #9 on: March 03, 2011, 06:32:33 pm »
I still want a "do you really want to allow this" rather than have the [there just isn't a swear word strong enough] virus I got a few months back.

lainz

  • Guest
Re: Windows Permissions
« Reply #10 on: March 03, 2011, 08:24:16 pm »
I still want a "do you really want to allow this" rather than have the [there just isn't a swear word strong enough] virus I got a few months back.

Sure, for this is privileges and UAC.

Also if the software is only for system administrators
because the settings of the system the app changes, or
because uses the root disk to save-load settings, etc..

If the soft is for a company, to ensure is used only by people with administrative privileges-

but I'm running applications with UAC disabled.

ffejrobins30

  • New Member
  • *
  • Posts: 10
Re: Windows Permissions
« Reply #11 on: March 03, 2011, 09:37:18 pm »
As stated before, I have solved this problem and now have the app distributed and working properly.

Requesting elevated privileges this way does not comprimise system integrity since it asks for permission first. I'm sure everyone has seen the User Account Control Dialog that pops up asking if you want to allow a program to make changes to your system, that's what this feature does. If you click no, then it fails to launch.

Disabling the "Use manifest" option in Project options took care of the override problem I was having.

JimBeam

  • New Member
  • *
  • Posts: 36
Re: Windows Permissions
« Reply #12 on: June 04, 2011, 12:25:22 pm »
change the name of the .exe or copy and paste the .exe generated in the compilation, because Windows saves the manifest options in 'some place' (I'm not secure if registry) and next time you run the .exe  read the configuration (not from exe manifest, weird)..
Possible solution for this:
adapted from
http://exadminmcse.blogspot.com/2010/02/manifestcache-windows-2008-and-vista.html

Run the following commands from an elevated command prompt to remove the manifest cache file in the %windir%\winsxs\ManifestCache\ directory:
Code: [Select]
sc query trustedinstaller
sc stop trustedinstaller
sc query trustedinstaller
rem NOTE: Wait for it to stop and ensure it stops successfully. If you are unable to stop the service, you may need to restart your machine.
takeown /f %windir%\winsxs\ManifestCache\*
icacls %windir%\winsxs\ManifestCache\* /GRANT administrators:F
del /q %windir%\winsxs\ManifestCache\*

Recompile program.

lainz

  • Guest
Re: Windows Permissions
« Reply #13 on: June 04, 2011, 07:57:12 pm »
change the name of the .exe or copy and paste the .exe generated in the compilation, because Windows saves the manifest options in 'some place' (I'm not secure if registry) and next time you run the .exe  read the configuration (not from exe manifest, weird)..
Possible solution for this:
adapted from
http://exadminmcse.blogspot.com/2010/02/manifestcache-windows-2008-and-vista.html

Run the following commands from an elevated command prompt to remove the manifest cache file in the %windir%\winsxs\ManifestCache\ directory:
Code: [Select]
sc query trustedinstaller
sc stop trustedinstaller
sc query trustedinstaller
rem NOTE: Wait for it to stop and ensure it stops successfully. If you are unable to stop the service, you may need to restart your machine.
takeown /f %windir%\winsxs\ManifestCache\*
icacls %windir%\winsxs\ManifestCache\* /GRANT administrators:F
del /q %windir%\winsxs\ManifestCache\*

Recompile program.


Thanks  8)

 

TinyPortal © 2005-2018