Batch file command output and if statement

By pyromaster114
Nov 26, 2008
  1. 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:

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

    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.
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...