Jump to content
Sign in to follow this  
kpu

Read from File and Execute Program

Recommended Posts

Hey All,

I need some help with this one. I wrote a script that connects to a remote PC's IPC$ and then locates a certain file on the root of "C:\" . We put a rev#.exe on there so we know what rev. version the image is. So, if it's rev11. You get a message box telling you what version it is. The first code here is what I currently use. Just shortend some.

; Run Dos command to connect to the IPC$ with Administrative Priviages
RunWait(@ComSpec & " /c " & "net use \\" & $answer &"\IPC$ /U:Administrator Password > c:\temp.txt", "", @SW_HIDE)
$info = FileReadLine ("C:\temp.txt" , 1 )
; ----------------------------------------------------------------------------

;Check to see if the command completed Successfull
if $info = "" then
MsgBox(016, "Warning", "Could not Connect To PC.","")
FileDelete ( "C:\temp.txt" )
Run("osc.exe", "c:\OS1")
WinWaitActive ( "Enter Password", "",  )
Send("password")
Send("{ENTER}")
$var = Ping($answer,250)
If $var Then; also possible:  If @error = 0 Then ...
    Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
    Msgbox(0,"Status","An error occured with number:" & @error & @LF & "1 = Host is Offline" & @LF & "2 = Host is unreachable" & @LF & "3 = Bad destination"& @LF & "4 = Host probably doesn't exist" )
EndIf
exit
else
;MsgBox(0,"Completed SuccessFull", $info, "")
FileDelete ( "C:\temp.txt" )
EndIF
; ----------------------------------------------------------------------------
;Check Rev ----NET Use to Connect to IPC$----
; ----------------------------------------------------------------------------

If FileExists("\\" & $answer & "\c$\osrev12.exe") then
MsgBox(0,"Information","Os is Rev12","")
RunWait(@ComSpec & " /c " & "net use" & " \\" & $answer & "\IPC$ /delete" & " > c:\temp.txt", "", @SW_HIDE)
Run("osc.exe", "c:\OS1")
WinWaitActive ( "Enter Password", "",  )
Send("akm")
Send("{ENTER}")
exit
endif

What I would like to do is read the $answer from a file instead. So this is what I currently have, which is basically cut and pasted out of the Help file.

#include <file.au3>
Dim $PCs
If Not _FileReadToArray("PCs.txt",$PCs) Then
   MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
   Exit
EndIf
For $x = 1 to $PCs[0]
    Msgbox(0,'Record:' & $x, $PCs[$x])
Next

What I would like it to do is Run my code above with a message box telling me if it was able to locate the file. I don't understande what

1 to $PCs[0]

means. Just to make sure I'm clear, here is the steps I need it to work.

1. Read line by line from a file called PCs.txt

2. Connect to a remote PC's IPC$ from the first line.

3. Display message if unable to connect.

4. If able to connect, check to see if the file is there and what name.

4. Give a message box Telling what rev version the PC is.

5. Disconnect from the the IPC$.

6. Repeat until there are no more lines.

Thanks!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...