BoogY Posted September 25, 2009 Posted September 25, 2009 Hello there me agen 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 ?
BoogY Posted September 25, 2009 Author Posted September 25, 2009 no its not working this line of code gives an error : $intReturn = $objProcess.Create($strCommand, "", $objConfig, $intProcessID)because of the ""
BoogY Posted September 25, 2009 Author Posted September 25, 2009 is there any alternatif on qutoit for NULL ?!
Juvigy Posted September 25, 2009 Posted September 25, 2009 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.
trancexx Posted September 25, 2009 Posted September 25, 2009 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now