Sign in to follow this  
Followers 0
DJ VenGenCe

Automated Use of Remote VNC & a problem I encounter

4 posts in this topic

Okay guys, after fiddling around with a program posted on here in the past, I have updated it. But I am having an issue.

The issue is that I try to connect to a PC by its Computer Name (Not IP Address) More times then not, it does work.. But in other Cases, it doesn't connect and TightVNC Viewer bombs.

Can anyone Help me out?

Heres the Description & Code.

Inspired by this Post: Install VNC on a Remote Computer. I decided to recode and form to my use.

You have to be the Admin in the group.

I work in the IT Field where there are programs to "Assist" in problems with clients. I thought of my own, as I like to make things. This does require TightVNC.

TightVNC comes from http://www.tightvnc.com.

Compile Serve.au3

Compile ServiceCenter.au3 (Optional)

Run Service Center.au3 or Service Center.exe

Files Required.

PSEXEC.EXE - Available From SysInternals.com (Part of PSTools, as well as Seperate)

PSKILL.EXE - Available from SysInternals.com (Part of PSTools, as well as Seperate)

This is my version (Lines of Code Tweaked.

Serve.au3 - This is the Code for the Server to start VNC Listening.

#NoTrayIcon;Shut Off Tray Icon
$compname = @ComputerName;Set Variable $compname to Computer name (Server)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ORL\WinVNC3", "AuthRequired", "REG_DWORD", "0")
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ORL\WinVNC3", "DisableTrayIcon", "REG_DWORD", "1")

FileInstall("vncviewer.exe", @TempDir & "\vncviewer.exe")
FileInstall("psexec.exe", @TempDir & "\psexec.exe")
FileInstall("pskill.exe", @TempDir & "\pskill.exe")

If @error Then
MsgBox(4096, "Error", 'Could Not Connect to Host: ' & $RemoteComputer)
Exit(1)
EndIf

FileInstall("vnchooks.dll", @TempDir & "\vnchooks.dll")
FileInstall("winVNC.exe", @TempDir & "\winVNC.exe")
Run(@TempDir & "\WinVNC.exe")

While ProcessExists("winvnc.exe")
WEnd
Sleep(500)
RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\ORL")
RegDelete("HKEY_CURRENT_USER\SOFTWARE\ORL")
DirRemove("C:\PROGRA~1\WVNC",1)
FileDelete(@TempDir & "\vncviewer.exe")
FileDelete(@TempDir & "\psexec.exe")
FileDelete(@TempDir & "\pskill.exe")
FileDelete(@TempDir & "\vncsrv.exe")

And here is the controller from the Operator's PC (Aka, Viewer)

Service Center.au3

#NoTrayIcon
$compname = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120)

FileInstall("vncviewer.exe", @TempDir & "\vncviewer.exe")
FileInstall("vnchooks.dll", @TempDir & "\vnchooks.dll")
FileInstall("pskill.exe", @TempDir & "\pskill.exe")
FileInstall("psexec.exe", @TempDir & "\psexec.exe")
Run(@TempDir & "\psexec.exe \\" & $compname & " -i -c -f -s serve.exe -force " & $compname & '"' , "", @SW_HIDE)
ProcessWait("psexec.exe")
Sleep(5000)
RunWait(@TempDir & "\vncviewer.exe " & $compname)
Sleep(5000)
RunWait(@TempDir & '\pskill.exe \\' & $compname & ' winvnc.exe', "", @SW_HIDE)
Sleep(5000)
RunWait(@TempDir & '\pskill.exe \\' & $compname & ' serve.exe', "", @SW_HIDE)

Help :geek::o

Share this post


Link to post
Share on other sites



Okay guys, after fiddling around with a program posted on here in the past, I have updated it. But I am having an issue.

The issue is that I try to connect to a PC by its Computer Name (Not IP Address) More times then not, it does work.. But in other Cases, it doesn't connect and TightVNC Viewer bombs.

Can anyone Help me out?

Heres the Description & Code.

Inspired by this Post: Install VNC on a Remote Computer. I decided to recode and form to my use.

You have to be the Admin in the group.

I work in the IT Field where there are programs to "Assist" in problems with clients. I thought of my own, as I like to make things. This does require TightVNC.

TightVNC comes from http://www.tightvnc.com.

Compile Serve.au3

Compile ServiceCenter.au3 (Optional)

Run Service Center.au3 or Service Center.exe

Files Required.

PSEXEC.EXE - Available From SysInternals.com (Part of PSTools, as well as Seperate)

PSKILL.EXE - Available from SysInternals.com (Part of PSTools, as well as Seperate)

This is my version (Lines of Code Tweaked.

Serve.au3 - This is the Code for the Server to start VNC Listening.

CODE

#NoTrayIcon;Shut Off Tray Icon

$compname = @ComputerName;Set Variable $compname to Computer name (Server)

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ORL\WinVNC3", "AuthRequired", "REG_DWORD", "0")

RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\ORL\WinVNC3", "DisableTrayIcon", "REG_DWORD", "1")

FileInstall("vncviewer.exe", @TempDir & "\vncviewer.exe")

FileInstall("psexec.exe", @TempDir & "\psexec.exe")

FileInstall("pskill.exe", @TempDir & "\pskill.exe")

If @error Then

MsgBox(4096, "Error", 'Could Not Connect to Host: ' & $RemoteComputer)

Exit(1)

EndIf

FileInstall("vnchooks.dll", @TempDir & "\vnchooks.dll")

FileInstall("winVNC.exe", @TempDir & "\winVNC.exe")

Run(@TempDir & "\WinVNC.exe")

While ProcessExists("winvnc.exe")

WEnd

Sleep(500)

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE\ORL")

RegDelete("HKEY_CURRENT_USER\SOFTWARE\ORL")

DirRemove("C:\PROGRA~1\WVNC",1)

FileDelete(@TempDir & "\vncviewer.exe")

FileDelete(@TempDir & "\psexec.exe")

FileDelete(@TempDir & "\pskill.exe")

FileDelete(@TempDir & "\vncsrv.exe")

And here is the controller from the Operator's PC (Aka, Viewer)

Service Center.au3

CODE

#NoTrayIcon

$compname = INPUTBOX("Remote Control", "Remote Control Address", "", "", -1, 120)

FileInstall("vncviewer.exe", @TempDir & "\vncviewer.exe")

FileInstall("vnchooks.dll", @TempDir & "\vnchooks.dll")

FileInstall("pskill.exe", @TempDir & "\pskill.exe")

FileInstall("psexec.exe", @TempDir & "\psexec.exe")

Run(@TempDir & "\psexec.exe \\" & $compname & " -i -c -f -s serve.exe -force " & $compname & '"' , "", @SW_HIDE)

ProcessWait("psexec.exe")

Sleep(5000)

RunWait(@TempDir & "\vncviewer.exe " & $compname)

Sleep(5000)

RunWait(@TempDir & '\pskill.exe \\' & $compname & ' winvnc.exe', "", @SW_HIDE)

Sleep(5000)

RunWait(@TempDir & '\pskill.exe \\' & $compname & ' serve.exe', "", @SW_HIDE)

Help :geek::o
Since you are using NetBIOS name resolution, verify it is resolving. Run the following from command line:

nbtstat -a \\ComputerName

Until that works, you are not resolving the NetBIOS name correctly. 'Ping' doesn't help becuase it doesn't check NetBIOS name resolution. You can get good ping from a machine that is not up in NetBIOS namespace. The following function is one I used for this situation, to whittle down a long list of computers to only those with NetBIOS up:

--------------------------------------------------------------
; Function _NetBiosPing($ServerName)
; Required parameter is the NetBIOS (WINS) name of the remote computer.
; Checks if a remote computer is answering NetBIOS requests.
; On success: Returns 1
; On failure: Returns 0
;--------------------------------------------------------------
Func _NetBiosPing($ServerName)
    If Not IsString($ServerName) Then Return 0
    $NBTStatCommand = 'nbtstat -a ' & $ServerName & ' | find /i "MAC Address = "'
    $ErrLvl = RunWait(@ComSpec & " /c " & $NBTStatCommand, @TempDir, @SW_HIDE)
    If Not $ErrLvl Then
        Return 1 ; DOS %ErrorLevel% = 0 is good, function returns 1 for success
    Else
        Return 0
    EndIf
EndFunc  ;==>_NetBiosPing

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

nbstat ? I know thats part of XP & 2003 Server, but is there an alternative program because my XP cd's are unavailable because we use an image.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Ok, here's the latest. I have developed a GUI application, when you type in the Computer Name, it'll attempt to "Connect" to it to update Tabs and text using the Set command to update a variable.

Here's what I have come up with.. And interesting enough, it works extremely fast.

I forgot where I saw this code, but this is what I implemented.

$Computer = InputBox("Computer Name", "Please Enter Computer Name:")
PingIt($Computer)

Func PingIt($Computer)
;
If RunWait("ping.exe -n 1 " & $Computer, "", @SW_HIDE) == 0 Then
    If $Computer = "" Then
        MsgBox(0, "Error","Computer Name Field Cannot Be Blank!")
    Exit
    Else
      ; If Sucessful, put functions you would like to do here
         MsgBox(0, "Doing Stuff", "Computer is online. So, run a function here")
    EndIf
Else
MsgBox(0, $Computer, $Computer & " is NOT Online")
EndIf
EndFunc

This seems to work like NBStat. So if it is online, could it be the execution of Serve.au3 ? Is there a way to replace the Sleep with another similar command? Or a wait function?

Edited by DJ VenGenCe

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0