forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Temp, Application Data and Common Files directories

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Wed Jul 04, 2007 2:08 am    Post subject: Temp, Application Data and Common Files directories Reply with quote

The correct use of directories other than C:\Program Files\<company>\<appname>\ is more important now - with the number of people using Vista increasing every day.

Since it's quiet around here I thought I'd ask:
When should a programmer use the following directories?

Temp:
C:\Documents and Settings\<user>\Local Settings\Temp\
C:\Documents and Settings\<user>\Local Settings\Temp\<appname>\
C:\Documents and Settings\<user>\Local Settings\Temp\<company>\<appname>\

Application Data:
C:\Documents and Settings\<user>\Local Settings\Application Data\
C:\Documents and Settings\<user>\Local Settings\Application Data\<appname>\
C:\Documents and Settings\<user>\Local Settings\Application Data\<company>\<appname>\

Common Files:
C:\Program Files\Common Files\<company>\<appname>\

Or does anyone have a link to an msdn resource that outlines the proper use of the above directories?

_________________
cheers

Dave
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Wed Jul 04, 2007 2:18 am    Post subject: Reply with quote

Use those temp directories always now, Windows can handle cleaning out these temp directories using the system cleanup wizard. This area is where most installers now empty out their archives into. C:\windows\temp\ should no longer be used.

Also use the application directory to store configuration files, etc in. Do not store any configuration files into c:\program files\* as this directory is now protected under Vista completely; even under XP limited user account it was protected.

I do not know if c:\program files\common files\ should be used, but I wouldn't store any files there, rather store them in the application data area of the computer - especially if you need to constantly read/write to this area without having to elevate your application to admin priv.

Theres exceptions where you may need to write to these directories and there are workarounds, follow the articles below where how to work within Vista's guidlines and how to 'cheat' and break out of them when you really need to.


Here's more info on Vista:
http://forum.vdsworld.com/viewtopic.php?t=4082&highlight=vista

Also follow Microsoft article on how to run programs in an unpriviledged (limited access) account:
http://go.microsoft.com/fwlink/?linkid=81232



Basically if you follow vista guidelines, your applications should work well under older versions of Windows as well; and your application will work appropriate no matter which user is logged in.

If you have any questions, don't hestitate to ask. I've been playing with Vista for almost a year now and have learned alot about UAC and getting applications to work under Vista.
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Wed Jul 04, 2007 2:52 am    Post subject: Reply with quote

Does/can anything get/be stored in C:\Program Files\<appname> anymore? What about the application's .exe file and DLLs?
_________________
John Trappett
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Wed Jul 04, 2007 4:14 am    Post subject: Reply with quote

Sure anything can be stored in c:\program files. your application will need to be elevated to run under administrative access. To do that you use a manifest file in your Vista exe. The manifest is different from the XP common controls manifest.

When you do this, a UAC messagebox will be displayed to the user informing them and asking if the program can gain admin access. Almost all setup/installers will do this, thus they have full access to the system.

Your application can do this too, provided it doesn't ask permission too many times it may be okay to do this; if you don't want any UAC dialogs showing up on your application than you need to make sure not to write to the program files dir, windows directories and not to write to HKEY_LOCAL_MACHINE registry. The reason you don't want your application to keep prompting the user to allow access is UAC fatigue - the person gets tired of pressing YES each time they get sick of your application; and/or security in Vista gets worse because users are tried of allowing access and just click YES/NO to everything.

Also any program that starts up with Windows CANNOT run elevated, Windows Defender will block the application from starting up. This was added to prevent malware from constantly running on Windows startup and prompting users to run as an admin, also to prevent apps from requiring users to allow access to each and every app that starts up and requires elevation (UAC fatigue). Any startup program will need to run under limited account access (non admin mode).


Here is the manifest file that needs to be included inside of your exe. Unfortuantely VDS 5 includes a limited manifest file which only includes extentions for the common controls for windows XP. Jules compiled a vista compatible manifest with VDS 6, when VDS 6 does come out you will be able to do this easily. One other way is using a resource editor program to edit the manifest file in your exe.

Code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    type="win32"
    name="COMPANYNAME.SOFTWARENAME"
    version="1.0.0.0"
    processorArchitecture="x86"
  />
  <description>DESCRIPTION GOES HERE</description>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="x86"
        publicKeyToken="6595b64144ccf1df"
        language="*"
      />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"       
        />
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Wed Jul 04, 2007 2:58 pm    Post subject: Reply with quote

PGWARE wrote:
One other way is using a resource editor program to edit the manifest file in your exe.

Looking at the existing manifest inside one of my VDS compiled exes it looks like I only need to insert the following into the existing manifest between the closing 'dependency' tag and the closing 'assembly' tag.

Code:
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"       
        />
      </requestedPrivileges>
    </security>
  </trustInfo>

_________________
cheers

Dave
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Wed Jul 04, 2007 8:01 pm    Post subject: Reply with quote

I'm using Windows Vista Business Edition right now, and those paths don't exists on my system. It's more like the following on my system:

C:\Users\<usernamehere>\AppData
C:\Users\<usernamehere>\AppData\Local
C:\Users\<usernamehere>\AppData\LocalLow
C:\Users\<usernamehere>\AppData\Roaming

C:\Users\<usernamehere>\AppData\Local\Temp

The majority of program related files seem to be stored in Roaming, then Local. LocalLow has very few files at all. I assume Roaming is available to all users on the computer while Local is that user only.

There is also a ProgramsData directory now which holds such things as the following:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs

Which actually does contain a lot of entries for the start menu.

The common files is still where it has been.

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Thu Jul 05, 2007 3:14 am    Post subject: Reply with quote

Garret, what directories do the following functions return?

Code:
@windir(AppData)
@windir(Local AppData)
@windir(Local Settings)
@windir(Start Menu)
@windir(Programs)
@longname(@env(TEMP))

_________________
cheers

Dave
Back to top
View user's profile Send private message
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Thu Jul 05, 2007 9:33 am    Post subject: Reply with quote

DaveŽ wrote:
Garret, what directories do the following functions return?

Code:
@windir(AppData)
@windir(Local AppData)
@windir(Local Settings)
@windir(Start Menu)
@windir(Programs)
@longname(@env(TEMP))


It returns the following:

Code:

C:\Users\<username>\AppData\Roaming
C:\Users\<username>\AppData\Local
blank, nothing returned at all.
C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu
C:\Users\<username>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
C:\Users\<username>\AppData\Local\Temp

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Thu Jul 05, 2007 3:50 pm    Post subject: Reply with quote

Garrett is correct its all in the c:\Users\ dir now, sorry for the mis-statement I made earlier. Using the appdata function should get it for you as Garret points out.

Also Dave yes those are the only lines needed to add into the manifest. Microsoft says you can include it as a separate file EXENAME.manifest but it doesn't seem that works - only the common controls portion works but not the elevation.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group