gleem Posted June 8, 2006 Share Posted June 8, 2006 After successfully writing my auto application installer, my boss wants me to write a program that would poll the network for any computers that are on and shut them down (after 8 pm) of course I would have a white list for pcs that will remain on; anywho, to get started.. I would like to ping the domain for active pcs on the network and dump it to a text file. I know I can achieve this by simply using a dos command: net view /domain:mydomain > c:\ip.txt this works great; however, the output in which it is set up will cause problems when I pull data from this text file. Ideally, I would like to have it so that the program spits either the ip address or computername alone (without the \\). That way, I can set each computer or ipaddress as a varable and use the shutdown command. Link to comment Share on other sites More sharing options...
Valuater Posted June 8, 2006 Share Posted June 8, 2006 (edited) i use this as the first part of a messeage sending program expandcollapse popup;delete last listing Filedelete(@TempDir & "\b.tmp") ;gets the computer list and a few other things RunWait(@ComSpec & ' /c net view > ' & @TempDir & '\a.tmp',"", @SW_HIDE) Sleep(300) ;open the file for working $file = FileOpen(@TempDir & "\a.tmp", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "QT - Error", "Unable to open file.") Exit EndIf ;Creates new file in which the result will be written FileOpen(@TempDir & "\b.tmp", 1) ; Read in lines of text until the EOF is reached in file a.tmp While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop ;find the string "\\" $result = StringInStr($line,"\\") if $result = 1 Then ;find next blank $blankpos = StringInStr($line," ") ;Find length of line $len = StringLen($line) ;calculate from what position to Trim string to the right $len = $len - $blankpos ;Trim all characters after the computer name $line = StringTrimRight($line, $len) ;Trim the // $line = StringTrimLeft($line,2) ;Write line to file, adding "|" FileWrite(@TempDir & "\b.tmp", $line & "|") EndIf Wend FileClose($file) FileDelete(@TempDir & "\a.tmp") $file2 = FileReadline(@TempDir & "\b.tmp", 1) MsgBox(0,0, $file2) 8) Edited June 8, 2006 by Valuater 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