setx loses quotes
Moderator: DosItHelp
setx loses quotes
I've been trying to use setx to set the path. My path is a bit long. I've used the variable rq to demonstrate the problem though.
When I set rq to a value blah;blah;blah , the double quotes always go.
C:\Documents and Settings\user>setx rq 54;^"f^";4 -m
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control
\Session Manager\Environment" | find "rq"
rq REG_SZ 54;f;4
C:\Documents and Settings\user>setx rq 541;"f";4 -m
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control
\Session Manager\Environment" | find "rq"
rq REG_SZ 541;f;4
C:\Documents and Settings\user>
When I set rq to a value blah;blah;blah , the double quotes always go.
C:\Documents and Settings\user>setx rq 54;^"f^";4 -m
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control
\Session Manager\Environment" | find "rq"
rq REG_SZ 54;f;4
C:\Documents and Settings\user>setx rq 541;"f";4 -m
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control
\Session Manager\Environment" | find "rq"
rq REG_SZ 541;f;4
C:\Documents and Settings\user>
Re: setx loses quotes
'
SetX does nothing more then saving a registry key, I think
get/display permanently stored variables?
viewtopic.php?f=3&t=2101&hilit=setx
I have a working way of saving an environment variable that includes quotes but it uses
regwrite "$path" "$key" "beginexample \"quoted\" endexample" not setx...
But why would you need them ? Maybe it's possibleWhen I set rq to a value blah;blah;blah , the double quotes always go.
Code: Select all
setx ""C:\ATI Technologies""
or
setx \"C:\ATI Technologies\"
Code: Select all
>echo %path%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\PRGMSYS\ATI Technolog
ies\ATI.ACE\Core-Static;D:\SYS\HD\Diskeeper10\
get/display permanently stored variables?
viewtopic.php?f=3&t=2101&hilit=setx
I have a working way of saving an environment variable that includes quotes but it uses
regwrite "$path" "$key" "beginexample \"quoted\" endexample" not setx...
Last edited by Ed Dyreen on 11 Aug 2011 16:57, edited 4 times in total.
Re: setx loses quotes
I thought i've had problems a number of times, fixed on adding quotes, like I see a directory in my huge path but cmd acts like it's not there, and like everything after it is not there. Then i've found an earlier thing unquoted and quoted it and the later one(s) then worked, but maybe something else was going on there... 'cos Googling I just read that since the delimeter is not space, it treats space as part of the file/directory, so no need to use quotes, as your example suggests.
reg add doesn't seem to accept quotes
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz 4^"5
Error: Too many command-line parameters
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz 4"5
Error: Too many command-line parameters
yeah which is setting the variable basically. To see, when you launch a new cmd.exe it reads it so then echo it.
for regwrite do you mean WSH(vbs/js)?
reg add doesn't seem to accept quotes
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz 4^"5
Error: Too many command-line parameters
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz 4"5
Error: Too many command-line parameters
Ed wrote:...SetX does nothing more then saving a registry key, I think
yeah which is setting the variable basically. To see, when you launch a new cmd.exe it reads it so then echo it.
for regwrite do you mean WSH(vbs/js)?
Code: Select all
http://msdn.microsoft.com/en-us/library/yfdfhz1b(v=vs.85).aspx
Last edited by taripo on 11 Aug 2011 17:00, edited 1 time in total.
Re: setx loses quotes
'
O yes, it accepts quotes, you didn't read the "reg add /?" very well
PROUD
My host www.ScriptingPros is gone, I am still looking for a host for my base
O yes, it accepts quotes, you didn't read the "reg add /?" very well
Code: Select all
reg add $Path /v $key "start quoted \"data\" end quoted" /f
No I mean reg add, regwrite is the name of my macro @regwritefor regwrite do you mean WSH(vbs/js)?
Code: Select all
::--------------------------------------------------------------------------------------------------------------------------
set "$Defines=@RegWrite" &set "$Details=Write to registry"
::
set ^"$Usage.%$Defines%=^
Usage: %%@forU%% ( 'r#Path, r#Key, o#Data, o#Type, o#error.bool' ) %%%$Defines%%% %$n1c%
r?Path : Path of registry object %$n1c%
r#Key : Key of registry object %$n1c%
o#Data : data of registry object %$n1c%
o#Type : type of registry object %$n1c%
o#error.bool: 0 for always return, 1 for always PANIC %$n1c%
ReturnConsole: Contents of $Key %$n1c%
$error : unaffected by function, panic otherwise "
::
2>%@DNul% ( %@forA% ( '"%$Defines%"¦"EnableDelayedExpansion"' ) %@Macro.Begin% )
::(
% % set ^"%$Defines%=!@Udelim! ( %$n1c%
% % !@forEL! ( '%$Defines%, "r?Path=%%~a", "r#Key=%%~b", "o#Data=%%~c", "o#Type=%%~d", "o#error.bool=%%~e"' ) !@LeadIn! %$n1c%
% % !@n2echo! %$Defines%: '^^^!$Key^^^!' %$n1c%
% % !@forEL! ( '@forU, @Declare.AsReg, $return, $Path, $Key, $Data, $Type, "^!$error.bool^!"' ) !@CallMacro! %$n1c%
% % if defined $Data set "$Data=^!$Data:""=\"^^^!^^^" %$n1c%
% % ^>nul reg add "^!$Path^!" /v "^!$Key^!" /t ^^^!$type^^^! /f /d "^!$Data^!" %$n1c%
% % set /a $error = ^^^!ErrorLevel^^^! %$n1c%
% % !@IfErrorBoolExit! %$n1c%
% % !@nError! %$n1c%
% % !@LeadOut! %$n1c%
% % )"
::)
2>%@DNul% %@Macro.End%
::
%@forU% ( '$ED.Path, FileOpen, This""Works""' ) %@RegWrite%
::
%@COMMIT%
::--------------------------------------------------------------------------------------------------------------------------
::
goto :skip "()"
%@endoftest%
:skip ()
My host www.ScriptingPros is gone, I am still looking for a host for my base
Re: setx loses quotes
how do you do it with $?
and accepting quotes without /d
Just googled got an example n read the help.. says to do /d value, (so funny that without /d worked -albeit not accepting quotes), but if done with /d it accepts quotes.
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz "4\"5"
Error: Too many command-line parameters
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz /d "4\"5"
The operation completed successfully
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz /d "4\"5"
Value yyyyz exists, overwrite(Y/N)? y
The operation completed successfully
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | find "yyyyz"
yyyyz REG_SZ 4"5
and accepting quotes without /d
Just googled got an example n read the help.. says to do /d value, (so funny that without /d worked -albeit not accepting quotes), but if done with /d it accepts quotes.
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz "4\"5"
Error: Too many command-line parameters
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz /d "4\"5"
The operation completed successfully
C:\Documents and Settings\user>@REG add "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v yyyyz /d "4\"5"
Value yyyyz exists, overwrite(Y/N)? y
The operation completed successfully
C:\Documents and Settings\user>@REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" | find "yyyyz"
yyyyz REG_SZ 4"5
Re: setx loses quotes
that macro is batch? (.bat?) (.cmd?)
where's documentation on how to write something like that?
never seen those lines starting with % signs
the only macros i've heard of in NT CMD, are doskey /macros. Little things, aliases.
where's documentation on how to write something like that?
never seen those lines starting with % signs
the only macros i've heard of in NT CMD, are doskey /macros. Little things, aliases.
Last edited by taripo on 11 Aug 2011 17:33, edited 1 time in total.
Re: setx loses quotes
'
Do a search for "macros"
viewtopic.php?f=3&t=2058
I have sworn myself not to use macros in giving solutions as it may come as overwelming and jerkish from my part.
Luckily I am not the only one who uses them indicating I am not a jerk or the only jerk...
Do a search for "macros"
viewtopic.php?f=3&t=2058
I have sworn myself not to use macros in giving solutions as it may come as overwelming and jerkish from my part.
Luckily I am not the only one who uses them indicating I am not a jerk or the only jerk...
Re: setx loses quotes
Congrats for developing a new kind of thing.
I know of somebody discovering a new thing in the past.. Benny Pederson's discovery, named The Bennylevel
http://users.cybercity.dk/~bse26236/bat ... /INDEX.HTM
Re: setx loses quotes
'
I'm eagerd to learn something new
Thanx, but I'm unsure if I invented the EDMacro, maybe, it just seemed logical.
The programmer/s of CMD should know every trick. After all they wrote it
I think the problem is;
Microsoft wants us to use it's features, but at the same time tries to prevent us from learning it's base. Keeping us little so they can be big. I always wonder why MS tries so hard in masking the fact they actually don't provide any help when it comes to learning. Maybe we might find out things we shouldn't know. They have copyright and bluecode.
Linux is often said to be "better" than windows, but I don't fully agree.
On the hardware level MS does a better job, the result of another conspiracy "MS♥IBM" against Linux.
I don't understand it, would you explain to me what the trick is and what it is good for ?I know of somebody discovering a new thing in the past.. Benny Pederson's discovery, named The Bennylevel
I'm eagerd to learn something new
Thanx, but I'm unsure if I invented the EDMacro, maybe, it just seemed logical.
The programmer/s of CMD should know every trick. After all they wrote it
I think the problem is;
Microsoft wants us to use it's features, but at the same time tries to prevent us from learning it's base. Keeping us little so they can be big. I always wonder why MS tries so hard in masking the fact they actually don't provide any help when it comes to learning. Maybe we might find out things we shouldn't know. They have copyright and bluecode.
Linux is often said to be "better" than windows, but I don't fully agree.
On the hardware level MS does a better job, the result of another conspiracy "MS♥IBM" against Linux.
Re: setx loses quotes
I don't understand that bennylevel thing either! I haven't really tried it..I may never figure it out, it'll be tricky!
I just recall it mentioned while searching a newsgroup(alt.msdos.batch) years ago.. maybe one day i'll look into it and figure it out, I think he did it with MS-DOS rather than NT CMD..
I don't understand your macro thing either! but I see there are some good posts on it, and maybe one day i'll look into it!
Also, it may be that any language has funny things that work, and moreso languages that aren't so structured and strict in their syntax. So perhaps it wasn't designed for that. And philosophically, when a tool is being used for something it wasn't designed for, there's usually another tool that'd do it better. That might be a reason why MS haven't bothered to document the weird things that work. And if it's fast but hard to read in batch, then in something else e.g. C it could perhaps be fast and read with the same ease or difficulty of any other C code.
I think sometimes people that use CMD or DOS run into things the developers didn't think of. Like "bouncing off the command prompt" a technique for prepending some text to the start of each line of a file. I missed a space but oh well!
I just recall it mentioned while searching a newsgroup(alt.msdos.batch) years ago.. maybe one day i'll look into it and figure it out, I think he did it with MS-DOS rather than NT CMD..
I don't understand your macro thing either! but I see there are some good posts on it, and maybe one day i'll look into it!
Also, it may be that any language has funny things that work, and moreso languages that aren't so structured and strict in their syntax. So perhaps it wasn't designed for that. And philosophically, when a tool is being used for something it wasn't designed for, there's usually another tool that'd do it better. That might be a reason why MS haven't bothered to document the weird things that work. And if it's fast but hard to read in batch, then in something else e.g. C it could perhaps be fast and read with the same ease or difficulty of any other C code.
I think sometimes people that use CMD or DOS run into things the developers didn't think of. Like "bouncing off the command prompt" a technique for prepending some text to the start of each line of a file. I missed a space but oh well!
Code: Select all
C:\rara>dir /b
file.txt
C:\rara>type file.txt
house
fish
dog
C:\rara>ren file.txt file.bat
C:\rara>prompt the
thefile >file2
'house' is not recognized as an internal or external command,
operable program or batch file.
'fish' is not recognized as an internal or external command,
operable program or batch file.
'dog' is not recognized as an internal or external command,
operable program or batch file.
theprompt $p$g
C:\rara>type file2
thehouse
thefish
thedog
C:\rara>
Re: setx loses quotes
'
MY GOD I've been looking for that for ages since I forgot, I hate to forget...
bouncing off the command prompt
Post subject: The bump from commandline trick !
viewtopic.php?f=3&t=1941&p=8350&hilit=bump+from#p8350
Thanx mate
MY GOD I've been looking for that for ages since I forgot, I hate to forget...
bouncing off the command prompt
Post subject: The bump from commandline trick !
viewtopic.php?f=3&t=1941&p=8350&hilit=bump+from#p8350
Thanx mate
Re: setx loses quotes
Great..
btw, if you were trying to find it, it helps to remember the name exactly right.
not bump/bumping! BounCing..
It's called "Bouncing off the command prompt"
You might want to edit your post in that thread. Don't want people calling it the wrong thing! makes it harder to find historically!
btw, if you were trying to find it, it helps to remember the name exactly right.
not bump/bumping! BounCing..
It's called "Bouncing off the command prompt"
You might want to edit your post in that thread. Don't want people calling it the wrong thing! makes it harder to find historically!
Re: setx loses quotes
'
I've studied the BennyLevel, I never ran the code but it seems he determines the character of a variable using the the fact that choice will accept only the first choice.
If it does what I think it does, this trick has become abundant.
I've studied the BennyLevel, I never ran the code but it seems he determines the character of a variable using the the fact that choice will accept only the first choice.
Code: Select all
@Echo. Fully specified file name.| CHOICE /n /c:abcdefgh.> NUL
For %%D in (A B C D E F G H ) do if errorlevel H%%D set D=%%D
Echo. The drive letter in your Fully specified file name: %D%
Re: setx loses quotes
abundant as in, widely used? I don't have ms-dos so can't test it. Where is it used? on this forum? I didn't know there are many other people writing batch files at that level
looks like the link isn't working all of a sudden, the whole domain has just gone down.. i'll see if I can zip it up.
i'll post a link here 'cos a bit safer if one or two others have the zip too.
not sure how useful it is though 'cos people aren't using ms-dos anymore.. but a lot on the site may still apply to CMD.
http://web.archive.org/web/200904201104 ... /INDEX.HTM
looks like the link isn't working all of a sudden, the whole domain has just gone down.. i'll see if I can zip it up.
i'll post a link here 'cos a bit safer if one or two others have the zip too.
not sure how useful it is though 'cos people aren't using ms-dos anymore.. but a lot on the site may still apply to CMD.
http://web.archive.org/web/200904201104 ... /INDEX.HTM
Re: setx loses quotes
'
Google translated, whoops, I meant superfluous hehe...
Dutch
Google translated, whoops, I meant superfluous hehe...
Dutch