很久没给大家带来好的东西了。作为批处理区版主,有点失职,先给大家陪个不是了。这篇文章是我在黑手上看到的。其中最出色的地方就是结合了INF文件。这个对我来说是个新概念。! 这个批处理工具有5个功能 1.查询快捷方式所指文件路径 2.系统账号重命名功能 3.重新启动 4.安装和卸载系统服务功能 5.查看端口关联进程功能 在这里,功能一利用的是findstr的正则表达式。在批处理实例教学动画里面有,不懂的可以看下。不过个人感觉有点啰嗦。,直接用FOR扩展下就可以得到的东西。为什么要去弄个findstr呢。? 系统账号重命名利用了wmic,这个wmi命令行形式。wmic很强哦。 重新启动和安装卸载服务都是通过echo INF文件来实现的。这是这文章的亮点,不过可惜的是没有把secedit也结合进去。不然就真的淫荡之极了。哈哈。 本来想挑战一下作者的。但是没得时间。呵呵。 源代码如下。 @Echo off If "%1" == "" Goto Help If "%1" == "-help" Goto Help If "%1" == "-reboot" Goto Reboot If "%1" == "-installservice" Goto InstallService If "%1" == "-removeservice" Goto RemoveService If "%1" == "-fport" Goto Fport If "%1" == "-querylnk" Goto QueryLnk If "%1" == "-renname" Goto RenName Goto Exit :QueryLnk If "%~2" == "" Echo 您未输入要查询的快捷方式路径(若路径有空格,请用引号引起来)&&Goto Help If /i "%~x2" NEQ ".lnk" Echo 错误,您输入的不是快捷方式&&Goto Exit Echo. Echo. Echo 您输入的是: Echo %2 Echo. Echo 查到目标文件路径是: type %2|more|findstr "^[a-zA-Z]:\\\\" Goto Exit :Reboot If "%2" == "" Echo 要重新启动请加任意参数(Exp:NP -reboot y)&&Goto Exit Setlocal Cd/d %temp% Echo [version] > reboot.inf Set inf=InstallHinfSection DefaultInstall Echo signature=$chicago$Content$nbsp;>>reboot.inf Echo [defaultinstall] >>reboot.inf Rundll32 setupapi,%inf% 1 %temp%\reboot.inf Del reboot.inf Goto Exit :InstallService Setlocal Cd/d %temp% If "%2"=="" Echo NP -InstallService ServiceName FileName&&Goto Exit If "%3"=="" NP -InstallService ServiceName FileName&&Goto Exit Echo [Version] >install.inf Echo Signature="$WINDOWS NT$" >>install.inf Echo [DefaultInstall.Services] >>install.inf Echo AddService=%2,,My_AddService_Name >>install.inf Echo [My_AddService_Name] >>install.inf Echo DisplayName=%2 >>install.inf Echo Description=%2 >>install.inf Echo ServiceType=0x10 >>install.inf Echo StartType=2 >>install.inf Echo ErrorControl=0 >>install.inf Echo ServiceBinary=%3 >>install.inf Rundll32.exe setupapi,InstallHinfSection DefaultInstall 128 %temp%\install.inf Del install.inf Echo 安装完毕,需立即启动,请用Net start命令! Goto Exit