How do I enable %UserProfile% for scripting with Folder Redirection?

vbscript

Solution

I think SpecialFolders is what you are looking for

Depo=oShell.SpecialFolders("Desktop") & "\Test"

It will return the location of the Desktop-folder also with Redirected Folders.

Problem

I'm experimenting with Folder Redirection and after getting it set up, I quickly realized that any VBS scripts that have environmental variables such as %UserProfile% become unusable. For example: ``` C:\MD %UserProfile%\Desktop\Not_Created_On_Real_Desktop\ ``` And ``` 'Place to deposit excel output file Depo=oShell.ExpandEnvironmentStrings("%userprofile%" & "\Desktop\Folder_This_User_Needs_Easy_Access_To\") if not objfso.folderexists(Depo) then objFSO.CreateFolder(Depo) end if ``` These no longer work when using Folder Redirection. I'm hoping there is a work around for this because a lot of my existing scripts depend on this variable remaining valid. I've found that .NET is able to pull the redirected folder with: ``` Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) ``` I haven't had much luck find an equivalent for VBS though. Any help is appreciated. Thanks!

Original source