Shoutbox

Environment variables - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Environment variables (/showthread.php?tid=89134)

Environment variables by wincy on 02-12-2009 at 07:10 PM

Hello everybody!

I need to get system environment variables (see Wikipedia) and write them in a file.

They are stored here:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

But i need them to be like this:
"Templates=C:\DOCUME~1\User\Models"

And not like this:
"Templates"="C:\\Documents and Settings\\Vincy\\Modelli"

How can i do that, in JScript or batch?
Thanks


RE: Environment variables by matty on 02-12-2009 at 07:34 PM

MSDN is your friend...

GetEnvironmentVariable
SetEnvironmentVariable

Or use the WMI Class Win32_Environment to enumerate them.

quote:
Originally posted by wincy
They are stored here:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
Those are not environment variables; they are special folders that you can use SHGetFolderPath or SHGetKnownFolderPath

These are environment variables:
[Image: attachment.php?pid=951659]
RE: Environment variables by wincy on 02-12-2009 at 09:50 PM

quote:
Those are not environment variables; they are special folders that you can use SHGetFolderPath or SHGetKnownFolderPath

I meant "Special Folders" then, sorry!
I've been looking for hours on Internet in order to find something useful!

I would like to have outputs like this (for example):
C:\DOCUME~1\Vincy\IMPOST~1\DATIAP~1\MICROS~1
but i don't know how to do that.

I saw this:
HRESULT SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);
but i'm not exactly understanding how to use that..!
Should i put it in a .vbs file?

Moreover, i found a way to do that with FSO:
var favfolderName=Shell.SpecialFolders("Favorites");
but it give an output like this:
C:\Documents and Settings\User\Favorites
and those paths containing spaces cannot be read by batch files.
RE: Environment variables by matty on 02-12-2009 at 10:37 PM

quote:
Originally posted by wincy
and those paths containing spaces cannot be read by batch files.
You would just need to quotes around the string for it to be read.

RE: Environment variables by wincy on 02-12-2009 at 10:59 PM

I know, but i have to do everything dinamically.
I had an exe file which output was something like:

SET "Local AppData=C:\DOCUME~1\Vincy\IMPOST~1\DATIAP~1"
SET "Common Programs=C:\DOCUME~1\ALLUSE~1\MENUAV~1\PROGRA~1"


And i used those defined variables a batch file.

I'm trying to do the same thing without that exe file.
I've already tried saving HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders to a file, but results are something like:

"Local AppData"="C:\\Documents and Settings\\Vincy\\Impostazioni locali\\Dati applicazioni"

What can i do to define Special Folders' Paths in the batch file?