Page 1 of 1

Code cmd (input)

Posted: 04 May 2020 03:22
by CmdUser202
Hi everyone.
I wanted it when it comes out: Do I have to clear the user's temp? I write "yes" and cmd deletes all the temp folder and when I write "no" the cmd closes.
this is the code that I managed but that doesn't work.

@echo off
set /P scelta="Vuoi anche cancellare temp del tuo utente?"
if %scelta% = "yes" (
echo fregato!
pause
) else (
echo ciao!
pause

echo ciao and echo fregato it's just a test to see if it works

Re: Code cmd (input)

Posted: 04 May 2020 09:46
by Squashman
You are doing a string comparison. The value on the left must equal the value on the right, character for character. That includes the quotes. You are also not using the correct comparison operator. It should be ==. You are also missing a closing parentheses.

Re: Code cmd (input)

Posted: 14 May 2020 07:30
by PAB
Hello CmdUser202, try this . . .

Code: Select all

@echo off
set /P scelta="Vuoi anche cancellare temp del tuo utente?"
if /I '%scelta%' == 'yes' (
echo fregato!
) else (
echo ciao!)
pause
I hope this helps!