echo %something% >> name.bat becomes blank space

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aseventhmindset
Posts: 8
Joined: 11 Apr 2010 20:55

echo %something% >> name.bat becomes blank space

#1 Post by aseventhmindset » 11 Apr 2010 21:36

I am trying to make a batch file that will make another batch file. It works up until the point where I enter:

echo if %command%==Hide goto :Hide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"
echo if %command%==hide goto :Hide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"
echo if %command%==Unhide goto :Unhide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"
echo if %command%==unhide goto :Unhide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"
echo if %command%==Exit goto :End >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"
echo if %command%==exit goto :End >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"

The batch file "File Hider.cmd" has a blank space where it should say "%command%". I know why this happens, but I was wondering if there is a way to work around this.

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: echo %something% >> name.bat becomes blank space

#2 Post by jeb » 12 Apr 2010 04:17

hi aseventhmindset,

Code: Select all

echo if %command%==Hide goto :Hide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"


Will result to
FileHider.cmd

Code: Select all

if ==Hide goto :Hide


You should change it to

Code: Select all

echo if %%command%%==Hide goto :Hide >> "%homedrive%\Documents and Settings\%username%\desktop\File Hider\FileHider.cmd"


jeb


Post Reply