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

334 views      
 

Messages in this Thread

 
96,656 Postings in 12,233 Threads, 350 registered users, 20 users online (0 registered, 20 guests)
Index | Admin contact |   Forum Time: May 18, 2024 - 6:01 am UTC  |  Hits:63,517,036  (1,740 Today )
RSS Feed