powershell – 如何使用批处理或vbscript向Windows 7/8搜索索引
发布时间:2020-12-14 01:59:21 所属栏目:Windows 来源:网络整理
导读:我正在尝试以编程方式向我的 Windows 8搜索索引添加位置(范围).经过一些谷歌搜索,我发现这个代码从 [here]: Set objISAdm = CreateObject("Microsoft.ISAdm")Set objCatalog = objISAdm. GetCatalogByName("MyCatatlog")Set objScope= objCatalog.AddScope(
我正在尝试以编程方式向我的
Windows 8搜索索引添加位置(范围).经过一些谷歌搜索,我发现这个代码从
[here]:
Set objISAdm = CreateObject("Microsoft.ISAdm") Set objCatalog = objISAdm. GetCatalogByName("MyCatatlog") Set objScope= objCatalog.AddScope("C:myfiles",False) objScope.Alias = "MyCatalogScope" 不幸的是,800A01AD错误提示无法创建对象’Microsoft.ISAdm’.进一步挖掘,似乎上面的代码不适用于Windows 8上的较新版Windows Search. 有谁知道如何使用vb脚本或从命令行?据推测,在Windows 7下工作的东西也适用于Windows 8. 解决方法
加雷特,你才是天才!这是我从您提供的链接中学到的代码:
#Code copied from "Powershell Tackles Windows Desktop Search" http://powertoe.wordpress.com/2010/05/17/powershell-tackles-windows-desktop-search/ #Microsoft.Search.Interop.dll is needed,download from http://www.microsoft.com/en-us/download/details.aspx?id=7388 #Load the dll Add-Type -path "D:UnattendUserFilesToolsMicrosoft.Search.Interop.dll" #Create an instance of CSearchManagerClass $sm = New-Object Microsoft.Search.Interop.CSearchManagerClass #Next we connect to the SystemIndex catalog $catalog = $sm.GetCatalog("SystemIndex") #Get the interface to the scope rule manager $crawlman = $catalog.GetCrawlScopeManager() #add scope $crawlman.AddUserScopeRule("file:///D:*",$true,$false,$null) $crawlman.SaveAll() 将代码保存为AddScope.ps1,并从提升的cmd控制台运行它: PowerShell Set-ExecutionPolicy Unrestricted -force PowerShell D:UnattendUserFilesAddScope.ps1 而已! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |