Programmatically uninstall a device in windows device manager - windows

Is it possible to programmatically uninstall a device in windows and perform a 'scan for hardware changes' programmatically? Is there any VB script that can be used for the same? Or is there any windows API that can be called to achieve the same?

To force the 'scan for hardware changes' checkout "How To Force Reenumeration of a Device Tree From an Application" the sample there shows how to force the entire tree to be re-enumerated.
As to removing a driver checkout DiUninstallDevice.

Related

How to determine display - touch device associations for windows 10?

I am currently writing an application that receives touch input through the windows WM_INPUT messages and the HID API. Every touch point received has a handle to the device associated from which it came. This is the same device that the family of WM_POINTER messages would report for the same touch point. My application needs to know which monitor corresponds to a particular touch device. Is there a programmatic way to determine this? If I was using the WM_POINTER API I could use MonitorFromPoint or something similar.
In the control panel under "hardware and sound" there is a category "Tablet PC Settings". If you click this category, a dialog box launches which has a button "Setup". This button launches a calibration tool which allows you to pair a USB HID touch device with a monitor.
Does anyone know where these settings might be saved to?
relevant links:
structure received in WM_INPUT messages:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms645562(v=vs.85).aspx
Structure received in WM_POINTER messages:
https://msdn.microsoft.com/en-us/library/windows/desktop/hh454907(v=vs.85).aspx
Thanks.
A generic way to determine where things are stored in the registry, is to watch registry changes. Process Monitor from the Windows Sysinternals Suite by Mark Russinovich, can be used to watch and log changes to the windows registry. So you can start it logging, and then perform your calibration, and then stop and examine the log for the desired registry activity.
Here is a link to a similar question I asked
Associate HID Touch Device with Pnp Monitor.
In short, you can use the details from the HIDApi calls with queries of registry keys to link HID Touch Devices to monitors.

After instaling window 8 Brightness control not working

After installing new Windows8 ultimate OS.
Brightness control keys are not working of my laptop.
My laptop model is TOSHIBA SATELLITE C660D
I search for drivers but not find suitable and working driver for my laptop.
I have the similar issue and have solved it like this
Just right click --> My Device/Mycomputer ---> Manage --->Device Manager
Then find Monitor open Monitor section
And then right click on Generic PnP Monitor and click enable
Then you will be able to use brightness keys in window 10 and 8
I have similar issue with Lenovo Y570. The software for managing fan speed does not wortking properly - it does not manage fan speed. Try to install soft which manages brighetness for windows 7 and compatibility mode.
P.S. Don't forget to create Restore point first.
Try to rollback driver to Windows default driver.
goto Control Panel - Device Manager - Display Devices - Right Click on Intel Graphics - Click on RollBack - Confirm - Ok.

Detect all connected monitors using Windows API

I am using Windows 7. When I plug a new monitor when the PC is running, the monitor is not automatically detected. I must go to the Display->Screen Resolution and click on the Detect button in order to detect the monitor with the registry configuration.
I am searching for a way to do the same programmatically using the Windows API. So I would like to write a program that detects all connected monitors reproducing the Detect button. I tried using ChangeDisplaySettingEx but with bad results. Any suggestions?
Not really a WinApi but try this utility:
C:\Windows\System32\DisplaySwitch.exe
DisplaySwitch.exe /internal - Switch to Primary only
DisplaySwitch.exe /external - Switch to Secondary only
DisplaySwitch.exe /clone - Clone desktop on both screens (Not HDCP compliant!)
DisplaySwitch.exe /extend - Extend desktop to both screens
In particular, try /extend switch, it should perform detection internally.
Not an API solution, but you can use MS's DevCon utility on the command line to scan for new hardware.
https://support.microsoft.com/en-us/kb/311272
Download it from that page, then just execute this from a cmd window:
devcon.exe rescan
You can easily create a .bat or .cmd file to run this from a link.
You should read this if you want to learn about display-aware apps.

How to automate the "Windows Security" window: "Windows can't verify the publisher of this driver software"

This should be a simple question that should have a simple solution...yet nothing that I have tried works. My question is why? Is there a security feature in Microsoft preventing sending keys to "Security Windows"?
AutoiT attempt (does not work):
WindWait("Windows Security")
Send("{DOWN}")
Sleep(10)
Send("{ENTER}")
I have also tried/look at this question
I have tried to do this in C++ and in C# and I can only get the window to become the active window but when I send keys to it it ignores it.
Below are some of the places that I have look in order to suppress or automate this window:
Windows 7 - Disable signature verification of drivers
Permanently disable driver signature enforcement on Win 7 x64
How to disable driver signing in Windows 7 SP1
Disabling digital driver signing in Windows 7
Windows - Suppress "Windows can't verify the publisher of this driver software"
All "solutions" from the above links don't work. I have been searching for an answer for more than 2 days now.
If someone can tell a successfully way to suppress/automate this I (and everyone that wants to know how to do this too) will really appreciated.
Are you able to identify the window using the Win... functions? If so you could try using MouseClick:
$aPos = WinGetPos("Windows Security")
MouseClick("left", $aPos[0]+50, $aPos[1]+100)
First get the position of the window, then add some pixels so that when you do a right-click with the mouse you click the appropriate button. Of course you need to adjust the number of pixels to add to the x-/y-axis.
I know this is old, but I just came across this issue as well.
I was able to solve it by using the following once the window was active:
ControlClick("Windows Security", "", "[CLASS:Button;INSTANCE:2]")
It did not work if I included the TEXT:&Install this driver software anyway in the control ID.

How do I automatically run an application on USB attach or CD insert on Mac OS X?

Is there any way to automatically launch an application on USB attach or CD insert on Mac OS X? it's easy on Windows, but I found that AutoRun.Inf does not work on the Mac at all.
You can't. Autostarting applications is impossible under Mac OS X.
The next-best thing, opening the CD folder and showing the installer icon, can be done by using (AutoOpen version 1.0) to make a .dmg which can then be burnt to a CD.
Basically, auto-run is considered a security problem and so is not supported in OSX. Sophie Alpert's answer is also a bit overkill. Most installers for OSX simply open up a folder to show the application and, possibly, a readme. Installing is done by dragging the app to your Applications folder.
For other kinds of apps on CDs (say, a slide show or something like that), the developer generally uses hidden folders to hide support data to ensure that the only thing the user will see when they open the CD is the single icon they're supposed to double click to start the app.
It is possible to install a background service that monitors whenever a USB device is plugged in and then launches an App. Google's "Android File Transfer Agent" is such a service that is running in the background and launches "Android File Transfer" whenever you plug in an Android device.
If you are looking for something for just yourself, you could write a small mac app that runs in the background and watches for a particular USB device (by id) to be attached and then run the program. Ideally a small XML plist could be used to map device IDs to the correct program to run. The XCode SDK has sample code that monitors for device additional and removal to get you started.
I agree with JavaCoderEx. I would crontab a task that looks for /Volumes/*/autorun.sh, then runs it once. Maybe touch a file in /tmp/ so you know its already been run, then remove it if the volume disappears.

Resources