Computing.Net > Forums > Programming > Turning device off by command line?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Turning device off by command line?

Reply to Message Icon

Name: Herb_Davis_Y2K
Date: June 1, 2009 at 13:31:19 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

I can't get this batch file to work:
FOR /F "tokens=* delims=: " %%R IN ('devcon status *DEV_1677* ^| FIND "running"') DO SET STATUS=%%R
IF %STATUS% == "Driver is running."
devcon disable *DEV_1677*

Any help is appreciated



Sponsored Link
Ads by Google

Response Number 1
Name: reno
Date: June 1, 2009 at 22:16:18 Pacific
Reply:

devcon status *DEV_1677* | FIND "running"

if not errorlevel 1 devcon disable *DEV_1677*


0

Response Number 2
Name: Herb_Davis_Y2K
Date: June 2, 2009 at 05:14:11 Pacific
Reply:

Thank you! How could I expand it to be a toggle for said device?
Something like this?

:Status
FOR /F "tokens=* delims=: " %%R IN ('devcon status *DEV_1677* ^| FIND "running"') DO SET STATUS=%%R
if not errorlevel 1 GOTO DISABLE ELSE GOTO ENABLE

:DISABLE
devcon disable *DEV_1677*
GOTO END

:ENABLE
devcon enable *DEV_1677*
GOTO END

:End


0

Response Number 3
Name: reno
Date: June 2, 2009 at 05:24:30 Pacific
Reply:

the for loop is not needed

@echo off & setlocal
set dev=*DEV_1667*
devcon status %dev%|FIND "running">nul 2>&1 && (goto:disable %dev%) || goto:enable %dev%
goto:eof

:enable
devcon enable %*
goto:eof

:disable
devcon disable %*


0

Response Number 4
Name: Herb_Davis_Y2K
Date: June 2, 2009 at 05:52:23 Pacific
Reply:

Thanks so much! Works great!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Turning device off by command line?

disble net card by command line www.computing.net/answers/programming/disble-net-card-by-command-line/3317.html

Batch file command line args www.computing.net/answers/programming/batch-file-command-line-args/4226.html

Help on Borland command line tools www.computing.net/answers/programming/help-on-borland-command-line-tools/6863.html