将我的VBS代码转换为C#代码 [英] Convert My VBS code to C# Code

查看:100
本文介绍了将我的VBS代码转换为C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我有vbs代码来启动/停止Windows中的索引服务,并使用vbs添加目录,范围. vbs代码是

-要在Windows中启动索引服务

Hi ALL ,


I have vbs code to start/stop indexing services in windows and add catalog,scope using vbs. The vbs code is

--To Start Indexing Service in windows

Set objISAdm = CreateObject("Microsoft.ISAdm")
If objISAdm.IsRunning= False then
    objISAdm.start()
end if



-在Windows中创建目录索引服务



--To create catalog Indexing Service in windows

Function AddCatalog(bstrCatName As String, bstrCatLocation As String) As Object
Set objISAdm = CreateObject("Microsoft.ISAdm")
objISAdm.stop()
Set objCatalog = objISAdm.AddCatalog("MyCatalog","c:\Mycatalog")
objISAdm.start()




-将范围分配给Windows中的目录索引服务




--To assign scope to a catalog Indexing Service in windows

Set objISAdm = CreateObject("Microsoft.ISAdm")
Set objCatalog = objISAdm. GetCatalogByName("MyCatatlog")
Set objScope= objCatalog.AddScope("C:\myfiles",False)
objScope.Alias = "MyCatalogScope"




我想要在C#中使用相同的代码.




I want the same code in C#. How to convert or equivalent classes.

推荐答案

要启动/停止服务,最好使用WMI,请参见:
To start/stop service it is better to use WMI see here : Using WMI to manipulate services (Install, Uninstall, Start, Pause etc)


希望在这里可以找到解决方案
转换器
Hope here you can find solution
Convertor


这篇关于将我的VBS代码转换为C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆