Simple VB script needed

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

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Simples, did the code in the last post here help you out or do you need something different.   If the bottom answer is what worked, we can get that answer changed.
SimplesAuthor Commented:
No sorry it's a very clunky looking DOS box ( showing my age here). I'd like a decent looking dialog box ! Thanks
RobOwner (Aidellio)Commented:
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!)
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

@tagit, just missing a comma before "false"
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

SimplesAuthor Commented:
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
RobOwner (Aidellio)Commented:
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
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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.