Jump to content

Another: Help parsing a DOS output


Recommended Posts

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.

Link to comment
Share on other sites

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]

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