Simple VB script needed

Posted on 2013-09-06
Medium Priority
Last Modified: 2013-09-24
Hi all,

I would like someone to write a VB script for me if they would be so kind.

I need to run RealVNC in reverse mode.

What I need is a dialog box that can run from a shortcut from the Windows 7 desktop. the dialog box should accept the computer name or IP address and put the data typed in by the user into the address bit of this command : "C:\Program Files\RealVNC\VNC4\winvnc4.exe" -service -connect address

Additionally I would also like the above RealVNC command to run as administrator as no user has admin rights to their PC but this is required fro the command to run successfully.

Many thanks

Question by:Simples
  • 2
  • 2
  • 2
  • +2
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 39469983
Simples, did the code in the last post here help you out http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_7/Q_28212410.html or do you need something different.   If the bottom answer is what worked, we can get that answer changed.

Author Comment

ID: 39470661
No sorry it's a very clunky looking DOS box ( showing my age here). I'd like a decent looking dialog box ! Thanks
LVL 43

Assisted Solution

Rob earned 375 total points
ID: 39476109
should be as simple as this vbs file:

address = inputbox("Please enter your computer name / ip address")

Set WshShell = WScript.CreateObject("WScript.Shell")

WshShell.Run "C:\Program Files\RealVNC\VNC4\winvnc4.exe -service -connect " & address, 1, false

Open in new window

Put the above in a file and save as vnc.vbs

(EDIT re comma... Thanks Rob!)
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

LVL 65

Assisted Solution

RobSampson earned 750 total points
ID: 39476244
@tagit, just missing a comma before "false"
LVL 20

Assisted Solution

ltlbearand3 earned 375 total points
ID: 39478486
You also asked about running this as an administrator.  That gets a little more complicated.  You can do this very simply using the run as option, but that is not recommended as you would then have the administrator password shown in the file.  Anyone who knows how to edit a vb script file could see your password.

The other option is to use the task scheduler if the users are on Windows 7.  What you would do is create a scheduled task to run as the administrator.  That task would then call the vbscript file from tagit.  Then you need to create a shortcut to the scheduled task.  On the desktop right click and choose create shortcut.  Then put this in the path:
schtasks /run /tn “TheNameOfYourTask”

Open in new window


Author Comment

ID: 39479605
Thanks for this info. I am getting an error when running the script however. (I copied and pasted it so no typo's). the correct version of VNC is installed at the correct location and the exe file is there. I can run

I enter the ip address and then I have an error window appearing from Windows Script Host telling me that at  at line5, char 1 there is a Type mismatch:'[string:C:\Program Files\Rea"]. and the code is 800A000D.The source is Microsoft VBScript runtime error. I am logged into the PC as the local admin.

The command C:\Program Files\RealVNC\VNC4\winvnc4.exe -service -connect " & address, 1, false  does run perfectly when in a command prompt window but not from the script
LVL 43

Expert Comment

ID: 39479636
it could be escape character related ie the backslash so you could try

WshShell.Run "C:\\Program Files\\RealVNC\\VNC4\\winvnc4.exe -service -connect " & address, 1, false

or even the space in Program Files

WshShell.Run "C:\""Program Files""\RealVNC\VNC4\winvnc4.exe -service -connect " & address, 1, false

or a combination of the both :)

WshShell.Run "C:\\""Program Files""\\RealVNC\\VNC4\\winvnc4.exe -service -connect " & address, 1, false
LVL 65

Accepted Solution

RobSampson earned 750 total points
ID: 39481518
It will be the spaces. this should work, if one of tagit's doesnt.

WshShell.Run """C:\Program Files\RealVNC\VNC4\winvnc4.exe"" -service -connect " & address, 1, false


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question