Jump to content
Sign in to follow this  
ending

Another: Help parsing a DOS output

Recommended Posts

ending

Ok, I've got everything working fine except for some reason I cannot parse out a carrage return no matter what.

What I'm doing is using the net localgroup command in DOS to get the computer's workgroup name.

Here's the code:

$pid = Run(@ComSpec & " /c net localgroup","",@SW_HIDE,"2")
   While 1
      $line = StdoutRead($pid)
      If @error = -1 Then ExitLoop
        If StringLeft($line,14) = "Aliases for \\" Then
         $localname = StringStripCr(StringAddCr(StringTrimLeft($line,14)))
         ExitLoop
      EndIf
   WEnd
   FileWrite("testoutput.txt",$localname)

I made it output to a file so you could see the extra carrage return. It doesn't show up when you display it in a message box.

I've tried everything from StringTrimLeft to StringStripWS and StringStripCR. All seemed to add in extra characters.

Any sort of help on this, or even another method of grabbing the computer's name.

Share this post


Link to post
Share on other sites
Skruge

Welcome to the forums!

"Net Localgroup" gives you the groups present on the local machine, not the workgroup the machine is in.

You can parse this information from "Net config workstation", or better yet, read it from the registry.

Look at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
herewasplato

...another method of grabbing the computer's name.

MsgBox(0, "@ComputerName", @ComputerName)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites
ending

MsgBox(0, "@ComputerName", @ComputerName)

Works wonders. Thank you both.

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
Sign in to follow this  

×