INF 右键安装驱动以及卸载 分类: 生活百科 2014-09-18 14:03 573人阅读 评论(0) 收藏

INF 右键安装驱动以及卸载

之前写过一篇文章是关于INF文件详解的,大家可以参看INF文件详解,这次写的是关于INF右键安装,这样比较方便。卸载的话也是一句话,可以大大减少安装时间;

先将INF文件内容贴上来:

; OsnDf.inf ; ; Installation file (.inf) for Infocore Corporation OsnDiskCopy driver. ; ; (c) Copyright 2007-2008 Infocore Corporation ; [Version] Signature="$Windows NT$" Provider=%StorTrust% ClassGUID={4D36E967-E325-11CE-BFC1-08002BE10318} Class=DiskDrive DriverVer=01/16/2001, 4.0.0 [DestinationDirs] DefaultDestDir = 12 [DefaultInstall] CopyFiles =OsnDSS.Files OptionDesc =%StorTrust.DeviceDesc% AddReg = OsnDSS.AddReg [DefaultInstall.Services] AddService = OsnDSS,, OsnDSS_Service_Inst, OsnDSS_EventLog_Install [DefaultUninstall] DelFiles =OsnDSS.Files DelReg =OsnDSS.DelRegistry [DefaultUninstall.Services] DelService =OsnDSS,0x00000200,System, [OsnDSS.AddReg] ; append this service to existing REG_MULTI_SZ list, if any HKLM,%OsnDSSRegistery%,"UpperFilters",0x00010008,"OsnDSS" [OsnDSS.DelRegistry] HKLM,%OsnDSSRegistery%,"UpperFilters",0x00018002,"OsnDSS" ; ; File sections ; [OsnDSS.Files] OsnDSS.sys [OsnDSS_Service_Inst] DisplayName = %OsnDSS.SvcDesc% ServiceType = 1 ; SERVICE_KERNEL_DRIVER StartType = 0 ; SERVICE_BOOT_START ErrorControl = 1 ; SERVICE_ERROR_NORMAL ServiceBinary = %12%\OsnDSS.sys [OsnDSS_EventLog_Install] AddReg = OsnDSSEventLogInstall [OsnDSSEventLogInstall] HKR,,EventMessageFile,0x00020000,"%SystemRoot%\System32\IoLogMsg.dll;%SystemRoot%\System32\drivers\OsnDSS.sys" HKR,,TypesSupported,0x00010001,7 ; Source file information ; [SourceDisksNames] 1 = %DiskId1%,,,"" [SourceDisksFiles] OsnDSS.sys = 1,, [Strings] ; ; Non-Localizable Strings ; REG_SZ = 0x00000000 REG_MULTI_SZ = 0x00010000 REG_EXPAND_SZ = 0x00020000 REG_BINARY = 0x00000001 REG_DWORD = 0x00010001 SERVICEROOT = "System\CurrentControlSet\Services" ; ; Localizable Strings ; ClassName = "DiskDrive" StorTrust = "Enterprise Information Management Inc." DiskId1 = "EIM Installation Disk #1" StorTrust.DeviceDesc = "EIM Disk Shadow Copy Driver" OsnDSS.SvcDesc = "EIM Disk Shadow Copy Driver" OsnDSSRegistery = "system\currentcontrolset\control\class\{4D36E967-E325-11CE-BFC1-08002BE10318}"

右键安装,最主要是需要有两个域[DefaultInstall]和[DefaultInstall.Services],只有有这两个域,右键安装的时候才能找到入口;先来讲讲[DefaultInstall]这个域,

CopyFiles =OsnDSS.Files ;这个是将Osndss.sys Copy windows\system32\driver 下

OptionDesc =%StorTrust.DeviceDesc% ;这个是描述下一个驱动是什么,随便填
AddReg = OsnDSS.AddReg ;由于我写的是Disk过滤驱动,所以需要加到注册表UpperFilters键值下面

OsnDSSRegistery = "system\currentcontrolset\control\class\{4D36E967-E325-11CE-BFC1-08002BE10318}" ;其中后面一串数字是表示Disk设备在windows系统里可以识别的ClassGuid,我们的Osndss是 append 在UpperFilters已有的PartMgr后面;这样系统启动的时候会去哪里找到Osndss也需要启动,然后回去找Services里对应的OsnDSS注册表,找到其相关信息;


再来讲讲[DefaultInstall.Services]:

AddService = OsnDSS,, OsnDSS_Service_Inst, OsnDSS_EventLog_Install ;这个在Services添加注册表名为OsnDSS,子域OsnDSS_Service_Inst(这个域内的内容在INF文件详细里有讲,这里就不累赘了),OsnDSS_EventLog_Install 这个是注册一下事件日志;


这样总结一下加载完成了什么:1.Copy sys文件;2在Upperfilters 加入Osndss;3写入注册表services名为Osndss;4写入注册表EventLog-》System里Osndss的注册表;这样我们就可以将驱动sys文件和Inf文件放在同一个目录(最好不好放桌面,随便找个卷都行,桌面好像中文系统的话不识别)然后右键Inf安装就可以了,安装完之后会有提示重启生效的;

还有一种安装方法就是:

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 132 path-to-inf\infname.inf

在Commnd 里输入上面的指令最后的path-to-inf\infname.inf替换为你Inf的路径;



接下来讲下卸载,我们安装什么,理论上我们就应该要卸载什么的。当然微软本身可能就有不少软件,安装之后,在卸载的时候有不少东西不清理掉的,所以系统用久了就会觉得不怎么好使了。

卸载域:

[DefaultUninstall]
DelFiles =OsnDSS.Files ;将Drivers 下面的Osndss.sy删掉;
DelReg =OsnDSS.DelRegistry ;删除Append在Upperfilters里的OsnDSS


[DefaultUninstall.Services]
DelService =OsnDSS,0x00000200,, ;卸载Service下面的OsnDSS 整个子键,后面的两个参数[Eventlog type][eventlogname], EventLog type的话有三种,SystemSecurityApplication,如果是System的话可以默认不写的,如果Eventlog name Servcie下的名字是一样的话也可以不写的,这里我试过多次,Service下面的子键Osndds确实能卸载掉的,但是Eventlog里的不管是默认还是写明了SystemOsndss都无法卸载掉,至今没找到为什么;

卸载的时候就不能用右键了,因为压根就没这个选项,只能用Command

RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultUninstall 132 path-to-uninstall-dir\infname.inf

这样就卸掉了,虽然还遗留Eventlog卸不掉的遗憾

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted @ 2014-09-18 14:03  毛毛虫的薄刻  阅读(228)  评论(0编辑  收藏  举报