Click here to Skip to main content
15,917,702 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was wondering if it's possible to connect/disconnect power of a Windows laptop through c# code only, without using any additional hardware?

What I have tried:

I haven't doen anything until now, just trying to now if this is possible.
Posted
Updated 1-Apr-18 1:50am
v2

1 solution

No, you can't. The power API's can set the power plan, but you cannot set whether or not the machine is running on AC or battery.

Thinking about this for a tiny bit, exposing this kind of functionality would be a huge security risk.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900