Jump to content

Read cell from Excel and then send data


Recommended Posts

Hi there,

Sorry I am a newbie to this. I have created a gui box with various buttons which interact with pstools commands, the data is output via a DOS window and mostly the hostname that I want to interact with comes from the INPUT box within the gui.

So,

Case $msg = $Button_7

; PSLIST

$iPID = Run('cmd.exe')

WinWaitActive("")

send ("c: {ENTER}")

send ("cd\ {ENTER}")

send ("cd c:\temp\ps {ENTER}")

Send('pslist \\' & GUICtrlRead($Input) & '{ENTER}')

SO if the input box contained data:10.10.10.10, the PSTools command "pslist \\10.10.10.10" will be fired up in a DOS window.

Now rather than grab hostnames from an input box, I want it to grab the hostname(s) from the first cell (or even a column) in an active excel sheet. This is where I am getting a bit stuck. So assuming that cell A1 has 10.10.1.1 in it, I included the "#Include <Excel.au3>" in the top of the script and then tried:

Case $msg = $Button_8

; IPconfig check on remote PC

$iPID = Run('cmd.exe')

WinWaitActive("")

;Read the cell A1 which contains the numbers: 10.10.1.1

_ExcelReadCell($oExcel, $sA [, $iColumn = 1])

; now the following should bring up another DOS window with the remote cmd prompt running from the ip 10.10.1.1 that was in the excel list

send ("psexec \\ &_ExcelReadCell cmd {ENTER}")

winwaitactive ("")

However, something keeps failing. Would be grateful for any help you can give.

Basically, I am trying to open a cmd prompt from another machine using PSEXEC...once opened, we are going to do a "ipconfig/all" and want to see if the machine is configured with DHCP=YES ot DHCP=no (ie static).

THanks

PJ

Link to comment
Share on other sites

Try to debug a little bit.

#include <Excel.au3>
Local $oExcel = _ExcelBookOpen(@ScriptDir & '\ip.xlsx', 0, 0)

For $i = 1 To 5 ;Loop
    $sCellValue = _ExcelReadCell($oExcel, $i, 1)
    ConsoleWrite($sCellValue & @CRLF)
Next

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

;Read the cell A1 which contains the numbers: 10.10.1.1

_ExcelReadCell($oExcel, $sA [, $iColumn = 1])

What does $sA equal? This would be the correct way to read Cell A1:

_ExcelReadCell($oExcel,1,1)

If you look in the help file the first number is the column (The letter in excel) and the 2nd number is the row (the numbers in excel).

You could use a for loop to read an entire column in excel if you want to:

$iCnt = 1
While 1
     $sRead = _ExcelReadCell($oExcel,$iCnt,1)
     If $sRead = "" Then ExitLoop
     ;Do what you want with the data gathered
     $iCnt +=1
WEnd
Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

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