[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] [已解决]有没有cmd命令可以实现关闭显示器/屏幕?

本帖最后由 pcl_test 于 2017-5-6 14:58 编辑

就是实现那种,如果我电脑长时间不碰它的时候,它会自动黑屏的那种(不知道算不算是休眠)。。。
这个怎么实现??
而且就算是黑屏的状态下,如果你下载东西的时候,它还是能下载的那种。。。
用dos命令能实现吗??
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

  1. nircmd.exe monitor off
复制代码
1

评分人数

TOP

DAIC 发表于 2014-1-7 16:09

ma


貌似不行啊:

C:\Documents and Settings\Administrator>nircmd.exe monitor off
'nircmd.exe' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

C:\Documents and Settings\Administrator>

TOP

回复 3# mimixi666


你需要先下载nircmd.exe
http://www.bathome.net/thread-2992-1-1.html

TOP

回复 4# DAIC


    OK,成功了,谢谢。。。

TOP

  1. /*&cls
  2. @echo off
  3. set "netpath=%systemroot%\Microsoft.NET\Framework"
  4. for /f "delims=" %%a in ('dir /ad /b "%netpath%\v?.*"') do (
  5.     if exist "%netpath%\%%a\csc.exe" (
  6.         set "cscpath=%netpath%\%%a\csc.exe"
  7.         goto :0
  8.     )
  9. )
  10. echo;未安装.Net Framework 2.0及其上版本组件或相关程序丢失&pause&exit/b
  11. :0
  12. "%cscpath%" /out:"$MonitorOff.exe" "%~f0"
  13. "$MonitorOff.exe"
  14. pause&exit
  15. */
  16. using System;
  17. using System.Runtime.InteropServices;
  18. class MonitorOff
  19. {
  20.     [DllImportAttribute("user32.dll")]
  21.     private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
  22.     static void Main(string[] args)
  23.     {
  24.         SendMessage((IntPtr)0xffff, 0x112, 0xF170, 2);
  25.     }
  26. }
复制代码

TOP

本帖最后由 eech 于 2020-4-14 01:49 编辑

代码如果精简一 下就更好了,我这里测试临时文件不能自动删除

TOP

回复 2# DAIC

如何重新打开屏幕呢?

TOP

test-1.bat
  1. @echo off
  2. powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)
复制代码
我帮忙写的代码不需要付钱。如果一定要给,请在微信群或QQ群发给大家吧。
【微信公众号、微信群、QQ群】http://bbs.bathome.net/thread-3473-1-1.html
【支持批处理之家,加入VIP会员!】http://bbs.bathome.net/thread-67716-1-1.html

TOP

返回列表