views:

19

answers:

1

I have a windows forms application that reads and updates an XML file with information which a windows service must act on.

This has been working on Windows Server 2003, XP and Vista (x32) for some time.

Now, when installed on Windows Server 2008 x64, strange things have started happening, thanks I assume to the User "VirtualStore" folder redirecting security arrangement (which as you can tell I don't fully understand yet).

The Windows Forms app wants to create, read and update the files in c:\user\username\appdata\local\virtualstore\programdata\appname but the service seems happy reading the data from the file in c:\program files\appname...

The result is they are looking at different data.

Now, if I set both executables to "run as an administrator" via the properties/compatibility tab, this problem goes away and the file in c:\program files\appname is used as expected.

However, this feels less than ideal.

As you can probably tell, I am not really aware of most of the issues / factors at work here.

This question is possibly too broad to answer well on Stack Overflow but can someone point in the right direction or alert me to what I need to understand so that my applications can work properly in the Win2008 x64 environment, and continue to work as they do now, on XP, Vista x32 etc.

My user base is not at all technical so I don't want to force them to be making technical "behind the scenes" changes - if possible, I want the setup program to handle this for them.

+1  A: 

From your question it seems you are storing data in c:\program files\appname

You shouldn't store any user or application modified data in c:\program files, it should only contain the static executable and support files written at installation. Simply store these things in ProgramData from the outset.

You should get the path to ProgramData from the environment variable ALLUSERSPROFILE (which also means it will work on XP, where it points to All Users). Alternatively if you want to have per user data use USERPROFILE instead.

This is all due to security changes, but the directory virtualisation that takes place can be extremely confusing. Especially for example if you install as admin (so all goes as expected) but then run as a normal user (where it starts pointing elsewhere).

Stuart
Of course if you make this change, it will most likely impact existing installations on XP, but the installer can handle that migration.
Stuart