gcue Posted April 21, 2008 Share Posted April 21, 2008 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 Link to comment Share on other sites More sharing options...
ProgAndy Posted April 21, 2008 Share Posted April 21, 2008 $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 Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 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 Link to comment Share on other sites More sharing options...
weaponx Posted April 21, 2008 Share Posted April 21, 2008 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. Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 thats the text in the code.. but not the text from the registry values im pulling from different remote machines. Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Share Posted April 21, 2008 Tell me this doesn't work: $x = StringSplit("bguser\absgdghgfhfgjf","\") MsgBox(0,"",$x[2]) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
weaponx Posted April 21, 2008 Share Posted April 21, 2008 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? Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 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. Link to comment Share on other sites More sharing options...
weaponx Posted April 21, 2008 Share Posted April 21, 2008 Not so hard. MsgBox(0,"",$user[1]) Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 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 =) Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Share Posted April 21, 2008 (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 April 21, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
gcue Posted April 21, 2008 Author Share Posted April 21, 2008 (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 April 21, 2008 by gcue Link to comment Share on other sites More sharing options...
weaponx Posted April 21, 2008 Share Posted April 21, 2008 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 Link to comment Share on other sites More sharing options...
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