i know how to see if an environmental variable exists, e.g: %comspec%, and to see what it contains, but does anyone/can anyone point me to a tutorial on how to make/edit your own variables using COM
Maybe adding a key to the Registry:
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Control/Session Manager/Environment
Same for ControlSet002 and CurrentControlSet, I don't know who is the default one.
ControlSet002
...i dont have that one... but i do got
ControlSet003
...does that make much diff?
PS:
also.. how to add in the new key?
do i write to a .reg file.. and then run it?
if so how do ya output binary info..
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment]
"windir"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,\
00,25,00,00,00
would set %windir% to %SystemRoot%
how to get the hex vailue for doing that is my question..
a /regwrite alias i made can write to: HKLM\test but not where environment vars are stored.
mmmmm indeed...
The only way to set an env variable is using under cmd.exe
set variable=blabla
Typing under cmd.exe echo %variable% returns blabla
Nothing found in the registry about "blabla".
so i could just make a /run alias to hide the window set a var and close when it's finished.
ok ty
I think you should be using HKCU\Environment\
Either way, I doubt if it would become available until Windows reads the registry entry again, which is usually at Logon.
http://www.mircscripts.org/comments.php?id=963mIRC-Env 1.0 by codemastr
DLL to set/read windows environment variables.
i was hoping that i wouldn't have to use a dll, i use 3 already -_-
same result, his $regwrite and my /regwrite can't write to that key for some reason.
See above
I think you should be using HKCU\Environment\
Either way, I doubt if it would become available until Windows reads the registry entry again, which is usually at Logon
I just tested with
//echo -a $regwrite(HKCU\Environment\Sheep,Baaa)
and it worked fine (after logoff/logon or opening/closing "sysdm.cpl > Advanced > Environment Variables")
I don't know of a way to force Windows to reread the registry hives
maybe somoene else does...
opening/closing "sysdm.cpl
well all that need to be done now is use smd.exe to do that to..
maybe mIRC should be programmed to directly manipulate cmd.exe better as its a good work around for almost n e thing :-/
even though this has nothing to do with my original question, i'll ask here considering the post title is $com
in cmd.exe/msdos.com you can type:
but you cannot retrieve %rand% the same way as %windir% or %comspec% anyone know why?
If you say so...
That just leaves a different question though.
WTH has cmd.exe got to do with opening comtrol panel applets?
Where, when and how is %rand% being set?
BTW You don't need "@echo on" as that is the default.
not a clue when where or how, i assumed it was in all systems, type: set /? in cmd.exe and on the last "page" of info it says about %rand%
i'm on XP, not sure if it's on all systems
alias envar {
if !$1 { return }
if $com(a) { .comclose a }
.comopen a WScript.Shell
if $comerr { return }
var %a $com(a,ExpandEnvironmentStrings,3,bstr,$iif($+($chr(37),*,$chr(37)) !iswm $1,$+($chr(37),$1,$chr(37)),$1))
%a = $iif($left($com(a).result,1) != $chr(37),1,0)
return $iif($prop == value,$iif(%a == 0,%a,$com(a).result),%a)
.comclose a
}
//echo -a $envar(windir) - returns 1
//echo -a $envar(random) - returns 0
it can't be retrieved the same way as %windir% for some reason.
Well, that is part of 'Command Extensions' which is only available to cmd.exe AFAIK.
I don't know, seeing as how it's already possible (at least here) with /run rundll32.exe shell32.dll,Control_RunDLL whatever.cpl
Yeah. for XP it's
/run sysdm.cpl That doesn't account for the rest it though,
opening/closing "sysdm.cpl > Advanced > Environment Variables"/run rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,3
Gets as far as "opening/closing "sysdm.cpl > Advanced" but still not to the "environment variables" page