Briandr

command works outside of autoit script, not inside autoit script

4 posts in this topic

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=ModelWrapper.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=Install wrapper
#AutoIt3Wrapper_Res_Description=Install wrapper
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=p
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <File.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#RequireAdmin

Dim $Model

$LogDirectory = @WindowsDir & "\Dell\KACE"
$ModuleName = @ScriptName
$ModuleName = StringSplit($ModuleName, ".")
$ModuleName = $ModuleName[1]
$Log = $LogDirectory & "\" & $ModuleName & ".log"
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$StrComputer = "localhost"

If Not FileExists($LogDirectory) Then DirCreate($LogDirectory) ;Creates path if does not exist
If FileExists($Log) Then FileDelete($Log)

_FileWriteLog($Log, $ModuleName & " module called.")

_Win32_ComputerSystem() ;Get Model

;Enable LAN/WLAN for newer models using a custom text file to apply the setting
If $Model = "HP ProBook 645 G1" Or $Model = "HP ProBook 645 G2" Or $Model = "HP EliteBook Folio 9470m" Or $Model = "HP EliteBook Folio 9480m" Or $Model = "HP ProBook 840 G2" Or $Model = "HP EliteBook Revolve 810 G2" Or $Model = "HP EliteBook Revolve 810 G3" Then ; Not a laptop or system not supported, do nothing
   $retval = RunWait(@ComSpec & ' /c ' & "BiosConfigUtility.exe /SetConfig:config1.txt", @ScriptDir, @SW_HIDE)
 EndIf

;Enable LAN/WLAN for HP EliteBook 2560p using a custom text file to apply the setting
If $Model = "HP EliteBook 2560p" Then
   $retval = RunWait(@ComSpec & ' /c ' & "BiosConfigUtility.exe /SetConfig:config2.txt", @ScriptDir, @SW_HIDE)
EndIf

;Enable LAN/WLAN for HP ProBook 6455b, HP EliteBook 2540p using a custom text file to apply the setting
If $Model = "HP ProBook 6455b" Or $Model = "HP ProBook 6465b" Or $Model = "HP EliteBook 2540p" Then
  $retval = RunWait(@ComSpec & ' /c ' & "BiosConfigUtility.exe /SetConfig:config3.txt", @ScriptDir, @SW_HIDE)
EndIf

Func _Win32_ComputerSystem()
    ;Get General PC Info
    $objWMIService = ObjGet("winmgmts:\\" & $StrComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            ;$DOMAIN = $objItem.Domain
            $Manufacturer = $objItem.Manufacturer
            $Model = $objItem.Model
            _FileWriteLog($Log, "Model: " & $Model)
            ;$MachineName = $objItem.Name
            ;$NumberOfProcessors = $objItem.NumberOfProcessors
            ;$PartOfDomain = $objItem.PartOfDomain
            ;$MEM = Round($objItem.TotalPhysicalMemory / 1024 / 1024, 0)
        Next
    EndIf
EndFunc   ;==>_Win32_ComputerSystem

Hi,

This line from above works if run outside of the AutoIT executable:

 $retval = RunWait(@ComSpec & ' /c ' & "BiosConfigUtility.exe /SetConfig:config3.txt", @ScriptDir, @SW_HIDE)

When run as part of the script it does nothing. Any ideas?

Thanks.

Share this post


Link to post
Share on other sites



Have you looked in helpfile what's the returned value?

Quote

Return Value

Success: the exit code of the program that was run.

You have to use run with setting the opt_flag as param using $STDOUT_CHILD (0x2) = Provide a handle to the child's STDOUT stream

+ $STDERR_CHILD (0x4) = Provide a handle to the child's STDERR stream

also you have to use in script the StdoutRead func.
   

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

In this particular case, since you are running an executable, and not a cmd shell command, you do not need to run @ComSpec.  You can just run the EXE file.

$retval = RunWait(@ScriptDir & "\BiosConfigUtility.exe /SetConfig:config3.txt", @ScriptDir, @SW_HIDE)

This way you are not inheriting whatever the @ComSpec shell is giving you for a working path, and the workingdir parameter you are passing should take effect and find config3.txt.

Edited by willichan
Additional comment

Share this post


Link to post
Share on other sites

I was referencing just the AutoIT executable. My zip file did not have the config.txt files needed, so my bad. Thanks guys for your suggestions.

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