UNSET a Variable

Jul 12, 2008
286
0
Las Vegas, NV
I have a system variable [LFMBROWSER] that I ran a command on

unset /s /u LFMBROWSER

But it still is showing via the "set" command, and in MyComputer / Advanced System Settings / Environment Variables

What am I doing wrong?

Regards,
Chuck Billow
 
May 20, 2008
11,432
99
Syracuse, NY, USA
1. It doesn't make much sense to use both /s and /u
2. No surprise it's still in TCC's environment; you didn't unset it there (that's what /e is for)
3. Do you close/reopen the system variables dialog? Here (Win7), it disappears.

Brief tutorial: Every process inherits the environment of its parent process. From then on that environment belongs solely to that process. In the case of TCC you manipulate it with [un]set and whatever it is at the moment is passed to (TCC) child processes. When you use /s or /u you're manipulating environments stored in the registry (/u ... the HKEY_CURRENT_USER one ... used at login, /s ... the HKEY_LOCAL_MACHINE one ... used at startup) and broadcasting a message saying that you did that. As I said before, Explorer updates its own environment as a result of receiving that message (few other apps do). If you want to **also** affect the current TCC environment when you use /s or /u, then also use /e.
 
Jul 12, 2008
286
0
Las Vegas, NV
Vince, I used both /s and /u in case I was " missing something."

"All" I am trying to do is: set a var to represent the given browser, so that any btm file can call LFMBROWSER and get the browser I want at that "moment." That way any number of shortcuts that rely on a browser will use the one I want.

So...

If I set up a shortcut with

%LFMBROWSER% http://www.last.fm/listen/artist/Chicago/similarartists

I can control which browser attaches to that link.

THEN I fond that I had to account for vars being already set [as you undoubtedly are aware.

The shortcut I have now is [for example]

%LFMBROWSER% http://www.last.fm/listen/globaltags/60s

So then I thought [silly me] that I should use a batch file. Within that bat [btm] file, I could set / verify the browser that would be called -- not always the default browser. Then, because I had set several shortcuts to call the browser via %LFMBROWSER%, I came to the problem of setting and unsetting a TCC / TCMD variable.

This of course is assuming that, by associating btm files to TCC [for example], I would be in a TCC environment when I executed a shortcut.

I THOUGHT I understood what you were telling me, but obviously I am having a senior moment.

Chuck
 
May 20, 2008
11,432
99
Syracuse, NY, USA
TCC /TCMD has nothing to do with your shortcuts that have the %LFMBROWSER% target. That's Explorer's business. If you want to change Explorer's idea of what %LFMBROWSER% means, TCC is one way to do that. Just "SET /U LFMBROWSER=some-browser" ... want to change the browser ... "SET /U LFMBROWSER=some_other_browser". That changes some info in a registry key and announces (to any app that's interested) that such a change was made. Explorer gets the announcement and changes its own (i.e., Explorer's) environment so it (Explorer) has a new notion of what %LFMBROWSER% means and does the right thing when you 2click a shortcut.
 
Jul 12, 2008
286
0
Las Vegas, NV
Vince, so then I could have a btm file to set the variable that reads

"SET /U LFMBROWSER=some-browser"

and then the shortcut to any specific link would just read "LFMBROWSER http://somewhere.com"?

It would "stick" as long as I was logged in? I wouldn't need to worry about system assignments? I wouldn't have to unset any previous assignment?

Then I could either assign the variable and then use "LFMBROWSER http://somsite.com" as the site shortcut, and control the browser with the one-line SET /U assignment?

I wouldn't have to differentiate between system and personal variables or anything else?

Chuck
 
May 20, 2008
11,432
99
Syracuse, NY, USA
Vince, so then I could have a btm file to set the variable that reads

"SET /U LFMBROWSER=some-browser"

and then the shortcut to any specific link would just read "LFMBROWSER http://somewhere.com"?

It would "stick" as long as I was logged in? I wouldn't need to worry about system assignments? I wouldn't have to unset any previous assignment?

Then I could either assign the variable and then use "LFMBROWSER http://somsite.com" as the site shortcut, and control the browser with the one-line SET /U assignment?

I wouldn't have to differentiate between system and personal variables or anything else?

Chuck

Yes. And it would stick forever. That's the point of the /u and /s environments; they're saved and reinstated upon login or restart (respectively). Change it and the new one will be remembered until you change it again. All users get the variables assigned with /S; **you** get (at login) the ones assigned with /U. I wouldn't even bother with the /S environment (you wouldn't even see your shortcuts if you logged in as another user). If you want to see where these are saved, use REGEDIT.EXE and navigate to HKEY_CURRENT_USER\Environment and to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. When you login, the two environments are merged and become the environment of the shell (Explorer). All processes are free to mess with their own environment (as with SET var=value); these changes are propagated to child processes but no up to parent processes.
 
Jul 12, 2008
286
0
Las Vegas, NV
I got it -- I THINK. I was having problems, but I found out that the quotation marks were the problem.

This SHOULD work.

Thanks Vince.

Regards,
Chuck
 
Similar threads
Thread starter Title Forum Replies Date
samintz WAD Cannot unset .py[co] Support 2
dcantor Documentation Documentation error in UNSET Support 0
Stefano Piccardi 14.01.33 unset doesn't complain about undefined variables Support 8
Stefano Piccardi 13.0.0.21 unset /V foo error Support 1
J Strange error: unset /s Support 14
J Issue with unset? Support 1
D Parsing an array variable to an array does not work Support 5
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
P Inserting string into a variable. Support 3
vefatica Setting array variable ignores leading spaces (and @execarray doesn't) Support 4
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
R Difference between TCC and CMD: variable names with hyphens Support 4
Joe Caverly Get a variable type Support 2
M How to set Path variable for non-executable file extensions in 4DOS Support 8
rps For loop internal %_for_files variable? Support 2
A How to safely print variable's value without quotes? Support 9
vefatica Array name in a variable? Support 3
nikbackm TCC 20 variable expansion bug Support 6
X How to set %_INIREAD result to variable Support 5
Charles Dye _USBS variable Support 2
BeechComer Debugger: how to set %1 variable? Support 3
Mordachai Variable followed by function constantly failing... Support 5
T Variable indirection for arrays Support 1
Mike Hall Unexpected "Variable loop" in IF condition Support 10
vefatica If there's no PATH variable ... Support 5
C Maximum length for a variable Support 8
D WAD Internal variable _cpu is undefined Support 2
fpefpe How to? Global variable set /v Support 4
I Change value of a variable while debugging Support 3
I "IF" command in a variable does not expand redirection variable name Support 0
J Variable setting regression in tcc17 ? Support 5
Jay Sage WAD Variable _LOGFILE Not Working Support 2
D Fixed Change in behavior of variable expansion between 16 and 17 Support 3
rps Fixed Using last argument variable ! Support 5
Jay Sage Brackets Around Variable Names Support 11
D Internal variable _tctabs within TCExit Support 9
vefatica WAD Nested variable expansion in PDIR's @function[*]? Support 13
J Set environment variable from stdout of command Support 3
nickles Passing a variable to a command w/o adding it to the local environment Support 7
nickles WAD Variable name gets changed within FOR loop Support 2
nikbackm FUNCTION with variable number of arguments Support 17
rfaquino WAD Apparently a bug when expanding environment variable %ProgramFiles(x86) Support 2
S WAD %_do_errors does not report errors when loop control variable type is not directory entry Support 1
B WAD environment variable in TCC.exe Support 2
Frank watch an array variable in ide/bdebugger Support 2
vefatica Conditional expressions in a variable? Support 2
M Updating environment variable from C++ fails erratically in version 14... Support 57
Frank problem with environment variable x86 vs. x64 Support 2
Charles Dye Unbalanced parentheses in variable expansion Support 12
D WAD Multiple TEE causese weird variable scoping? Support 7

Similar threads