Roke
Roke

Reputation: 300

Batch error not letting me set a variable

I'm making a shell based off batch and powershell (mainly batch though).

I have a little snip-it of code:

:prompt
@echo off
title JDOS command line
echo.
echo.
SET /P command=%FDIR%>

But whenever I add the > in the code, it quits with a message: The syntax of the command is incorrect.

So, is there any possible way to bypass this in order for the > display?

BTW: I would love it if you helped me in this; so far I am alone. http://1drv.ms/1VT7grx

Feel free to edit the link ^ above ^ and add whatever you feel like, help is appreciated.

Upvotes: 2

Views: 44

Answers (2)

npocmaka
npocmaka

Reputation: 57322

Two ways

1) SET /P command=%FDIR%^> as in the shawnt00 comment

2) SET /P "command=%FDIR%>" which in some cases can be safer

Upvotes: 4

shawnt00
shawnt00

Reputation: 17953

You need to use the caret (^) to escape the redirection character (>) as a literal.

Upvotes: 3

Related Questions