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\a^b&c>set "dir=%cd%"

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



Messages in this Thread

96,333 Postings in 12,176 Threads, 350 registered users, 63 users online (0 registered, 63 guests)
Index | Admin contact |   Forum Time: May 28, 2023 - 2:44 am UTC  |  Hits:55,533,115  (2,240 Today )
RSS Feed