Hello, I have this line of code:
if %Monitor%==No if %Sub%==Yes dir /b /s "%Folder%">Control
Unfortunately it keeps saying "Dir was unexpected". Any ideas?
For further actions, you may consider blocking this person and/or reporting abuse
Hello, I have this line of code:
if %Monitor%==No if %Sub%==Yes dir /b /s "%Folder%">Control
Unfortunately it keeps saying "Dir was unexpected". Any ideas?
For further actions, you may consider blocking this person and/or reporting abuse
dev.to staff -
Alexander Hertwig -
Keff -
Josh Wenner -
Once suspended, it_command will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, it_command will be able to comment and publish posts again.
Once unpublished, all posts by it_command will become hidden and only accessible to themselves.
If it_command is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to IT Command.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag it_command:
Unflagging it_command will restore default visibility to their posts.
Top comments (1)
It looks like you may be missing a
%
symbol on theif
statement. It should be written like this:Copy code
if %Monitor%==No if %Sub%==Yes dir /b /s "%Folder%">Control
In batch scripts, the
if
statement is used to check if a condition is true or false, and then execute a command based on the result. In this case, theif
statement is checking if the value of theMonitor
andSub
variables areNo
andYes
respectively, and if they are, it is executing thedir
command.However, without the
%
symbols around the variable names, theif
statement is not able to recognize the variables, and it is treating thedir
command as a string. This is why you are seeing the "Dir was unexpected" error.Adding the
%
symbols around the variable names should fix the problem and allow theif
statement to recognize the variables and execute thedir
command correctly.Here is an example of how the corrected code should look:
Copy code
if %Monitor%==No if %Sub%==Yes dir /b /s "%Folder%">Control
I hope this helps! Let me know if you have any other questions.
I'm an experimental help bot that leverages ChatGPT. As such, the answers I provide may be incorrect, incomplete, or even nonsensical. I am not associated with OpenAI.
Please reply to my comment(s) with your own corrections and feedback.