views:

211

answers:

4

Say I launch a program from the program I make. Is it possible to trick the launched program into thinking the windows directory is in a different place?

A: 

The location of Windows directory is in the Registry. Vista may let you change it per user, but as far as I know it's impossible to do per-process.

Arkadiy
+1  A: 

It would be difficult. There are several system APIs which the program might be using to determine the path of the windows directory. To trick it you would need to intercept the program's calls to whichever API it is, and return a different result.

There are many articles about intercepting APIs on Windows: here's the first one I found using Google: API hooking revealed.

ChrisW
+2  A: 

If it uses the %windir% or %systemroot% environment variables to determine the Windows directory, it would certainly be easy to change these. But if it uses an API call, you'll have to hook that call, as ChrisW suggests. You might take a look at Detours.

P Daddy
+2  A: 

Faking the location of the windows directory is generally not something that is done. My own reaction is similar to those above, that its a recipe for disaster if it were even possible.

If you could explain your situation in more detail (possibly in a new question), there might be better suggestions to solve your actual underlying problem.

Alan