Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
colargol
- Posts: 49
- Joined: 28 Sep 2011 13:23
- Location: france
#1
Post
by colargol » 16 Nov 2011 02:26
Hi
I still don't understand when we must use
instead of
Can someone explain please

set /? doesn't help
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#2
Post
by Ed Dyreen » 16 Nov 2011 07:52
'
You use it as you like, the quoted version does not require escaping special chars
Code: Select all
@echo off
set "$var=| special &char"
set $var
set $var=hello^
% % there ^!
set $var
set $var=hello^
there ^!
set $var
pause
exit
-
colargol
- Posts: 49
- Joined: 28 Sep 2011 13:23
- Location: france
#3
Post
by colargol » 16 Nov 2011 08:50
Ok, very good examples
Thank you again Ed.
-
jeb
- Expert
- Posts: 1059
- Joined: 30 Aug 2007 08:05
- Location: Germany, Bochum
#4
Post
by jeb » 16 Nov 2011 11:03
Hi colargol,
As Ed wrote, it's a good choice to be safer with special characters, but it's not bullet proof.
There is a second cause to use it.
It avoids the appending of invisible spaces at the line end.
Set var1=a<space>
Set "var2=a"<space>
In var1 is a<space> in var2 is only a
Jeb
-
colargol
- Posts: 49
- Joined: 28 Sep 2011 13:23
- Location: france
#5
Post
by colargol » 16 Nov 2011 11:36
Ok thanks jeb
This may be safer to use quotes when we manipulate filenames, like me.
Once I'll have finished my small app., I'll ask for help because I'd like my scripts to work with files containing those special chars (% & ^)
Currently, it supports only exclamation mark.