ZTree.com  | ZEN  | About...  

 Index   Back

[OT] Example BAT script   [OT]

By: Liviu       
Date: Jan 13,2023 at 06:24
In Response to: [OT] Example BAT script (Slobodan Vujnovic)

> [...] By the way, I've never seen such use of double quotes in the SET command.

In addition to Ben's well taken points, the quotes also allow assigning values that contain cmd "poison" characters.

> set "dir=%cd%"

Suppose the above gets called while the current directory is "C:\etc\a^b&c", then this happens:

C:\etc\a^b&c>set dir=%cd%
'c' is not recognized as an internal or external command,
operable program or batch file.

C:\etc\a^b&c>echo %dir%
C:\etc\ab

C:\etc\a^b&c>set "dir=%cd%"

C:\etc\a^b&c>echo "%dir%"
"C:\etc\a^b&c"


Cheers,
Liviu

59 views      
 

Messages in this Thread

 
96,194 Postings in 12,153 Threads, 350 registered users, 26 users online (0 registered, 26 guests)
Index | Admin contact |   Forum Time: Jan 27, 2023 - 1:06 am UTC  |  Hits:53,203,665  (898 Today )
RSS Feed