Microsoft
Software
Hardware
Network
Question : Batch file variable does not store value
I have a very simple batch file script that does not work as intended: a variable does not store its value.
@echo off
SETLOCAL
SET CURLDIR = fgggh
ECHO CURLDIR is %CURLDIR%
ENDLOCAL
The output is: "ECHO CURLDIR is"
The same is if I use "" like that: SET CURLDIR = "fgggh"
And sometimes the output is "ECHO is off" - not sure why.
But after I comment out the "@echo off" statement and execute the batch script, and then un-comment the "@echo off" again, it starts to display "ECHO CURLDIR is" again.
Commenting out SETLOCAL/ENDLOCAL does not change anything.
The script seems too simple, and still does not work properly.
What am I doing wrong?
Thanks!
Answer : Batch file variable does not store value
Try removing the spaces before and after quotes in the set statement.
1: 2: 3: 4: 5:
@echo off SETLOCAL SET CURLDIR=fgggh ECHO CURLDIR is %CURLDIR% ENDLOCAL
Random Solutions
TRIM function to eliminate the last three characters
Remove Columns from CSV file, save results to new file
I can't find the audio driver for a Satellite P30
How to print logos on Epson T88IV
Apple iWeb - how to save HTML to Disk or to publish the web site via FTP?
Unable to install any framework .NET in XP Mode (Virtual PC)
Ref Cur
Create a "Batch Number" in SQL Server 2000 for import of sales orders
Complete uninstall of Sharepoint Services 3.0 from Windows 2008 Server
How to change the from field on auto-generated SharePoint emails.