Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a question on sending commands to the CMD window

Status
Not open for further replies.

Franklinqiang

Technical User
Dec 16, 2007
2
CN
I have a question on sending commands using Procomm to the windows command line(CMD,dos window).

PLS see my script below:



proc main


winfocus "command prompt"

pause 1

sendkeystr "ipconfig"

sendkey ctrl 'M'

pause 1

alarm 1


winfocus "untitled - notepad"

pause 1

sendkeystr "ipconfig"

sendkey ctrl 'M'

pause 1

alarm 1



endproc


Besides the Procomm mainwindow, I have an opened windows command line window, titled "command prompt" and another opened notepad window, titled "untitled - notepad".

I want my script send "ipconfig^M" to both window,but it only succeeded in the notepad, nothing was sent to the CMD window.


Could you tell me how can I send some commands to the CMD window?
 
Is there any reason you need to send a command to an open cmd window instead of just running the command via the dos command in ASPECT? Below is a script I wrote a while back to get a machine's IP address which shows how to do this:

proc main
string sLine, sIP

dos "ipconfig > c:\ip.txt"
pause 3
fopen 0 "c:\ip.txt" READ TEXT
while not feof 0
fgets 0 sLine
if strfind sLine "IP Address"
strextract sIP sLine ":" 1
strreplace sIP " " ""
strreplace sIP "`n" ""
strreplace sIP "`r" ""
endif
endwhile
fclose 0
delfile "c:\ip.txt"
endproc

 
Thanks knob!

Your script is a good example to communicate with CMD window.

But the CMD window will dispear as soon as the dos command finished.I also want keep the logs and mabe do some other interaction works.

I have find another workaround way:)

Just enable the telnet service on the windows, then use procomm telnet to local ipaddress, then we got a dos CMD window in the procomm, just like we telnet to a unix server.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top