daddydave Posted January 24, 2007 Posted January 24, 2007 (edited) I'm trying to echo literal > characters and % characters, and I understand I can escape them with ^ characters, but for some reason the ^ characters appear in the output also. Yet if I remove them, the %TMP% variable is evaluated immediately. In other words the output I want, strangely enough, is"UninstallString"="cmd /c echo Windows Registry Editor Version 5.00>%TMP%\BlahBlah.regI am not trying to create BlahBlah.reg at this time, I am echoing to screen what will eventually be echoed to a different reg file to be merged with the Registry so that BlahBlah.reg can be created at a later time. The syntax is off a bit for the registry, but right now I am just worried about the syntax for the .cmd fileWhat I get is:C:\>@echo "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00^>^ %TMP^%\BlahBlah.reg "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00^>^%TMP^%\Bla hBlah.reg C:\>@echo "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00>^% TMP^%\BlahBlah.reg "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00>^%TMP^%\Blah Blah.reg C:\>@echo "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00>%T MP%\BlahBlah.reg "UninstallString"="cmd /c echo Windows Registry Editor Version 5.00>C:\DOCUME~1\ ADMINI~1\LOCALS~1\Temp\BlahBlah.regSee how the ^ echoes in the output even though I am just using it to keep %TMP% from evaluating during the run of the batch file as it does in the last example above. Edited January 24, 2007 by daddydave
Yzöwl Posted January 24, 2007 Posted January 24, 2007 One problem is that your outputting from the console and not a batch, you're testing for a batch run so use a batch for the testing!Also the escape character for the percent is another percent:Since you missed a double quote from your examples, I will give you a couple of solutions just in case I've guessed incorrectly!@ECHO/"UninstallString"="%%COMSPEC%% /c ECHO/Windows Registry Editor Version 5.00 >%%TMP%%\BlahBlah.reg"@ECHO/"UninstallString"="%%COMSPEC%% /c ECHO/Windows Registry Editor Version 5.00"^>%%TMP%%\BlahBlah.reg
daddydave Posted January 24, 2007 Author Posted January 24, 2007 (edited) Thanks, Yzöwl, that fixes it! And you're right, I hadn't considered that running it from the console was distorting my output. Edited January 24, 2007 by daddydave
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now