Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Calling a program in windows prompt by absolute path from C:\Windows directory is working, but calling this program from C:\Windows\System32 gives me errors.

  • C:\Windows>D:\pathtoexe\program.exe --> OK
  • C:\Windows\System32>D:\pathtoexe\myprogram.exe --> Terminates without doing it's task

The program reads a configuration file from the current directory. The configuration file exists in both (Windows and System32) directories. If I delete the file from the Windows directory then calling the program from the Windows directory terminates with the same error as if I call it from the System32 directory. There should be no file access problems:

  • C:\Windows>type config.ini--> OK
  • C:\Windows\system32>type config.ini --> OK

The same program with same configuration file on Windows Server 2003 is working for both directories!

How do I debug why it won't run from system32 on 2008?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

I assume you are on a 64-bit OS, and program.exe is a 32-bit program.

If that is true, put the configuration file into the windows\syswow64 directory. This is what appears to a 32-bit process as system32.

Due to the way Windows starts processes, they do not directly inherit their working directory, but perform the equivalent of a cd during startup. Hence the 32-bit process, started in the 64-bit system directory, actually ends up in the 32-bit system directory (called syswow64 in a 64-bit cmd or Explorer).

share|improve this answer
    
Yes, it's all true what you say! Thanks for the solution. –  Christian Ammer Aug 31 '12 at 18:37
add comment

Your app is sensitive to which directory it is run in due to expecting certain files- configuration files, maybe dlls or third party exes- from the current directory. I would suggest using pstools procmon to determine the.exact files being accessed.

This may also be a 32 vs 64 bit problem. Procmon will show this as well.

share|improve this answer
    
Thanks for the tip, I will upvote your answer after my 15rep limit. –  Christian Ammer Aug 31 '12 at 18:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.