0

I just completed my application development efforts on a D2D1 application using Visual Studio 2010 IDE in C++. I was exploring different ways of creating a package from this and used the built-in Visual Studio installer/setup. The setup project compiled smoothly and an install file was created. I was also able to successfully install the application according to my requirements. However, when I install it in the default location (which would be my preferred location - C:\Program Files(x86)), the application refuses to launch. Here is the debugging I was able to do so far:

  1. Installed in C:\Program Files(x86): Application does not launch normally.
  2. Installed in C:\Program Files(x86): Application launches when "Run as administrator"
  3. Installed in a location other than %ProgramFiles% or %ProgramFiles(x86)%: Application launches normally without having to "Run as administrator".

I have tried cornering the error cases, but don't have anything conclusive or convincing so far, which is why I am seeking the experts help here. What I have done further:

  1. Used Dependency Walker x86 version to figure out where/what the dll calls are through the profiler. It did not provide me with anything concrete - depends.exe believes my application has delay-load dependent modules GPSVC.dll and IESHIMS.dll and I am fairly certain that I don't need those. The profiler also indicates a CRT 0xC0000417 error - but it is difficult for me to say if it is related at all.

  2. I do have a manifest defined for my visual styles as a pragma. Removing this did not help.

  3. If this helps - my C++ project manifest file options in the Linker settings looks like this:

    • Generate Manifest - Yes
    • Allow Isolation -Yes
    • Enable UAC - Yes
    • UAC Execution level - As invoker
    • UAC Bypass UI Protection - No
  4. I have converted all CRT functions to it's secure version (sprintf -> sprintf_s) as recommended by MSDN documentation. Is this even related here?

  5. I have tried simply copying the .exe to %ProgramFiles(x86)%. It did not help - so it appears that my installer is not the one creating the problem.

  6. I use _dupenv_s in several places within the code to retrieve %COMSPEC% , %TEMP% etc.

Any pointers to how I can proceed further with the debug is highly appreciated. I did read around about this and some experts suggest incorrect string handling or large or invalid directory names; but I don't see that as relevant in my case since the issue is unique to launching the application normally under %ProgramFiles(x86)% .

Other details: * OS Windows 7 - 64 bit, Vista with latest SP - 32 bit * Visual Studio Professional 2010, C++ Project with .Net client profile target Visual Studio Installer; Target platform 32 bit * Nature of application - Direct2D based

Pardon me if I did not use the correct technical terms. I am a novice in application deployment.

  • You left the most important diagnostic out of your question. What does "not normally" mean. – Hans Passant May 04 '12 at 01:02
  • Normally - double click and launch the application. Not normally - Run as administrator. I just figured out the problem, I think. There are some environment variables that point to %ProgramFiles% indirectly and tries to write files in the %ProgramFiles% location, which apparently is a strict no without admin privileges. I will try fixing this and update here about what happens. Edit - More information here http://stackoverflow.com/questions/6213755/application-only-runs-if-you-run-as-administrator – Viswanathan May 04 '12 at 02:16
  • Ok. As mentioned before, I confirmed this. http://stackoverflow.com/questions/6213755/application-only-runs-if-you-run-as-administrator One cannot directly or indirectly write to %programfiles% without permissions. Thanks for reading (and I could not answer my own question for a while since I am new). – Viswanathan May 04 '12 at 04:26

1 Answers1

1

That is correct Viswanathan, you cannot write to Program Files/Program Files(x86) if you are not running from an elevated process.

If your application needs to write custom settings in a file when it is launched you should create a dedicated folder for it under CommonAppDataFolder

Bogdan Mitrache
  • 10,536
  • 19
  • 34