What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Environment variables

Environment variables
Author: Message:
wincy
Junior Member
**


Posts: 67
Reputation: 4
34 / Male / Flag
Joined: Feb 2008
O.P. Undecided  Environment variables
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
02-12-2009 07:10 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Environment variables
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]

.jpg File Attachment: enviro_var.jpg (36.23 KB)
This file has been downloaded 231 time(s).

This post was edited on 02-12-2009 at 07:39 PM by matty.
02-12-2009 07:34 PM
Profile E-Mail PM Find Quote Report
wincy
Junior Member
**


Posts: 67
Reputation: 4
34 / Male / Flag
Joined: Feb 2008
O.P. RE: Environment variables
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.

This post was edited on 02-12-2009 at 09:51 PM by wincy.
02-12-2009 09:50 PM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Environment variables
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.
02-12-2009 10:37 PM
Profile E-Mail PM Find Quote Report
wincy
Junior Member
**


Posts: 67
Reputation: 4
34 / Male / Flag
Joined: Feb 2008
O.P. RE: Environment variables
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?

This post was edited on 02-12-2009 at 11:00 PM by wincy.
02-12-2009 10:59 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On