TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Logan on August 01, 2017, 02:50:56 PM
-
Hello everyone.
Do you know a more elegant way to accomplish this task?
I see a small window to open in the Windows taskbar.
(defun c:pingtest (/ ping)
(defun ping (adress / pingStatus objShell)
(vl-load-com)
(setq objShell (vlax-get-or-create-object "WScript.Shell"))
(setq pingStatus
(vl-catch-all-apply
'vlax-invoke-method
(list
objShell
"Run"
(strcat "ping -n 1 " adress)
6
:vlax-true
) ;_ >list
) ;_ >vl-catch-all-apply
) ;_ >setq
(vlax-release-object objShell)
(gc)
(cond
(
(= 0 pingStatus)
(setq pingStatus t)
)
(
(= 1 pingStatus)
(setq pingStatus nil)
)
(
(vl-catch-all-error-p pingStatus)
(vl-catch-all-error-message pingStatus)
(setq pingStatus nil)
)
) ;_ >cond
) ;_ >defun
(if (ping "www.theswamp.org")
(princ "Status: online")
(princ "Status: offline")
) ;_ >if
(princ)
) ;_ >defun
Best regards
Luís Augusto
-
You could use WMI, e.g.:
(defun ping
( hst
/ qry rtn srv wmi
) qry
(vlax-invoke srv 'execquery
(strcat "SELECT * FROM Win32_PingStatus WHERE Address = '" hst
"'")) )
)
)
)
)
rtn
)
Translated from Rob van der Woude's page (http://www.robvanderwoude.com/vbstech_network_ping.php).
-
Thanks for adapting the code and sharing with us Lee Mac. I really appreciate your work.
The code works the way I need it.
Rob Van der Woude's website is very good and has great examples there. Thanks for sharing.
Luís Augusto.
-
Having poor performance with AutoCAD in combination with some particular projects on part of our network. My guess is that AutoCAD is taking large portions to run the programm and there is little left for moving data. I'm curious if it would be possibe to use this to check network speed (inside / outside AutoCAD?).