Using VBS with Windev

Startbeitrag von Mark Nelson am 23.02.2014 21:21

********* CODE 1 **********************

ResultatVbs is a string

ScriptVBS is string = [
FUNCTION delltage()
strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

FOR EACH objSMBIOS IN objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
delltage = "Serial Number: " & objSMBIOS.SerialNumber
Next
END FUNCTION
]


//MSScriptControl>>AllowUI = True
MSScriptControl>>Language ("VBScript")

MSScriptControl >> AddCode (ScriptVBS)
MSScriptControl>>Timeout(-1)
ResultatVbs = MSScriptControl>>Run("delltage")

Info(ResultatVbs)


******* CODE 2**********


ResultatVbs is a string

ScriptVBS is string = [
FUNCTION JoinDomian()
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2

strDomain = %1
strUser = %2
strPassword = %3

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
'Join Computer TO domain
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, Null, _
JOIN_DOMAIN + ACCT_CREATE)

IF ReturnValue = 0 THEN
ELSE
JoinDomian "Error encountered joining computer to domain error: " & ReturnValue
END IF
END FUNCTION
]

MyResult is string = StringBuild(ScriptVBS,"Domain","username","Password")

//MSScriptControl>>AllowUI = False
MSScriptControl>>Language ("VBScript")

MSScriptControl >> AddCode (MyResult)
MSScriptControl>>Timeout(-1)
ResultatVbs =MSScriptControl>>Run("JoinDomian")
Info(ResultatVbs)

Antworten:

Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.