如何将jscript转换为VB.NET [英] How do I convert jscript to VB.NET

查看:92
本文介绍了如何将jscript转换为VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用卡巴斯基安全中心管理所有域计算机上的AV。我正在寻找一种外部方式将计算机移动到不同的组并更改我们在卡巴斯基安全中心提供的评论。卡巴斯基给了我一些退房的链接,但我不知道从哪里开始。我希望在VB.Net Windows窗体应用程序中对此进行编码。



Link1: https://support.kaspersky.com/9291

Link2: https:// support。 kaspersky.com/2810



我的尝试:



下面是我想用vb.net运行的JScript:



We use Kaspersky Security Center to manage AV on all our domain computers. I was looking for an external way to move computers to different groups and change the comments we give them in the Kaspersky Security Center. Kaspersky gave me some links to check out but I have no idea where to start on this. I was looking to code this in a VB.Net Windows Form Application.

Link1: https://support.kaspersky.com/9291
Link2: https://support.kaspersky.com/2810

What I have tried:

below is the JScript i want to run with vb.net:

function AcquireAdServerProxy()
{    
    var oSrvConnectionProps = new ActiveXObject("klakaut.KlAkParams");
    oSrvConnectionProps.Add("Address", "localhost:13291");
    oSrvConnectionProps.Add("UseSSL", true);

    var oAdmServer = new ActiveXObject("klakaut.KlAkProxy");
    oAdmServer.Connect(oSrvConnectionProps);
    return oAdmServer;
};

function Update_Host_Comment(hostid,comment)
{
    var oHosts = new ActiveXObject("klakaut.KlAkHosts");
    oHosts.AdmServer = AcquireAdServerProxy();
    var strHostName = hostid;    //name of the host to change attributes
   //Fill container with attributes to change
    var oProps = new ActiveXObject("klakaut.KlAkParams");
    oProps.Item("KLHST_WKS_COMMENT") = comment;    //Change Comment
    oHosts.UpdateHost(strHostName, oProps);
};

function Update_Host_Group(hostid,groupid)
{
    var oHosts = new ActiveXObject("klakaut.KlAkHosts");
    oHosts.AdmServer = AcquireAdServerProxy();
    var strHostName = hostid;    //name of the host to change attributes
    //Fill container with attributes to change
    var oProps = new ActiveXObject("klakaut.KlAkParams");
    oProps.Item("KLHST_WKS_GROUPID") = groupid;    //Change group
    oHosts.UpdateHost(strHostName, oProps);
};

//Calling Functions
Update_Host_Comment("SomeHostID","Some Comment Text");
Update_Host_Group("SomeHostID","Some GroupID");

推荐答案

嗨。



我只是试图从我的记忆中进行语法转换...... :)



In VB你不是用一个分号结束命令,只是用一个NewLine(VbCrLf)。

在VB中'var'是'Dim',它的语法......

并且函数应该返回一些东西,这就是为什么你不仅在FunctionHeader上设置参数,也是一个返回类型(TypeOf BlaBliBlup)

- > As SomethingToReturn< - 如果你返回一个Printf / String,你应该使用'As String'来设置返回值的类型。



如何使用我忘记的ActiveX ,但基本上你做引用,然后存储到变量,并使用ActiveX实例。

Performe仅适用于少量的ActiveX实例。

很多性能和Errros与ActiveX来自于在Functions / Subs中创建一个新的ActieX实例,然后您必须处理...

示例:如果您只使用一个PDF-ActiveX实例,如果yOu使用相同的文档,请不要消耗太多的内存!



VB中的子类是没有返回类型的函数(无效)。





Hi.

I just tried to do a syntactical conversion "out of my Memory"... :)

In VB You don´t end the command with a Semicolon, just by a NewLine (VbCrLf).
In VB 'var' is 'Dim', and its Syntax...
And the Functions should return something, thats why you set at the FunctionHeader not only Parameters, also a Return-Type (TypeOf BlaBliBlup)
-> As SomethingToReturn <- If You return a Printf/String you should use 'As String' to set the Type ouf the Return Value.

Howto use the ActiveX I forgot, but basicaly you do Referencing, then storeing into a Variable, and consume the ActiveX Instance.
Performe only on a small numbers of the ActiveX Instance(s).
Alot of Performance and Errros with ActiveX come from Creating always a new ActieX Instance inside Functions/Subs, and then You have to handle that...
Example: If you use only one PDF-ActiveX Instance, You don´t consume too much of Memory if yOu are using the same Document!

Subs in VB are "Functions with no Return Type (Void)".


Function AcquireAdServerProxy() As SomethingToReturn
    
    Dim oSrvConnectionProps = New ActiveXObject("klakaut.KlAkParams")
    oSrvConnectionProps.Add("Address", "localhost:13291")
    oSrvConnectionProps.Add("UseSSL", true)

    Dim oAdmServer = new ActiveXObject("klakaut.KlAkProxy")
    oAdmServer.Connect(oSrvConnectionProps)
    Return oAdmServer
End Function

Function Update_Host_Comment(hostid As Something,comment As Something) As SomethingToReturn

    Dim oHosts = new ActiveXObject("klakaut.KlAkHosts")
    oHosts.AdmServer = AcquireAdServerProxy()
    Dim strHostName = hostid     'name of the host to change attributes
    'Fill container with attributes to change
    Dim oProps = new ActiveXObject("klakaut.KlAkParams")
    oProps.Item("KLHST_WKS_COMMENT") = comment   'Change Comment
    oHosts.UpdateHost(strHostName, oProps)
    
    ' Nothing to return ???
End Function

Function Update_Host_Group(hostid,groupid)

    Dim oHosts = New ActiveXObject("klakaut.KlAkHosts")
    oHosts.AdmServer = AcquireAdServerProxy()
    var strHostName = hostid     'name of the host to change attributes
    'Fill container with attributes to change
    var oProps = New ActiveXObject("klakaut.KlAkParams")
    oProps.Item("KLHST_WKS_GROUPID") = groupid     'Change group
    oHosts.UpdateHost(strHostName, oProps)
    
    ' Nothing to return ???
End Function

//Calling Functions
Update_Host_Comment("SomeHostID","Some Comment Text")
Update_Host_Group("SomeHostID","Some GroupID")







这是另一个版本的Update_H ost_Comment。

更改为Sub,并将Parametertypes定义为Integer(hostid)和String(注释)。






Here is another Version of the "Update_Host_Comment".
Changed to a Sub, and Defined the Parametertypes as Integer (hostid) and String (comment).

Sub Update_Host_Comment(hostid As Integer, comment As String)
    Dim oHosts = new ActiveXObject("klakaut.KlAkHosts")
    oHosts.AdmServer = AcquireAdServerProxy()
    Dim strHostName = hostid     'name of the host to change attributes
    'Fill container with attributes to change
    Dim oProps = new ActiveXObject("klakaut.KlAkParams")
    oProps.Item("KLHST_WKS_COMMENT") = comment   'Change Comment
    oHosts.UpdateHost(strHostName, oProps)
End Sub





也许这会有所帮助。



这不是工作代码。



只是为了介绍你的例子,我不是VB大师。



cu来自阳光明媚的汉堡



Maybe this will help.

This is not Working Code.

Just to get an intro by your example, and I am not a VB Guru.

c.u. from sunny Hamburg


这篇关于如何将jscript转换为VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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