Jump to content

Strings


Nunos
 Share

Go to solution Solved by Nunos,

Recommended Posts

Found some code on the forums that grabs information about the bios that I am trying to get into a format and write to a logfile. 

$iPid = Run("cmd /c powershell get-wmiobject win32_BIOS", "", @SW_HIDE, $stdout_child)

$sOutput = ""

While 1
    $sOutput &= StdoutRead($iPid)
    If @error Then
        ExitLoop
    EndIf
WEnd

$aOut = StringSplit($sOutput, @LF, 2)

_ArrayDelete($aOut, "0-1 ; 7-10")


Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Write the serial number data from BIOS
    IniWrite($sFilePath, "Information", "Serial", $aOut[03])

    $sSerial = IniRead($sFilePath, "Information", "Serial", "Serial Number")
    MsgBox($MB_ICONINFORMATION, "Serial Number from BIOS", $sSerial)

$aOut[03] returns SerialNumber : and a variable length string. I only need the string but when I am not able to get stringsplit to return just everything after the ":" and I was not able to get stringtrim either left or right working.

Can someone teach me how to use the proper one please? 

Link to comment
Share on other sites

  • Solution

Please disregard I found my error.

$iPid = Run("cmd /c powershell get-wmiobject win32_BIOS", "", @SW_HIDE, $stdout_child)

$sOutput = ""

While 1
    $sOutput &= StdoutRead($iPid)
    If @error Then
        ExitLoop
    EndIf
WEnd

$aOut = StringSplit($sOutput, @LF, 2)

_ArrayDelete($aOut, "0-1 ; 7-10")
$iOut = StringSplit($aOut[03], ":")
_ArrayDisplay($iOut[02])


Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir)

    ; Write the serial number data from BIOS
    IniWrite($sFilePath, "Information", "Serial", $iOut[02])

    $sSerial = IniRead($sFilePath, "Information", "Serial", "Serial Number")
    MsgBox($MB_ICONINFORMATION, "Serial Number from BIOS", $sSerial)

I had the $iOut[VALUE] left on 03 

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...