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

[文本处理] 批处理隐藏桌面图标

请教一下各位大老,怎样把桌面图标用批处理全部隐藏掉。  然后又可以用批处理全部显示出来。

谢谢各位大老

本帖最后由 aloha20200628 于 2024-8-27 10:17 编辑


用修改文件属性 ‘+h’ 方法隐藏桌面图标可能还要两个前置步骤
一是在资源管理器的文件目录显示选项中关闭 ‘显示隐藏文件’
二是修改全部桌面图标的文件属性也许需要管理员权限(win8.1系统实测无此必要)
备注》在 %USERPROFILE%\Desktop\ 下的*.lnk及其文件夹一般都是第三方应用设置或用户自定义的,可用 ‘+h’ 方法隐藏,而系统内置的图标如 ‘回收站’ 等不在其内,须用别法处理...
  1. @echo off &if "%~1" neq "" goto[main]
  2. :: 检查当前进程是否获取管理员权限
  3. net session >nul 2>nul
  4. if %errorlevel% neq 0 (
  5.     echo,申请管理员权限...
  6.     powershell "start -filepath '%~f0' -ArgumentList 1 -verb runas"
  7.     exit/b
  8. )
  9. :[main]
  10. attrib +h "%USERPROFILE%\Desktop\*.*"
  11. :: 刷新桌面以确保桌面图标隐藏生效(win8.1系统实测无此必要)
  12. assoc .bat=batfile>nul
  13. pause&exit/b
复制代码
恢复桌面图标显示须修改代码第10行中 +h 为 -h 即可

TOP

回复 1# yidamw@qq.com


    attrib +h +s "%USERPROFILE%\Desktop\*.*"
    pause
    attrib -h -s "%USERPROFILE%\Desktop\*.*"

TOP

本帖最后由 jyswjjgdwtdtj 于 2024-8-26 15:09 编辑
  1. #powershell
  2. add-type -typedefinition 'using System.Runtime.InteropServices;
  3. using System.Timers;
  4. using System;
  5. public class csclass
  6. {
  7.     [DllImport("user32.dll")]
  8.     public static extern int ShowWindow(int hwnd, int nCmdShow);
  9.     [DllImport("user32.dll", EntryPoint = "FindWindowExA")]
  10.     private static extern IntPtr FindWindowExA(IntPtr hWndParent, IntPtr hWndChildAfter, string lpszClass, string lpszWindow);
  11.     [DllImport("user32.dll", EntryPoint = "EnumWindows")]
  12.     private static extern int EnumWindows(EnumWindowsProc ewp, IntPtr lParam);
  13.     private delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
  14.     public static Timer timer = new Timer();
  15.     public static void Main()
  16.     {
  17.         timer.Interval = 10;
  18.         timer.Enabled = false;
  19.         timer.AutoReset = true;
  20.         IntPtr Fv = IntPtr.Zero;
  21.         EnumWindows((hwnd, lParam) =>
  22.         {
  23.             IntPtr fv = FindWindowExA(hwnd, IntPtr.Zero, "SHELLDLL_DefView", null);
  24.             if (fv != IntPtr.Zero)
  25.             {
  26.                 Fv = fv;
  27.             }
  28.             return true;
  29.         }, IntPtr.Zero);
  30.         ShowWindow((int)Fv, 0);
  31.         timer.Elapsed += (s, e) => {
  32.         };
  33.     }
  34. }'
  35. [csclass]:Main()
复制代码
若要解除 则将ShowWindow((int)Fv, 0);处0改为1

TOP

用nircmd
  1. 隐藏桌面所有图标 nircmd.exe win hide class progman
  2. 显示桌面所有图标(用以上命令隐藏过后) nircmd.exe win show class progman
复制代码
bat小白,请多指教!谢谢!

TOP

返回列表