![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | find local profile path on XP Our users are using roaming profile. Using the login script I want to copy a file to a folder under their local profile on XP machine. However, I found it's not always under c:\document and settings\<username>\ instead many of them are actuall at c:\document and settings\<username.domain>\ How can I make login script detect the correct path? Is there a variable I can use in login script so it will check the current path during logon? Or a variable I can use in the copy command to the current path? Thanks. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: find local profile path on XP You can use %homedrive%\%homepath% and expand it using WScript.Shell's ExpandEnvironmentStrings method, like this, to get the user's root folder: dim WshShell: Set WshShell = CreateObject("WScript.Shell") userRoot = WshShell.ExpandEnvironmentStrings("%homedrive%%homepath%") However, this may NOT be what you really want. Is there a specific location under their home folders that you're after? There are other ways to get specific special folders using Shell.Application that may be preferable. There are special constants that refer to particular folders, and you can get the folder's path using the NameSpace method of Shell.Application. For instance, the value 5 is used for the personal My Documents folder and 16 is used for the personal Desktop folder. So whatever the actual customizations or language settings in effect on the system, the following code would capture the true My Documents and Desktop paths: Dim sa: Set sa = CreateObject("Shell.Application") MyDocsPath = sa.Namespace(5).Self.Path WScript.Echo MyDocsPath MyDesktopPath = sa.Namespace(16).Self.Path WScript.Echo MyDesktopPath "Chris" <Chris@xxxxxx> wrote in message news 0FD1056-7A5F-4F85-8071-76756D813D01@xxxxxxQuote: > Our users are using roaming profile. Using the login script I want to > copy a > file to a folder under their local profile on XP machine. However, I > found > it's not always under > c:\document and settings\<username>\ > > instead many of them are actuall at > > c:\document and settings\<username.domain>\ > > How can I make login script detect the correct path? > > Is there a variable I can use in login script so it will check the current > path during logon? Or a variable I can use in the copy command to the > current path? > > Thanks. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: find local profile path on XP The actually folder I want to copy file to is: C:\Documents and Setting\<UserNameHere>\Application Data\Microsoft\Signatures But the problem is that <username> can be either <username> or <username.domain>. The variable %homedrive%\%homepath% you mentioned is for home directory, not the profile path on the desktop, right? "Alex K. Angelopoulos" wrote: Quote: > > You can use %homedrive%\%homepath% and expand it using WScript.Shell's > ExpandEnvironmentStrings method, like this, to get the user's root folder: > > dim WshShell: Set WshShell = CreateObject("WScript.Shell") > userRoot = WshShell.ExpandEnvironmentStrings("%homedrive%%homepath%") > > > However, this may NOT be what you really want. Is there a specific location > under their home folders that you're after? There are other ways to get > specific special folders using Shell.Application that may be preferable. > There are special constants that refer to particular folders, and you can > get the folder's path using the NameSpace method of Shell.Application. For > instance, the value 5 is used for the personal My Documents folder and 16 is > used for the personal Desktop folder. So whatever the actual customizations > or language settings in effect on the system, the following code would > capture the true My Documents and Desktop paths: > > Dim sa: Set sa = CreateObject("Shell.Application") > MyDocsPath = sa.Namespace(5).Self.Path > WScript.Echo MyDocsPath > MyDesktopPath = sa.Namespace(16).Self.Path > WScript.Echo MyDesktopPath > > > > > > "Chris" <Chris@xxxxxx> wrote in message > news 0FD1056-7A5F-4F85-8071-76756D813D01@xxxxxxQuote: > > Our users are using roaming profile. Using the login script I want to > > copy a > > file to a folder under their local profile on XP machine. However, I > > found > > it's not always under > > c:\document and settings\<username>\ > > > > instead many of them are actuall at > > > > c:\document and settings\<username.domain>\ > > > > How can I make login script detect the correct path? > > > > Is there a variable I can use in login script so it will check the current > > path during logon? Or a variable I can use in the copy command to the > > current path? > > > > Thanks. > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: find local profile path on XP Alex, I tried your 2nd script and I could use it. Just need to know what the values are for namespace. Is there one for signatures folder? "Alex K. Angelopoulos" wrote: Quote: > > You can use %homedrive%\%homepath% and expand it using WScript.Shell's > ExpandEnvironmentStrings method, like this, to get the user's root folder: > > dim WshShell: Set WshShell = CreateObject("WScript.Shell") > userRoot = WshShell.ExpandEnvironmentStrings("%homedrive%%homepath%") > > > However, this may NOT be what you really want. Is there a specific location > under their home folders that you're after? There are other ways to get > specific special folders using Shell.Application that may be preferable. > There are special constants that refer to particular folders, and you can > get the folder's path using the NameSpace method of Shell.Application. For > instance, the value 5 is used for the personal My Documents folder and 16 is > used for the personal Desktop folder. So whatever the actual customizations > or language settings in effect on the system, the following code would > capture the true My Documents and Desktop paths: > > Dim sa: Set sa = CreateObject("Shell.Application") > MyDocsPath = sa.Namespace(5).Self.Path > WScript.Echo MyDocsPath > MyDesktopPath = sa.Namespace(16).Self.Path > WScript.Echo MyDesktopPath > > > > > > "Chris" <Chris@xxxxxx> wrote in message > news 0FD1056-7A5F-4F85-8071-76756D813D01@xxxxxxQuote: > > Our users are using roaming profile. Using the login script I want to > > copy a > > file to a folder under their local profile on XP machine. However, I > > found > > it's not always under > > c:\document and settings\<username>\ > > > > instead many of them are actuall at > > > > c:\document and settings\<username.domain>\ > > > > How can I make login script detect the correct path? > > > > Is there a variable I can use in login script so it will check the current > > path during logon? Or a variable I can use in the copy command to the > > current path? > > > > Thanks. > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: find local profile path on XP "Chris" <Chris@xxxxxx> wrote in message news:A00A7710-2DFF-4541-A607-D6E23A43EADD@xxxxxx Quote: > Alex, > I tried your 2nd script and I could use it. Just need to know what the > values are for namespace. Is there one for signatures folder? operating system folders, not folders they may contain. That's _probably_ sufficient, because you can construct the path to Microsoft\Signatures from the roaming appdata folder like this: sigpath = sa.Namespace(5).Self.Path & "\Microsoft\Signatures" There _may_ be a problem with this if the location of the Signatures folder is ever customized; there is a value named Signatures in the registry under the key HKCU\Software\Microsoft\Office\<version# - 11.0, 12.0, etc>\Common\General If this is never changed - and probably it's not - you're fine. If this does get customized, it's also possible to make the code more robust to handle it, but I'm not sure about what shows up there when it IS customized. I would suggest that using the technique above will probably do what you want unless you ever start explicitly redirecting that folder. Quote: > "Alex K. Angelopoulos" wrote: > Quote: >> >> You can use %homedrive%\%homepath% and expand it using WScript.Shell's >> ExpandEnvironmentStrings method, like this, to get the user's root >> folder: >> >> dim WshShell: Set WshShell = CreateObject("WScript.Shell") >> userRoot = WshShell.ExpandEnvironmentStrings("%homedrive%%homepath%") >> >> >> However, this may NOT be what you really want. Is there a specific >> location >> under their home folders that you're after? There are other ways to get >> specific special folders using Shell.Application that may be preferable. >> There are special constants that refer to particular folders, and you can >> get the folder's path using the NameSpace method of Shell.Application. >> For >> instance, the value 5 is used for the personal My Documents folder and 16 >> is >> used for the personal Desktop folder. So whatever the actual >> customizations >> or language settings in effect on the system, the following code would >> capture the true My Documents and Desktop paths: >> >> Dim sa: Set sa = CreateObject("Shell.Application") >> MyDocsPath = sa.Namespace(5).Self.Path >> WScript.Echo MyDocsPath >> MyDesktopPath = sa.Namespace(16).Self.Path >> WScript.Echo MyDesktopPath >> >> >> >> >> >> "Chris" <Chris@xxxxxx> wrote in message >> news 0FD1056-7A5F-4F85-8071-76756D813D01@xxxxxxQuote: >> > Our users are using roaming profile. Using the login script I want to >> > copy a >> > file to a folder under their local profile on XP machine. However, I >> > found >> > it's not always under >> > c:\document and settings\<username>\ >> > >> > instead many of them are actuall at >> > >> > c:\document and settings\<username.domain>\ >> > >> > How can I make login script detect the correct path? >> > >> > Is there a variable I can use in login script so it will check the >> > current >> > path during logon? Or a variable I can use in the copy command to the >> > current path? >> > >> > Thanks. >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Issue with $profile being set to d:\\path... | PowerShell | |||
| Copy Local Profile to new Domain Profile | Vista General | |||
| Windows cannot find the local profile and is logging you on with a temporary profile. Changes you make to this profile will be lost when you log off. | Vista General | |||
| Local profile not found, logged on with a temporary profile | Vista account administration | |||
| Profile Path | Vista installation & setup | |||