Created
January 28, 2016 19:41
-
-
Save kevinlee12/0cc0ec5b398da655fe76 to your computer and use it in GitHub Desktop.
Toggle Enable/Disable Device Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@setlocal enableextensions enabledelayedexpansion | |
@echo off | |
rem =========================================================================== | |
rem The following toggles the touch screen on the Lenovo Thinkpad Yoga 12 using | |
rem DevCon.exe. Please ensure that you have Devcon.exe installed before running | |
rem this script. Please see Windows Device Console (Devcon.exe) page for Devcon | |
rem installation instructions. | |
rem This script must be run with admin privileges. | |
rem | |
rem Copyright 2016 Kevin Lee | |
rem Licensed under the Apache License, Version 2.0 (the "License"); | |
rem you may not use this file except in compliance with the License. | |
rem You may obtain a copy of the License at | |
rem http://www.apache.org/licenses/LICENSE-2.0 | |
rem Unless required by applicable law or agreed to in writing, software | |
rem distributed under the License is distributed on an "AS IS" BASIS, | |
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
rem See the License for the specific language governing permissions and | |
rem limitations under the License. | |
rem =========================================================================== | |
set DEVICE="<Device ID here>" | |
set DEVCON="C:\Program Files (x86)\Windows Kits\10\Tools\x64\devcon.exe" | |
%DEVCON% rescan | |
%DEVCON% status %DEVICE% | |
%DEVCON% status %DEVICE% | find "disabled" > temp.txt | |
set /p disabled=<temp.txt | |
set user_set_disable=0 | |
if ["%disabled%"] == [""] ( | |
%DEVCON% /r disable %DEVICE% | |
echo "Device has been disabled" | |
set user_set_disable=1 | |
) else ( | |
%DEVCON% /r enable %DEVICE% | |
echo "Device has been enabled" | |
) | |
del temp.txt | |
%DEVCON% rescan | |
%DEVCON% status %DEVICE% | find "disabled" > temp.txt | |
set /p disabled=<temp.txt | |
rem This is to ensure that the device is really disabled. | |
if %user_set_disable% == 1 ( | |
if ["%disabled%"] == [""] ( | |
%DEVCON% /r remove %DEVICE% | |
) | |
) | |
del temp.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment