Sign in to follow this  
Followers 0
BoogY

Translate .vbs script

6 posts in this topic

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 ?

Share this post


Link to post
Share on other sites



If you tried and work is corect.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

no its not working this line of code gives an error :

$intReturn = $objProcess.Create($strCommand, "", $objConfig, $intProcessID)
because of the ""

Share this post


Link to post
Share on other sites

is there any alternatif on qutoit for NULL ?!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Description for that parameter says: "if NULL, the new process will have the same path as the calling process". That means you can replace NULL with @ScriptDir macro, besides Juvigy's suggestion.


♡♡♡

.

eMyvnE

Share this post


Link to post
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
Sign in to follow this  
Followers 0