Jump to content

Recommended Posts

Posted (edited)

Hi guys,

looking for a way to query the Local appdata folder from the registry

FOR /F "TOKENS=3 DELIMS=	" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Local AppData"') do set LocalAppData=%%i

However 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 by midiboy

Posted

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>
"

Posted (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,

Alex

PS: That is a <TAB> in there :hello:

Edited by midiboy
Posted

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 .. :no:

Bye,

ALe

x

Posted

Before GSM jumps in with a VBS solution, here is a hybrid batch /vbs offering.

@ECHO OFF
SETLOCAL
>"%TEMP%\_.VBS" ECHO/Wscript.Echo CreateObject("Shell.Application").Namespace(^&H1C^&).Self.Path
FOR /F "DELIMS=" %%? IN ('CSCRIPT /Nologo "%TEMP%\_.VBS"') DO (SET LAppData=%%?)
DEL "%TEMP%\_.VBS"
ECHO/
ECHO/ Your local application data repository is:
ECHO/ %LAppData%
ECHO/
ENDLOCAL
GOTO :EOF

Lines 2, 3 & 4 are the important ones!

Posted
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 version
Dim Act, AppData 
AppData = CreateObject("Shell.Application").Namespace(&H1C&).Self.Path
Set 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...