Why won't my program run from the Program Files directory but will be from anywhere?

My program works fine elsewhere on my drive besides the Program Files directory (Windows XP), I am registered as administrator, so I have full rights to the drive. It works fine in the root of the c: windows directory, mostly anywhere but program files. I have recreated this issue on 4 different machines 2 XP, 2 Vista.

My program is a C # .Net 2.0 program. What could be the problem?

I even copied my whole project to the Program Files directory and I can't debug it from there, it just won't start, no errors at all.

Thanks for any help.

+1


source to share


8 answers


Just guess, if your program tries to store data in the program directory, Vista will prevent this and dynamically change the path to something like c: \ users [user] \ AppData. It might give you a hint of what's going on.



If not, we need more information about your program to help you.

+2


source


If you are unable to debug, you can always create a debug log. It's a little slow, but at the end you will find the place where the program stops working.



LogDebug('before 1');
Statement1;
LogDebug('before 2');
Statement2;
LogDebug('before 3');
Statement3;
LogDebug('after 3');

      

+2


source


I tried the program on a fresh XP installation that doesn't have any anti-frontend policies.

: - (

+1


source


The program is launched from other folders with a space in the path, such as Documents and Settings, the program creates a temporary file in the user profile \ appdata folder.

If I run the application multiple times from somewhere, it works from me just noticed that I get an error with debug capability, but VS doesn't show me the location of the problem, I just get belo error.

Unhandled exception at 0x79fb96a2 in test.exe: 0xC0000005: Access violation read location 0x0000000c.

The problem can be recreated on XP and Vista.

Many thanks

0


source


If this is a machine operated by your big brother company, it looks like only "allowed" applications can run from "Program Files"

0


source


What does your program read in its directory?

Why are you creating a temporary file in user / appdata? For temporary files, you should use the API to get the temporary folder for the current profile and ideally the temporary filename, works like this:

string tempFilePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

      

To help you correctly, we need to know what your program should do when initializing.

0


source


Do you have something like antivirus software?

What is it?

  • Doesn't it work (possibly OS related)
  • OR is it falling (maybe permissions)
  • OR run and not produce the expected result? (maybe permissions)

Have you checked the event logs?

Try calling it from a batch file and see what happens.

Anyone want to try his .exe on their machine?

0


source


Sorry, but I found the problem, I had some shitty code looking for the passed arguments including "file" and a file in "program files" made the program run in command line mode which has no gui. It's a shame that I wasted your time on such a trivial problem, you live and learn!

Thanks everyone.

0


source







All Articles