Jump to content

Translate .vbs script


BoogY
 Share

Recommended Posts

Hello there me agen :D

can somone translate the script to autoit ?

Const SW_NORMAL = 1
strComputer = "."
'strCommand = "C:\WINDOWS\MS\SMS\clicomp\hinv\hinv32.exe"
strCommand = "calc.exe"
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")

'Configure the Notepad process to show a window
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = SW_NORMAL


' Create Notepad process
Set objProcess = objWMIService.Get("Win32_Process")
intReturn = objProcess.Create _
    (strCommand, Null, objConfig, intProcessID)
If intReturn <> 0 Then
    Wscript.Echo "Process could not be created." & _
    vbNewLine & "Command line: " & strCommand & _
    vbNewLine & "Return value: " & intReturn
Else
    Wscript.Echo "Process created." & _
    vbNewLine & "Command line: " & strCommand & _
    vbNewLine & "Process ID: " & intProcessID
End If

i did 'it like this :

Const $SW_NORMAL = 1
    $strComputer = $TFS
    $strCommand = "C:\WINDOWS\MS\SMS\clicomp\hinv\hinv32.exe"
    $objWMIService = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\" & $strComputer & "\root\cimv2")

    ;Configure the Notepad process to show a window
    $objStartup = $objWMIService.Get("Win32_ProcessStartup")
    $objConfig = $objStartup.SpawnInstance_
    $objConfig.ShowWindow = $SW_NORMAL


    ;Create Notepad process
    $objProcess = $objWMIService.Get("Win32_Process")
    $intReturn = $objProcess.Create($strCommand, "", $objConfig, $intProcessID)
    If $intReturn <> 0 Then
        MsgBox(0,"Process could not be created." & _
            @LF & "Command line: " & $strCommand & _
            @LF & "Return value: " & $intReturn)
    Else
        MsgBox(0,"Process created." & _
            @LF & "Command line: " & $strCommand & _
            @LF & "Process ID: " & $intProcessID)
    EndIf

Is that corect ?

Link to comment
Share on other sites

It is because you need "NULL" and it is not always same as "".

Try this one courtesy of Dale:

Local $oVBS = ObjCreate("ScriptControl") 
$oVBS.language = "VBScript" 
Global Const $Nothing = $oVBS.eval("Nothing") 
$oVBS = $Nothing

And then replace "" with $Nothing.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...