midiboy Posted November 21, 2006 Posted November 21, 2006 (edited) Hi guys,looking for a way to query the Local appdata folder from the registryFOR /F "TOKENS=3 DELIMS= " %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Local AppData"') do set LocalAppData=%%iHowever that does not work. This line works fine for extracting the personal folder but not for the local appdata folder. Any ideas, why ?Thanks a lot for your help !Alex Edited November 21, 2006 by midiboy
Yzöwl Posted November 21, 2006 Posted November 21, 2006 That folder already has a variable %APPDATA%!However your command looks okay, which means that, you've probably got:DELIMS=<space><space><space><space>"instead of:DELIMS=<tab>"
midiboy Posted November 21, 2006 Author Posted November 21, 2006 (edited) Hi Yzöwl,Thanks for helping out ! mhh, first, %APPDATA% points to "%Profiles%\Appdata" not to "%Profiles%\Local settings\Appdata" :-)Second, I just tested it again and the line works fine in Windows XP but not in Windows 2003 Server even though the registry keys look identical.Any ideas why it does not work ? It seems like the whole line is not even processed. In Windows XP I can see a line "set LocalAppData=C:\...." before the echo statement, which is missing in Windows 2003 Server. Thanks,AlexPS: That is a <TAB> in there Edited November 21, 2006 by midiboy
Yzöwl Posted November 21, 2006 Posted November 21, 2006 SuggestionTry changing User Shell Folders to Shell Folders so that you are reading a REG_SZ key.
midiboy Posted November 21, 2006 Author Posted November 21, 2006 Hi Yzöwl,actually I did that already as you can see in the pic. I am gonna change the code example in the first post to reflect that.Does not help though .. Bye,ALex
Yzöwl Posted November 21, 2006 Posted November 21, 2006 Before GSM jumps in with a VBS solution, here is a hybrid batch /vbs offering.@ECHO OFFSETLOCAL>"%TEMP%\_.VBS" ECHO/Wscript.Echo CreateObject("Shell.Application").Namespace(^&H1C^&).Self.PathFOR /F "DELIMS=" %%? IN ('CSCRIPT /Nologo "%TEMP%\_.VBS"') DO (SET LAppData=%%?)DEL "%TEMP%\_.VBS"ECHO/ECHO/ Your local application data repository is:ECHO/ %LAppData%ECHO/ENDLOCALGOTO :EOFLines 2, 3 & 4 are the important ones!
gunsmokingman Posted November 21, 2006 Posted November 21, 2006 Before GSM jumps in with a VBS solution, here is a hybrid batch /vbs offering.I just could not stop myself, so here my hybird versionDim Act, AppData AppData = CreateObject("Shell.Application").Namespace(&H1C&).Self.PathSet Act = CreateObject("Wscript.Shell")Act.Run("%Comspec% /C @Echo Off && CLS && Mode 85,9 && Title AppData Directory &&"&_ "Color F3 && Echo. && Echo Your local application data repository is:"&_ "&& Echo " & AppData & "&& Pause"),1,True
midiboy Posted November 21, 2006 Author Posted November 21, 2006 Hey !Jesus you 2 are good ! Thanks a lot for this one Yzöwl and gunsmokingman! Bye,Alex
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now