找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 21886|回复: 7

[系统相关] 批处理怎样修改鼠标指针文件?

[复制链接]
发表于 2023-3-14 15:24:14 | 显示全部楼层 |阅读模式
请教:
我想临时修改一下系统正在使用鼠标指针文件,比如:
——我并不知道系统正在使用的是啥鼠标指针文件,但是,我想临时使用一下“zhuxing.cur”这个鼠标指针,使用完后,又要还原到之前系统使用的鼠标指针文件。

请教怎么才能办到??谢谢!!
发表于 2023-3-14 17:04:20 | 显示全部楼层
直接在main.cpl的指针选项卡修改,还可以在注册表项HKCU\Control Panel\Cursors修改,不过修改注册表要重启。
 楼主| 发表于 2023-3-14 21:05:39 | 显示全部楼层
直接在main.cpl的指针选项卡修改,还可以在注册表项HKCU\Control Panel\Cursors修改,不过修改注册表要重启 ...
buyiyang 发表于 2023-3-14 17:04



    谢谢您的回答!但,不完全符合我的想法!
在这里提问题,我当然是想用命令行或BAT来解决的了!
发表于 2023-3-15 10:52:53 | 显示全部楼层
  1. set "curfile=C:\zhuxing.cur"
  2. cd /d "%~dp0"
  3. if not exist recover.reg (reg export "HKCU\Control Panel\Cursors" recover.reg)
  4. reg query "HKCU\Control Panel\Cursors" /v Arrow | findstr /c:"%curfile%" && goto re
  5. reg add "HKCU\Control Panel\Cursors" /v Arrow /t REG_EXPAND_SZ /d "%curfile%" /f
  6. shutdown -l
  7. exit
  8. :re
  9. reg import recover.reg
  10. shutdown -l
复制代码
设置好自定义的cur文件路径,这个bat脚本会判断切换或恢复鼠标arrow的cur,不过由于是修改注册表需要注销后生效,注意它会自动注销,生成的recover.reg不要删除。
 楼主| 发表于 2023-3-16 15:52:00 | 显示全部楼层
设置好自定义的cur文件路径,这个bat脚本会判断切换或恢复鼠标arrow的cur,不过由于是修改注册表需要注销后 ...
buyiyang 发表于 2023-3-15 10:52



    谢谢了!
美中不足的不能立即生效!!
发表于 2023-3-16 16:57:22 | 显示全部楼层
试试把注销换成这样
  1. powershell "Add-Type 'using System.Runtime.InteropServices;public static class test{[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);}';[test]::SystemParametersInfo(0x0057,0,$null,0)"
复制代码

评分

参与人数 2技术 +2 收起 理由
czjt1234 + 1 这个有用啊
buyiyang + 1 学习了

查看全部评分

 楼主| 发表于 2023-3-17 14:31:42 | 显示全部楼层
本帖最后由 locoman 于 2023-3-17 16:22 编辑
试试把注销换成这样
idwma 发表于 2023-3-16 16:57


谢谢您了!
实测:我手工在注册表中修改了鼠标指针后,再运行您这个powershell后,就立即生效了!!


再请教:
1. 您这段powershell代码只能对修改鼠标指针立即生效有作用?还是可以对所有注册表修改都能立即生效吗?
2. 您这段powershell代码与下面这两句有啥区别?使用哪个更好呢??
taskkill /f /im explorer.exe
start explorer.exe

3. 据此,将4楼的代码整合如下吗?

   

set "curfile=C:\zhuxing.cur"
cd /d "%~dp0"
if not exist recover.reg (reg export "HKCU\Control Panel\Cursors" recover.reg)
reg query "HKCU\Control Panel\Cursors" /v Arrow | findstr /c:"%curfile%" && goto re
reg add "HKCU\Control Panel\Cursors" /v Arrow /t REG_EXPAND_SZ /d "%curfile%" /f
powershell "Add-Type 'using System.Runtime.InteropServices;public static class test{[DllImport(\"user32.dll\", EntryPoint = \"SystemParametersInfo\")]public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);}';[test]::SystemParametersInfo(0x0057,0,$null,0)"
exit
:re
reg import recover.reg
powershell "Add-Type 'using System.Runtime.InteropServices;public static class test{[DllImport(\"user32.dll\", EntryPoint = \"SystemParametersInfo\")]public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);}';[test]::SystemParametersInfo(0x0057,0,$null,0)"
发表于 2023-3-17 17:19:50 | 显示全部楼层
回复 7# locoman

这个api改参数才能让对应的设置生效
https://learn.microsoft.com/zh-c ... stemparametersinfoa
结束进程的方式也好呀,适合自己就是最好的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 18:40 , Processed in 0.024987 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表