cowsmanaut Posted June 17, 2006 Share Posted June 17, 2006 (edited) I'm trying to run an IPconfig on a romote computer on our little network using the PStools here.. I can do it from the command line easy enough.. but with autoit seems like it's bailing. Right now it's not running the script due to something it doesn't like in the part that is supposed to copy the file from their computer to mine. ;send ipconfig request to selected computer run ( @ComSpec & "psexec \\" & $data & "ipconfig /all c:/ip.txt", , @SW_HIDE) ;copy the file to a local folder FileCopy("\\" & $data & \c$\ip.txt", "c:\*.*") ;open the file $file = FileOpen("c:/ip.txt", 0) there is the code I've made perhaps someone could find where I went wrong? thanks just to mention.. the $data is fed in from a command box so that the user can specify which computer he wants the info from. Edited June 17, 2006 by cowsmanaut Link to comment Share on other sites More sharing options...
Sardith Posted June 17, 2006 Share Posted June 17, 2006 It would help if you gave us all of your code. You have a lot of syntax errors, also $Data is undeclared. But.. ;send ipconfig request to selected computer run ( @ComSpec & "psexec \\" & $data & "ipconfig /all c:/ip.txt", @SW_HIDE) ;copy the file to a local folder FileCopy("\\" & $data & "\c$\ip.txt", "c:\*.*") ;open the file $file = FileOpen("c:/ip.txt", 0) [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font] Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 (edited) the rest of the code works and I've tested it on the local machine. $data is declared earlier in the script as the input for the name of the machine. ie $data = computer01 so I'm expecting it to: \\ $data \c$\ip.txt = \\computer01\c$\ip.txt It's now choking at the \c$ which is windows way of saying go to the C:\\ drive on the networked computer.. the automatic share name is c$. So, here's the whole code as requested.. expandcollapse popup#include <GuiConstants.au3> ; Create the GUI window and controls GuiCreate("IP Get", 191, 157,(@DesktopWidth-191)/2, (@DesktopHeight-157)/2) $Label_1 = GuiCtrlCreateLabel("Select", 30, 40, 131, 21, 0x1000) $Combo_2 = GuiCtrlCreateCombo("", 30, 60, 130, 21) GuiCtrlSetData($combo_2, "digi01|dig02|digi03|digi04|digi05|dig06|digi07|digi08|digi09|digi10|dig11|digi12|digi13|dig14|di gi15|digi16|digi17|dig18|digi19|digi20|digi21|digi22") $button1 = GuiCtrlCreateButton("Get IP", 30, 90, 130, 20) ; Run the GUI until it is closed GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop ;Takes the information from changed button to ;Communicate with selected computer Case $msg = $button1 $data = GUICtrlRead($Combo_2) ;send ipconfig request to selected computer run ( @ComSpec & "psexec \\" & $data & "ipconfig /all c:/ip.txt", @SW_HIDE) ;copy the file to a local folder FileCopy("\\" & $data & "\c$\ip.txt", "c:\*.*") ;open the file $file = FileOpen("c:/ip.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines 29 and 35 $chara = FileReadLine($file, 29) If @error = -1 Then ExitLoop $charb = FileReadLine($file, 35) If @error = -1 Then ExitLoop MsgBox(0, $data, $data & " information:" & @cr & @cr & $chara & @cr & $charb) FileClose($file) EndSelect WEnd Exit I doubt that will make it any more clear.. as the error is local to this specific set of actions which is appart from the rest of the functions of the script... but there it is Edited June 19, 2006 by cowsmanaut Link to comment Share on other sites More sharing options...
Danny35d Posted June 19, 2006 Share Posted June 19, 2006 Check your Run function, after @Comspec you are missing /c and then psexec run ( @ComSpec & " /c psexec \\" & $data & "ipconfig /all c:/ip.txt", @SW_HIDE) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 actually.. I think it's choking on PSexec .. which is in the same folder as the script.. where should it be? Link to comment Share on other sites More sharing options...
Danny35d Posted June 19, 2006 Share Posted June 19, 2006 (edited) Psexec should be at the same folder as the running script. Did you try my suggestion this is right off the help fileTo run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) Edited June 19, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 (edited) actually.. I think it's choking on PSexec .. which is in the same folder as the script.. where should it be?yes definitely the program as I made the changes you suggest but still doesn't run.. yet I was missing some things .. like a space in front of IPconfig and I was missing the > before c:\ip.txtI tested it in the command prompt manually and it works..psexec \\digi02 ipconfig /all > c:/ip.txtbut from the script it says cannot execute external program, path not specified. ;send ipconfig request to selected computer run ( @ComSpec & "/c psexec \\" & $data & " ipconfig /all > c:/ip.txt", @SW_HIDE)moo Edited June 19, 2006 by cowsmanaut Link to comment Share on other sites More sharing options...
Danny35d Posted June 19, 2006 Share Posted June 19, 2006 (edited) There are two thing that you can do:1) run ( @ComSpec & "/c psexec \\" & $data & " ipconfig /all > c:/ip.txt", @ScriptDir, @SW_HIDE)2) $PsexecPath = FileGetShortName(@ScriptDir)run ( $PsexecPath & "\psexec.exe \\" & $data & " ipconfig /all > c:/ip.txt", @SW_HIDE)Note: you can also check your syntax by changing /c for /k and @SW_HIDE for @SW_SHOW ones you are happy with the output switched back to /c and SW_HIDE.run ( @ComSpec & "/k psexec \\" & $data & " ipconfig /all > c:/ip.txt", @SW_SHOW) Edited June 19, 2006 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 (edited) just tried even doing this in CMD C:\au3_tool\psexec.exe \\digi02 ipconfig /all > c:/ip.txt and it worked.. and yet.. run ( @comspec & "C:\au3_tool\psexec.exe \\digi02 ipconfig /all > c:/ip.txt") this will not.. nor will run ( @comspec & "/c C:\au3_tool\psexec.exe \\digi02 ipconfig /all > c:/ip.txt") nor runwait ( @comspec & "C:\au3_tool\psexec.exe \\digi02 ipconfig /all > c:/ip.txt") what is wrong here???!!! I'm going crazy.. everything seems right but it won't work edit woah.. you just posted... checking.. Edited June 19, 2006 by cowsmanaut Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 ok tried your directory stuff run ( @ComSpec & "/c psexec \\" & $data & " ipconfig /all > c:/ip.txt", @ScriptDir, @SW_HIDE) still the same error for both.. keeps complaining about "Error: can not execute external program. The system can not find the path specified" I used this program once before in an older AU3 script and it did work.. I had done this : run ( @comspec & "c:\au3_tool\psexec \\digi"& $digi &" -i c:\au3_test\caphost.exe") and $digi was defined as a 01, 02, 03, etc by radio buttons on the GUI. it worked fine.. yet now this thing refuses to work. I have no idea what is going on Link to comment Share on other sites More sharing options...
Danny35d Posted June 19, 2006 Share Posted June 19, 2006 Sorry cowsmanaut but, I run out of idea, just a long shot I notice c:/ip.txt instead of c:\ip.txtrun ( @ComSpec & "/c psexec \\" & $data & " ipconfig /all > c:\ip.txt", @ScriptDir, @SW_HIDEmay be that is the path that can not be found.... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 was hunting through and found annother reference to the comspec in a recent post.. using @systemdir .. so I changed my request based on that to : Run(@ComSpec & ' /c ' & @ScriptDir & "psexec \\" & $data & " ipconfig /all > c:/ip.txt", '', @SW_HIDE) and now it doesn't give an error about the program.. however it now makes a blank Ip.txt ... so it seems to run the command but it doesn't execute correctly. I'm wondering.. is it perhaps an administrative issue? Does the command use the current active users access or just the systems own access? Am I just taking stabs in the dark? I can feel it... almost there.. :S Link to comment Share on other sites More sharing options...
Danny35d Posted June 19, 2006 Share Posted June 19, 2006 I can't remember all psexec switches but if you don't use -u it will use current active users access, also try running your script with /k and @SW_SHOW so you can see the output at the command prompt window I think you are missing a backslash \Run(@ComSpec & ' /c ' & @ScriptDir & "\psexec \\" & $data & " ipconfig /all > c:\ip.txt", '', @SW_HIDE) AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 tried adding the slash.. I also used the /k and @SW_Show and I get a window that just shows that it is indeed at the scripts dir.. however no command is shown.. The end result is yet again a 0k text file :S so close I can taste it. Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 19, 2006 Author Share Posted June 19, 2006 ok.. still going nuts here... decided.. ok what the heck.. get rid of the network aspect and just try it locally Run(@ComSpec & ' /k ' & @ScriptDir & "ipconfig /all > c:/ip.txt", '', @SW_SHOW) this also produces a blank txt file.. is this something with the ipconfig command??? can anyone at least get *THIS* to work? Link to comment Share on other sites More sharing options...
w0uter Posted June 20, 2006 Share Posted June 20, 2006 (edited) Run('C:\windows\system32\cmd.exe /k C:\Program Files\AutoIt v3ipconfig /all > c:/ip.txt') is that what you want ? you just want Run(@ComSpec & ' /c ipconfig /all > c:/ip.txt') AFAIK Edited June 20, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
cowsmanaut Posted June 20, 2006 Author Share Posted June 20, 2006 thanks.. some how you gave me the perspective I needed to understand what I was messing up over and over again.. I was using " instead of ' Run(@ComSpec & ' /k c:\au3_tool\psexec \\' & $data & ' ipconfig /all > c:/ip.txt', '', @SW_SHOW) the above works now every time. silly little things.. almost invisible.. thank you both for all your help cheers 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