Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vb script for a task
#1
Solved: 10 Years, 7 Months, 3 Weeks ago
Hi All,



need help on a vb script

task:

1. we have an excel of 2 columns onw with host name and 2 with Ip Adress
2.Write a code ns lokkup host name in CMd prompt and get the Ip adress
3. COmpare the 2 ip adresses
4.iff the IP macthces then true msg box or esle false
Reply
#2
Solved: 10 Years, 7 Months, 3 Weeks ago
You can use wscipt.shell to execute the command and get the output using stdout.readall method.
here is some guidelines you can use -
1. get the host name and ip address from excel
2. Execute the ns lookup command with the returned host name
3. Get the output with stdout
4. Parse the ip address and compare

Reply
#3
Solved: 10 Years, 7 Months, 3 Weeks ago
thanks saket .

can u let me know any sample code
I tried recording through QTP but the C command prompt are not captured by QTP
Reply
#4
Solved: 10 Years, 7 Months, 3 Weeks ago
Code:
Set oWshShell = CreateObject("wscript.Shell")
sCmd = "nslookup .." 'put your command here

Set oExec = oWshShell.Exec(sCmd)
sStdout = oExec.StdOut.ReadAll
sStdErr = oExec.StdErr.ReadAll

MsgBox "stdout: " & sStdout &  " stderr: " & sStderr
let me know if this helps

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)