# extra spaces in variable



## Vivek17 (Jul 22, 2007)

Hi All,
I have written a batch file which has some variables. But when I run the batch file the path variable do not get populated which depends on some application.
But when I rerun the script for the second or the third time, the variables get its value.
I was using Windows2003 server OS.
I want to know how to solve this problem.

Regards,
Vivek


----------



## JohnWill (Oct 19, 2002)

Can we see the batch file? Also, EXACTLY what happens when you run the first time, and what application is this dependent on?

I can't really be sure what you're doing or what the exact issue is from the description.


----------



## Vivek17 (Jul 22, 2007)

HI
CURRENT_VERSION=35.34.34t.45
FOR /F "usebackq tokens=1 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR1=%%a
FOR /F "usebackq tokens=2 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR2=%%a
FOR /F "usebackq tokens=3 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR3=%%a 
FOR /F "usebackq tokens=4 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR4=%%a

echo "%VAR1% %VAR2% %VAR3% %VAR4% "

In the first run it displays NULL and in the second run it displays the values.

Regards,
Vivek


----------



## dez_666 (May 30, 2007)

It worked fine for me..


```
@echo off
set CURRENT_VERSION=35.34.34t.45
FOR /F "usebackq tokens=1 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR1=%%a
FOR /F "usebackq tokens=2 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR2=%%a
FOR /F "usebackq tokens=3 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR3=%%a 
FOR /F "usebackq tokens=4 delims=." %%a IN (`echo %CURRENT_VERSION%`) DO set VAR4=%%a

echo "%VAR1% %VAR2% %VAR3% %VAR4%
```
returned this


```
C:\Documents and Settings\nick\Desktop>x.bat
"35 34 34t  45
```


----------

