Removing double quotes from variables in batch file creates problems with CMD environment

前端 未结 11 583
春和景丽
春和景丽 2020-12-04 11:25

Can anybody help with effective and safe way of removing quotes from batch variables?

I have written a batch file which successfully imports a list of parameters %1,

11条回答
  •  情话喂你
    2020-12-04 11:46

    I learned from this link, if you are using XP or greater that this will simply work by itself:

    SET params = %~1

    I could not get any of the other solutions here to work on Windows 7.

    To iterate over them, I did this:

    FOR %%A IN (%params%) DO (    
       ECHO %%A    
    )
    

    Note: You will only get double quotes if you pass in arguments separated by a space typically.

提交回复
热议问题