Command-line connection to listening client from Vista machine? [now SCRIPTS]
Philip Herlihy
Philip at Herlihy.eu.com
Mon Jul 6 20:00:33 BST 2009
EDIT is pretty old stuff. I just use notepad, or maybe an advanced
programmer's editor like ConText or Crimson Editor (which can highlight
keywords, both free). Sometimes I use Vi on Windows for the "Regular
Expression" support! Just create the text anyhow and save with either .cmd
(preferred) or .bat extension (see here
<http://en.wikipedia.org/wiki/Batch_file> for differences) - then run it.
The VB family (VB, VBA, VBS) are different. They need a "runtime" to
provide library functions. In Excel VBA, the runtime is built into Excel
(VBA scripts don't run in isolation). In full-blown VB, you have to provide
a runtime as part of the installation package. With VBS, you can use
Cscript.exe or Wscript.exe to provide the necessary environment within the
NT command-line environment. See http://support.microsoft.com/kb/232211 for
more, or see http://technet.microsoft.com/en-gb/scriptcenter/default.aspx
for tons of stuff. Do understand that vanilla NT scripting is considered
really old hat these days.
After my signature I'll paste in a recent (crude) example NT script. Copy
into Notepad and save as PingMonitor.cmd and run it. All it does is loop,
pinging an IP address (set in a variable), in this case the BBC. When it
responds, it plays a sound (your path may vary, as may your file association
for *.wav files), changes the colour of the text in the window and sets the
window's title to "### UP ###". You can leave it running in the background,
minimised, and if you glance at the taskbar icon it tells you the connection
status of the remote machine - that's if you don't notice Windows Media
Player popping up to play the TADA sound! If you need to stop it, use
Control-C in the command window.
If you have VNC running on remote machines which get their addresses from
DHCP, then you have two options. Run a listening client at your end, and
manage your own incoming port forwarding for port 5500. Then the client
simply has to right-click their VNC server icon and enter your IP or domain
address, and it'll connect. To speed this up, you can leave a command
script on their desktop (etc) which runs:
WinVNC4.exe -connect YOURADDRESS
I've wrapped mine up in all sorts of VBS which pops up an information panel
and checks for a running server - this now needs work to cope with Vista.
If you're trying to initiate a connection from a Vista box running VNC as a
service you need to add "-service" in the line above. Here the user is
connecting to you, of course.
The other option is to use Dynamic DNS. I use DynDNS.com. You register for
an account, and add a (free) Dynamic DNS hostname. It picks up your current
IP address, and links that with a third-level domain name you invent,
choosing from a range of second-level domains available. To maintain the
connection when the IP address changes, you should download, configure and
run the updating client available on the DynDNS site (under support). Works
a treat - usually propagates within 5 to 10 minutes after the new address is
detected by the update client. Then, if port forwarding is configured (or
unnecessary) at the remote end, and firewalls are appropriately set, you can
simply give the DynDNS domain name as the remote (server) address in the VNC
client. DynDNS have paid-for services which you might need, depending on
your requirements.
If you're reaching a number of machines through one (reasonably
sophisticated) router, you can set up "rules" to accept VNC connections on
other ports (add a double-colon and the port number after the address in the
client's address box) and have the router configured to route it to the
preferred machine, translating the port to 5900, the standard one for VNC.
If your router can't do that, then you can configure VNC to respond on a
different port, and route that port to the particular machine.
Hope that helps.
Philip Herlihy
:
:
:
:
Here's that example NT script:
=============================
set addr=212.58.254.252
echo off
title down
color 0C
:loop
ping -n 1 -w 10000 %addr% | grep -i "TTL"
if errorlevel 1 GOTO :loop
color 0A
title ### UP ###
C:\WINDOWS\Media\tada.wav
pause
_____
From: Dale Eshelman [mailto:eshelmand at gmail.com]
Sent: 05 July 2009 17:12
To: Philip Herlihy
Subject: Re: Command-line connection to listening client from Vista machine?
[now SCRIPTS]
Thanks
I have wondered how to do this in Windows. I have written DOS batch files,
UNIX scripts, written COBAL programs, written al lot of Excel macros in
Visual Basic for Applications (VBA). Have heard IT people talk about writing
SCRPTS but did not know what that meant.
I have gone to start-run and typed EDIT. Entered DOS commands and saved the
file with and extension BAT. Did not know there is a command line in Windows
and I guess that is cscript.exe. But not sure how to open a blank window to
enter script. Or do you just open a text editor and start typing, save with
an extension CMD, type the name of the script you just saved and it runs?
Not sure.
Definitely need to find out more about it so I can work on it. Gee I can not
believe I have used windows all this time and not learned about this.
Any guidance would be appreciated or even samples. Very interested in the
VNC thing as we have a number of users with DHCP that we need to come up
with a fixed IP by registering to track (although not sure how this works)
and set up a script to have them run so we do not have to spend a long time
walking them through finding the IP and starting VNC.
Dale
On Jul 5, 2009, at 10:31 AM, Philip Herlihy wrote:
Sorry it's taken so long to respond - inundated with email lately!
More information about the VNC-List
mailing list