Jump to content

Recommended Posts

Posted

in dos we are able to truncate the value of a variable as such

%fecha:~24,9%

is there a way to do that in autoit?

id like to truncate

bguser\abcds

where abcds can be anywhere between 2-10 characters

hope this make sense

Posted

$x = StringSplit("bguser\absgdghgfhfgjf","\")
$x[1] ;-> "bguser"
$x[2] ; -> "absgdghgfhfgjf"

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

ok on the right track.. but when i did this, it user[2] = "absgdghgfhfgjf"

and NOT what the value truly is

i want it to grab anything after the "\" regardless of what the characters are

did i forget something?

thanks

Posted

ok on the right track.. but when i did this, it user[2] = "absgdghgfhfgjf"

and NOT what the value truly is

i want it to grab anything after the "\" regardless of what the characters are

did i forget something?

thanks

That IS the text after the slash.
Posted

thats the text in the code.. but not the text from the registry values im pulling from different remote machines.

Posted

thats the text in the code.. but not the text from the registry values im pulling from different remote machines.

Can you post an example string?

Posted

sorry maybe i shoulda mentioned this before..im pulling registry values from remote machines (so the values are always changing depending on what machine im querying)

$user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")

THEN i try to get just the username (wout the domain) as the value. the following returns "asdfasdf" only

$user = StringSplit("BGUSER\asdfasdf", "\")

MsgBox(0,"",$user[2])

sorry bout that.

Posted

ok here are the exact details/steps:

$user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")

this outputs different values for different machines:

BGUSER\AFKDD

BGUSER\KJDKF

BGUSER\DKFJDJF

TGUSER\DKFJ

CGUSER\DFLKLD

etc...

i want to seperate both sides of the "\" for each entry no matter what the domain is or the account name. i would imagine i only need to specify the seperator and maybe use some type of wildcard?

hope i was clearer this time =)

Posted (edited)

???

$user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")
$array=StringSplit($user,"\")
MsgBox(0,"",$array[1]) ; This is the left side of the \ sign
MsgBox(0,"",$array[2]) ; This is the right side of the \ sign
Edited by monoceres

Broken link? PM me and I'll send you the file!

Posted (edited)

weird it works when you do it on one machine.. which makes sense. but not when u do it on an array of machines.

error " array variable has incorrect number of subscripts or subscript dimension range exceeded."

still looking..

thanks.

Edited by gcue
Posted

weird it works when you do it on one machine.. which makes sense. but not when u do it on an array of machines.

error " array variable has incorrect number of subscripts or subscript dimension range exceeded."

still looking..

thanks.

Gotta debug man.

$assets[4] = ["Computer1","Computer2","Computer4","Computer4"]

For $X = 0 to Ubound($assets) - 1
    ConsoleWrite("Computer name: " & $assets[$x] & @CRLF)
    $user = RegRead("\\" & $assets[$x] & "\HKEY_LOCAL_MACHINE\SOFTWARE\Altiris\Altiris Agent\Inventory", "PrimaryUser")
    
    If NOT @ERROR Then
        $array=StringSplit($user,"\")
        ConsoleWrite("Username: " & $array[1] & @CRLF) ; This is the left side of the \ sign
        ConsoleWrite("Domain: " & $array[2] & @CRLF) ; This is the right side of the \ sign     
    Else
        ConsoleWrite("RegRead FAIL" & @CRLF)
    EndIf
    ConsoleWrite(@CRLF)
Next

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
  • Recently Browsing   0 members

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