Batch file command output and if statement

Status
Not open for further replies.

pyromaster114

Posts: 243   +0
Not sure if this would be the right forum to post this in... but I suppose it doesn't fit in any other forum anyways.

So I have a batch file I'm TRYING to write to do basically one thing:
Determine if a device is disabled.

I've gotten the command to give me a status output of the device, however, I can't seem to get the IF statement to work properly.

I figure I must set the output of the status thing to a variable, and then try and tell the thing to see if the word 'disabled' is in the variable string.
I've got this so far:

:TOP
FOR /F "tokens=*" %R IN ('devcon status ACPI\WACF009') DO SET VAR=%R
IF %VAR% == "*disabled*"
ECHO Device Disabled!!!
GOTO TOP

I'm apparently bad at this whole batch file writing thing, and I keep making mistakes, so I thought I'd see if anyone here knows anything.


In case you're wondering... No, I'm not trying to be redundant. In the end, the batch file is actually going to toggle the state of my notebook's WACOM sensor... the ECHO will eventually be replaced by the command to re-enable the touch sensor.
 
Status
Not open for further replies.
Back