Code cmd (input)

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
CmdUser202
Posts: 1
Joined: 04 May 2020 03:21

Code cmd (input)

#1 Post by CmdUser202 » 04 May 2020 03:22

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

Squashman
Expert
Posts: 4153
Joined: 23 Dec 2011 13:59

Re: Code cmd (input)

#2 Post by Squashman » 04 May 2020 09:46

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.

PAB
Posts: 82
Joined: 12 Aug 2019 13:57

Re: Code cmd (input)

#3 Post by PAB » 14 May 2020 07:30

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!

Post Reply