Jump to content

Small Remote Control Tool


kpu
 Share

Recommended Posts

Okay, I think I posted this a while back and I'm looking for some suggestions to make this better. This is used to with ConsoleOne and should reside in "...\ConsoleOne\1.2\bin\zen\RcLaunch". With it, you don't have to run ConsoleOne to remote a PC. You just need the files.

Here's how it works.

1. Type in the name of the PC and press the "Find It" button. "nlist.exe" will then search for.

2. It will change contexts where your workstations and reside and search for the workstation.

3. If it finds anything, it will display a message box and then put the information in the input box of the app.

4. Once you press the "Remote It", it will resolve the name to IP and run the command.

Here's the code.

; ----------------------------------------------------------------------------
#include <GuiConstants.au3>
#Include <process.au3>
;-----------------------------------------------------------------------------------------------
AutoItSetOption("TrayIconHide", 1)
;-----------------------------------------------------------------------------------------------
_errorCtl()
;-----------------------------------------------------------------------------------------------
$script_title = "Mini Remoter V2"
GuiCreate($script_title, 266, 120, 430,346)
GUISetFont(12, 400, "", "Arial")
$txt_pcname = GuiCtrlCreateInput("Inventory Number Here", 8, 32, 249, 29)
GUICtrlSetLimit(-1, 14);Number of characters in name.
$btn_findit = GuiCtrlCreateButton("Find It", 56, 64, 97, 25)
$btn_remote = GuiCtrlCreateButton("Remote It", 160, 64, 97, 25)
$Label1 = GuiCtrlCreateLabel("Type in the inventory number Below", 8, 5, 224, 20)
;-----------------------------------------------------------------------------------------------
GUICtrlCreateMenu("Information",300,200)
$filemenu = GUICtrlCreateMenu ("&File")
$help = GUICtrlCreateMenuitem ("&Help",$filemenu)
$about = GUICtrlCreateMenuitem ("&About",$filemenu)
$close = GUICtrlCreateMenuitem ("&Exit",$filemenu)
;-----------------------------------------------------------------------------------------------
$tree = IniRead("settings.ini", "RCONSOLE", "TREE", "")
$pword = IniRead("settings.ini", "RCONSOLE", "RemoteAgentPassword", "")
$ws_container = IniRead("settings.ini", "RCONSOLE", "WorkStationContainer", "")
$ws_nlist = IniRead("settings.ini", "RCONSOLE", "NLISTQUERY", "")
;-----------------------------------------------------------------------------------------------
;FileInstall("sscreen.gif", @WindowsDir & "\Temp\sscreen.gif",1);Name of splash screen file.
;$splash = @WindowsDir & "\Temp\sscreen.gif";;Name of splash screen file.
;-----------------------------------------------------------------------------------------------
GuiSetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $btn_findit
            GUICtrlSetState($btn_findit, $GUI_DISABLE)
            $ws = GUICtrlRead($txt_pcname)
            $ws_ip = TCPNameToIP($ws)
        ;SplashImageOn("Searching, please wait...", $splash, 272, 156, 300, 100, 16);Name of splash screen file.
            $temp = @WindowsDir & "\Temp\temp.txt"
            RunWait(@ComSpec & " /c " & "z:\cx .", "", @SW_HIDE)
            RunWait(@ComSpec & " /c " & "z:\cx ou=" & $ws_nlist, "", @SW_HIDE)
            RunWait(@ComSpec & " /c " & "z:\nlist workstation= *" & $ws & "* > " & $temp, "", @SW_HIDE)
            $file = FileOpen($temp, 0)
            If $file = -1 Then
                MsgBox(0, "Error", "Unable to open " & $temp)
                Exit
            EndIf
            $line = FileReadLine($file, 1)
        ;SplashOff()
            If $line = "No workstation objects were found." Then
                MsgBox(16, "Warning!", $line)
            Else
                $line = FileReadLine($file, 4)
                MsgBox(32, "PC Information", "PC found with the following information:" & @CRLF & $line)
                GUICtrlSetState($btn_findit, $GUI_ENABLE)
                ClipPut($line)
                FileClose($file)
                WinSetState($script_title, "", @SW_SHOW)
                ControlSend($script_title, "", "Edit1", ClipGet())
            EndIf
        Case $msg = $btn_remote
            GUICtrlSetState($btn_remote, $GUI_DISABLE)
            $ws = GUICtrlRead($txt_pcname)
            $ws_ip = TCPNameToIP($ws)
            TCPStartup()
            $ws = GUICtrlRead($txt_pcname)
            $ws_ip = TCPNameToIP($ws)
            $run_line = 'RCConsole -n"' & $tree & '" -c"Remote Control" -t"0" -s"2" -a"' & $ws_ip & '" -p"' & $pword & '" -w"' & $ws & $ws_container & '"'
            RunWait(@ComSpec & " /c " & $run_line, "", @SW_HIDE)
            GUICtrlSetState($btn_remote, $GUI_ENABLE)
    ;---------------------------------------------------------------------------------------
    Case $msg = $help
            ;_RunDOS("start http://website/help.htm");put web address to help file
            MsgBox(64,"Help","No help Information at this time.")
        Case $msg = $about
            MsgBox(64,"About","Program is used as a replacement for ZenBrowser." & @CRLF & "It uses ConsoleOne Components to remote control the workstation.")
        Case $msg = $close
            ExitLoop
    ;---------------------------------------------------------------------------------------
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
        ;;;
    EndSelect
WEnd
Exit
;-----------------------------------------------------------------------------------------------
Func _errorCtl();This is used for error control. 
If UBound(ProcessList(@ScriptName)) > 2 Then 
    $run2 = Msgbox(164,"Warning","Application is already running!")
Exit
Else
EndIf
$error_1 = FileExists("settings.ini")
If $error_1 = "0" Then
    MsgBox(16,"Warning!",'Please make sure "setting.ini" is in the same directory as ' & @ScriptName)
    Exit
EndIf
EndFunc

Here's the settings.ini file it needs.

[RCONSOLE];What tree it should use.

TREE=

;The remote Agenet Password

RemoteAgentPassword=

;The Workstation COntainer. It must be writen like this .[container].[container] **Example: .workstations.chc

WorkStationContainer=

;Full path from root. This is used for Nlist to query for workstation

NLISTQUERY=

Does anyone have any suggestions?? B)
Link to comment
Share on other sites

Last year I build a app like yours. Our helpdesk uses it every day.

My app is based on a simple inputbox, the name of the workstation can be entered there, then I use NLIST to get all details of the Workstation object (use full workstation context, cx commands are not necessary). Then I give a ping with the IP-address of the WS-object. Then a dialog shows the inventory details like Machine type, OS, Client version etc.

When the Ping was successfully, a remote control can be started (the way you do.) When the Ping was unsuccessful, a Wake on Lan can be done. I do use a little external program for that function.

My new beta does a port check after a successful ping. I do a check on the remote control port to see if a workstation is available to control after a reboot.

Good Luck! Novell B)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...