Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSIDL_LOCAL_APPDATA, or Local Settings\Application Data: Help! :( 1

Status
Not open for further replies.

Stick1337

Programmer
Dec 3, 2008
8
US
I just realized that I need to move some files from folder x to C:\Documents and Settings\{User}\Local Settings\Application Data\ and NOT to C:\Documents and Settings\{User}\Application Data

I can't for the life of me figure out how to get the path for this folder! In searching, I've come across a bunch of convoluted stuff (re: CSIDL_LOCAL_APPDATA) that supposedly works in VB -- but not in VBScript (which I'm running in WSH).

Has anyone else run into this problem? Does anyone have any solutions? If not, I suppose I can hack at the non-local version and fake it, but I'd rather not...thanks in advance!
 
Dim oWSN:Set oWSN = CreateObject("WScript.Network")
strPath = "C:\Documents ad Setings\"& oWSN.UserName & "\Local Setings\Application Data\"

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks, EBGreen! I'll definitely look into the WScript.Network object. (I just started messing with WSH and VBScript last night, so I'm well below even n00b status.)
 
Code:
Option Explicit

Private Const ssfLOCALAPPDATA = &H1C&

With CreateObject("Shell.Application").NameSpace(ssfLOCALAPPDATA).Self
  MsgBox .Path
End With
 
The EBGreen example can fail on two counts.

For one the folder username may not be the same as the user's display name he logs on with (usually due to user renaming). For another the path format has changed in Vista and later OSs.
 
Good points.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
dilettante, thank you for your insights! I'll definitely give that a shot...

...and it works! Excellent! Thank you very much for your time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top