0

As far as you know, we can call windows7 DLL's entry points via rundll32 <dll-file>,<Entry point> in command line. For example I lock my screen using below command in Windows Command Line :

rundll32.exe user32.dll,LockWorkStation

Now, I want to know if is there any way to turning off my monitor in such as this way? i.e. Is there any Entry-Point that I can call it in CMD and turn off my monitor?

2

I dont see anyway to achieve this in win7 or later by using the rundll32, but you can use an external app called nircmd.

To turn monitor off:

nircmd.exe monitor off

To turn monitor on:

nircmd.exe monitor on

You can put this in a bat file and make a shortcut of it.
You could also use a tool called WIZMO and use this in the command-line:

wizmo.exe monoff
1

In the command line/ or as .bat/ .cmd / .com file: powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

As a direct powershell command, you can drop the escapes and powershell directive (and save as ps1 file as well. (Add-Type '[DllImport("user32.dll")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)

Of note this seems to leave a process forever running, that you need to either make sure you kill off later or something. I am working on that issue now, which is how I stumbled here. If I correct it I will leave an answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.