Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - How to locate the 'Default User' profile

Reply
 
Old 10-21-2008   #1 (permalink)
RigB


 
 

How to locate the 'Default User' profile

I have a script that copies Office templates and toolbars to 3 separate
locations in the user's profiles at logon. I also update the 'Default User'
profile so that the templates will be available should another user login to
the workstation. I've been looking up the location with a query of the
'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
Folders\Desktop' key in the registry. It works fine in Windows XP, however,
the key no longer exists on Vista installations! Is there a prefered method
of accomplishing this task?

Tom Gilmour
Tecsult Inc.

My System SpecsSystem Spec
Old 10-21-2008   #2 (permalink)
Dave Patrick


 
 

Re: How to locate the 'Default User' profile

HKEY_USERS\.DEFAULT is the hive that's loaded when no one is logged on.
Generally the system account (NT Authority). The default user hive is
located at;

Vista;
C:\Users\Default\ntuser.dat

Windows 2000 / XP;
C:\Documents and Settings\Default User\ntuser.dat


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"RigB" wrote:
Quote:

>I have a script that copies Office templates and toolbars to 3 separate
> locations in the user's profiles at logon. I also update the 'Default
> User'
> profile so that the templates will be available should another user login
> to
> the workstation. I've been looking up the location with a query of the
> 'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
> Folders\Desktop' key in the registry. It works fine in Windows XP,
> however,
> the key no longer exists on Vista installations! Is there a prefered
> method
> of accomplishing this task?
>
> Tom Gilmour
> Tecsult Inc.
My System SpecsSystem Spec
Old 10-22-2008   #3 (permalink)
RigB


 
 

Re: How to locate the 'Default User' profile

Hi Patrick,

I am aware of the location of the folder. I was wondering if there was a
reliable way of locating it regardless of the version of OS. From what I
gather there is none. I've been searching everywhere for a solution without
success. Microsoft encourages programmers to use proper methods to enumerate
special folder locations so that code remains compatible with each new
version of Windows. I thought that I had found such a method through the
regitry. Vista proves me wrong, however, because MS changed the location of
the key values due to the new 'Roaming' and 'Local' sub keys of the registry
key path just as is the case with the file directory path. A method to
enumerate the special folders for the current user exists but I have found no
method that produces the Default User profile.

As it stands, it appears that I will have to hard code the folder location
for systems that have Vista as the OS. MS shouldn't make it such a chore
considering the functionality of a default profile.

BTW, HKU\.DEFAULT also serves as a template for new users and if you look at
the contents of the key I mentioned earlier you will see that it contains the
location of the special folders for default user.

Thanks for your efforts, Dave.

Tom Gilmour
Tecsult Inc.

"Dave Patrick" wrote:
Quote:

> HKEY_USERS\.DEFAULT is the hive that's loaded when no one is logged on.
> Generally the system account (NT Authority). The default user hive is
> located at;
>
> Vista;
> C:\Users\Default\ntuser.dat
>
> Windows 2000 / XP;
> C:\Documents and Settings\Default User\ntuser.dat
>
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
My System SpecsSystem Spec
Old 10-22-2008   #4 (permalink)
Dave Patrick


 
 

Re: How to locate the 'Default User' profile

I'm sorry but that info is incorrect.

http://blogs.msdn.com/oldnewthing/ar...2/1786493.aspx


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect


"RigB" wrote:
Quote:

> I am aware of the location of the folder. I was wondering if there was a
> reliable way of locating it regardless of the version of OS. From what I
> gather there is none. I've been searching everywhere for a solution
> without
> success. Microsoft encourages programmers to use proper methods to
> enumerate
> special folder locations so that code remains compatible with each new
> version of Windows. I thought that I had found such a method through the
> regitry. Vista proves me wrong, however, because MS changed the location
> of
> the key values due to the new 'Roaming' and 'Local' sub keys of the
> registry
> key path just as is the case with the file directory path. A method to
> enumerate the special folders for the current user exists but I have found
> no
> method that produces the Default User profile.
>
> As it stands, it appears that I will have to hard code the folder location
> for systems that have Vista as the OS. MS shouldn't make it such a chore
> considering the functionality of a default profile.
>
> BTW, HKU\.DEFAULT also serves as a template for new users and if you look
> at
> the contents of the key I mentioned earlier you will see that it contains
> the
> location of the special folders for default user.
>
> Thanks for your efforts, Dave.
>
> Tom Gilmour
> Tecsult Inc.
My System SpecsSystem Spec
Old 10-22-2008   #5 (permalink)
RigB


 
 

Re: How to locate the 'Default User' profile

I see, says the blind man... Never the less, what I thought was a dependable
way to enumerate the Default User profile is broken ;?( For the time being,
I'm just going to check the installed version of Windows and use a hard coded
path.

Thanks for the lesson,

Tom Gilmour
Tecsult Inc.

"Dave Patrick" wrote:
Quote:

> I'm sorry but that info is incorrect.
>
> http://blogs.msdn.com/oldnewthing/ar...2/1786493.aspx
>
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
>
> "RigB" wrote:
Quote:

> > I am aware of the location of the folder. I was wondering if there was a
> > reliable way of locating it regardless of the version of OS. From what I
> > gather there is none. I've been searching everywhere for a solution
> > without
> > success. Microsoft encourages programmers to use proper methods to
> > enumerate
> > special folder locations so that code remains compatible with each new
> > version of Windows. I thought that I had found such a method through the
> > regitry. Vista proves me wrong, however, because MS changed the location
> > of
> > the key values due to the new 'Roaming' and 'Local' sub keys of the
> > registry
> > key path just as is the case with the file directory path. A method to
> > enumerate the special folders for the current user exists but I have found
> > no
> > method that produces the Default User profile.
> >
> > As it stands, it appears that I will have to hard code the folder location
> > for systems that have Vista as the OS. MS shouldn't make it such a chore
> > considering the functionality of a default profile.
> >
> > BTW, HKU\.DEFAULT also serves as a template for new users and if you look
> > at
> > the contents of the key I mentioned earlier you will see that it contains
> > the
> > location of the special folders for default user.
> >
> > Thanks for your efforts, Dave.
> >
> > Tom Gilmour
> > Tecsult Inc.
>
>
My System SpecsSystem Spec
Old 10-22-2008   #6 (permalink)
James Whitlow


 
 

Re: How to locate the 'Default User' profile

"RigB" <RigB@xxxxxx> wrote in message
news38B6FC3-9EC5-41B7-8549-2B9430C2EEFF@xxxxxx
Quote:

>I have a script that copies Office templates and toolbars to 3 separate
> locations in the user's profiles at logon. I also update the 'Default
> User'
> profile so that the templates will be available should another user login
> to
> the workstation. I've been looking up the location with a query of the
> 'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
> Folders\Desktop' key in the registry. It works fine in Windows XP,
> however,
> the key no longer exists on Vista installations! Is there a prefered
> method
> of accomplishing this task?
I have not tried this on Vista, but you should be able to get the paths
you are looking for with the 'Environment' & 'SpecialFolders' methods of
'WScript.Shell'

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set oWSH = CreateObject("WScript.Shell")
MsgBox oWSH.Environment("Process").Item("AllUsersProfile")
MsgBox oWSH.SpecialFolders("AllUsersDesktop")
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

http://msdn.microsoft.com/en-us/libr...xe(VS.85).aspx
http://msdn.microsoft.com/en-us/libr...dd(VS.85).aspx



My System SpecsSystem Spec
Old 10-22-2008   #7 (permalink)
Tom Lavedas


 
 

Re: How to locate the 'Default User' profile

On Oct 22, 8:42*am, "James Whitlow" <jwhitlow.60372...@xxxxxx>
wrote:
Quote:

> "RigB" <R...@xxxxxx> wrote in message
>
> news38B6FC3-9EC5-41B7-8549-2B9430C2EEFF@xxxxxx
>
Quote:

> >I have a script that copies Office templates and toolbars to 3 separate
> > locations in the user's profiles at logon. I also update the 'Default
> > User'
> > profile so that the templates will be available should another user login
> > to
> > the workstation. I've been looking up the location with a query of the
> > 'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
> > Folders\Desktop' key in the registry. It works fine in Windows XP,
> > however,
> > the key no longer exists on Vista installations! Is there a prefered
> > method
> > of accomplishing this task?
>
> * * I have not tried this on Vista, but you should be able to get thepaths
> you are looking for with the 'Environment' & 'SpecialFolders' methods of
> 'WScript.Shell'
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Set oWSH = CreateObject("WScript.Shell")
> MsgBox oWSH.Environment("Process").Item("AllUsersProfile")
> MsgBox oWSH.SpecialFolders("AllUsersDesktop")
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> http://msdn.microsoft.com/en-us/libr...dd(VS.85).aspx
I don't believe AllUsers is the same as Default User. At least my XP
machine has two separate locations for these two.

However, it is clear that the OS can figure it out. I looked at the
more expansive Shell.Application list of special folders (included
below) and it doesn't list a Default Users folder in its constants.

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(hSpecialFolderConstant)

Constant Special Folder
-------- --------------
&H1& Internet Explorer
&H2& Programs
&H3& Control Panel
&H4& Printers and Faxes
&H5& My Documents
&H6& Favorites
&H7& Startup
&H8& My Recent Documents
&H9& SendTo
&Ha& Recycle Bin
&Hb& Start Menu
&Hd& My Music
&He& My Videos
&H10& Desktop
&H11& My Computer
&H12& My Network Places
&H13& NetHood
&H14& Fonts
&H15& Templates
&H16& All Users Start Menu
&H17& All Users Programs
&H18& All Users Startup
&H19& All Users Desktop
&H1a& Application Data
&H1b& PrintHood
&H1c& Local Settings\Application Data
&H19& All Users Favorites
&H20& Local Settings\Temporary Internet Files
&H21& Cookies
&H22& Local Settings\History
&H23& All Users Application Data
&H24& Windows
&H25& System32
&H26& Program Files
&H27& My Pictures
&H28& User Profile
&H2b& Common Files
&H2e& All Users Templates
&H2f& Administrative Tools
&H31& Network Connections

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Old 10-22-2008   #8 (permalink)
James Whitlow


 
 

Re: How to locate the 'Default User' profile

"Tom Lavedas" <tglbatch@xxxxxx> wrote in message
news:8fa0f85d-1b1f-4689-b595-80241b872f73@xxxxxx
Quote:

> I don't believe AllUsers is the same as Default User. At least my XP
> machine has two separate locations for these two.
Woops, oversight on my part. Thanks, Tom!
Quote:

> However, it is clear that the OS can figure it out. I looked at the
> more expansive Shell.Application list of special folders (included
> below) and it doesn't list a Default Users folder in its constants.
>
> Set objShell = CreateObject("Shell.Application")
> Set objFolder = objShell.Namespace(hSpecialFolderConstant)
I seldom use 'Shell.Application'. I really need to start harnessing it's
power more.


My System SpecsSystem Spec
Old 10-22-2008   #9 (permalink)
mayayana


 
 

Re: How to locate the 'Default User' profile

Quote:

> I seldom use 'Shell.Application'. I really need to start harnessing it's
> power more.
>
It seems to be a wrapper around the APIs
that MS recommends for finding folder paths.
(SHGetSpecialFolderLocation, etc. and the
SHGetFolderPath* from the more recent
shfolder.dll.) Unfortunately, part of the reason
they needed those APIs in the first place is
the inconsistency with folder paths in the past.
Different Windows versions have different paths
and varying support for the APIs. Likewise, support
for the Shell.App functionality varies between
systems. One always needs to be prepared for
a possible blank return.




My System SpecsSystem Spec
Old 10-22-2008   #10 (permalink)
Stefan Kanthak


 
 

Re: How to locate the 'Default User' profile

"James Whitlow" <jwhitlow.60372693@xxxxxx> wrote:
Quote:

> "RigB" <RigB@xxxxxx> wrote in message
> news38B6FC3-9EC5-41B7-8549-2B9430C2EEFF@xxxxxx
Quote:

>>I have a script that copies Office templates and toolbars to 3 separate
>> locations in the user's profiles at logon. I also update the 'Default
>> User'
>> profile so that the templates will be available should another user login
>> to
>> the workstation. I've been looking up the location with a query of the
>> 'HKEY_USERS\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell
>> Folders\Desktop' key in the registry. It works fine in Windows XP,
>> however,
>> the key no longer exists on Vista installations! Is there a prefered
>> method
>> of accomplishing this task?
Did your OLEXP create these poor linebreaks? (I don't see the OP, posters
without real name and with known invalid domains are filtered.)
Quote:

> I have not tried this on Vista, but you should be able to get the paths
> you are looking for with the 'Environment' & 'SpecialFolders' methods of
> 'WScript.Shell'
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Set oWSH = CreateObject("WScript.Shell")
> MsgBox oWSH.Environment("Process").Item("AllUsersProfile")
> MsgBox oWSH.SpecialFolders("AllUsersDesktop")
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> http://msdn.microsoft.com/en-us/libr...xe(VS.85).aspx
> http://msdn.microsoft.com/en-us/libr...dd(VS.85).aspx
The "Default User" profile is NOT the "All Users" profile!

And (as Tom Lavedas already pointed out) there's no namespace item
for the "Default User" profile, neither in VB (resp. the WSH) nor
in the Setup-API which can be used with .INF files.

There are but several ways to get its location:

1. Use the following entry in your WINNT.SIF/UNATTEND.TXT during
an unattended installation (see MSKB 216518) to create the
environment variable %DefaultUserProfile%:

[SetupParams]
UserExecute = "%SystemRoot%\System32\Reg.Exe" Add "HKLM\System\CurrentControlSet\Control\Session Manager\Environment" /V
"DefaultUserProfile" /T REG_SZ /D "%UserProfile%" /F

During the GUI phase of the Windows 2000/XP setup the "Default User"
profile is used as the user profile.

2. IFF you are really old-fashioned use the command given in 1. in
the \$OEM$\CMDLINES.TXT (see MSKB 249149 for example).

3. Read [HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList]
REG_EXPAND_SZ:ProfilesDirectory holds the base path and
REG_SZefaultUserProfile holds the directory name.

4. Use one of the following in a .CMD-Script (or its equivalent in a
VBScript):

Set DefaultUserProfile=%ALLUSERSPROFILE%\..\Default User
Set DefaultUserProfile=%ALLUSERSPROFILE:\All Users=\Default User%
For %! In ("%ALLUSERSPROFILE%") Do Set DefaultUserProfile=%~dp!Default User


Stefan

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to make a standard profile w/ Default User Vista account administration
Vista Roaming Profile Questions (Default Profile & User Folder on Desktop) Vista networking & sharing
how to copy wista user profile to default profile Vista account administration
Default user profile Vista General
Vist Default User Profile Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46