07-23-2023, 11:12 AM
I feel like I'm going around in circles with FOR loop options.
I'm trying to take a string (output of a command) and split it on commas, then use each value to SET, e.g.
String: `USER=Andy,IP=1.2.3.4,HOSTNAME=foobar,PORT=1234`
So I want to split on comma and then literally use that variable in SET. I don't know ahead of time how many many variables there will be.
I've tried things like:
FOR %%L IN (%MYSTRING%) DO ECHO %%L
but that splits on the equals sign too so I end up with
USER
Andy
IP
1.2.3.4
etc
I just want to be able to do the following so I can `SET USER=Andy` etc, something like:
FOR %%L IN (%MYSTRING%) DO SET %%L
What option or flags am I missing?
I'm trying to take a string (output of a command) and split it on commas, then use each value to SET, e.g.
String: `USER=Andy,IP=1.2.3.4,HOSTNAME=foobar,PORT=1234`
So I want to split on comma and then literally use that variable in SET. I don't know ahead of time how many many variables there will be.
I've tried things like:
FOR %%L IN (%MYSTRING%) DO ECHO %%L
but that splits on the equals sign too so I end up with
USER
Andy
IP
1.2.3.4
etc
I just want to be able to do the following so I can `SET USER=Andy` etc, something like:
FOR %%L IN (%MYSTRING%) DO SET %%L
What option or flags am I missing?