Lansweeper logo
Home Download Features Demo Buy now Help Support forum
 
    Most requested support articles:
  Lansweeper troubleshooting guide.
  The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
  WMI Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
  How to configure the windows firewall using group policies.
  Support:  
 support@lansweeper.com  
Skype: Lansweeper  
  Mo-Fri 9h-17h CET  
Welcome Guest Search | Active Topics | Log In | Register

Tag as favorite
LSRemote with confirmation
mrmcfu
#1 Posted : Friday, October 02, 2009 10:09:29 PM

Rank: Premium user

Groups: Premium Users
Posts: 19
Location: Montreal
Hello -

Is there some kind of way to generate a popup or confirmation on the user's desktop when the lsremote tool is invoked? Our Service Desk is extremely nervous about using this feature without user confirmation.

Best,
MrMcFu
mrmcfu
#2 Posted : Saturday, October 03, 2009 4:21:39 AM

Rank: Premium user

Groups: Premium Users
Posts: 19
Location: Montreal
Alright well I just took care of this myself.

First I created two .vbs scripts and put them in my tools folder.

We'll call the first script "remote.vbs" and it is written below:



On error resume next

compstr = wscript.arguments(0)
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFilePath = "\\LANSWEEPERSERVER\tools$\Remote_Client.vbs"
strDestination = "\\" & compstr & "\c$\"
Set objFileCopy = objFSO.GetFile(strFilePath)

objFileCopy.Copy(strDestination)

set WshShell = WScript.CreateObject("WScript.Shell")
return = WshShell.Run("%comspec% /c \\LANSWEEPERSERVER\tools$\psexec.exe \\" & compstr & " -i wscript.exe c:\remote_Client.vbs",0,True)

Set objFileDel = objFSO.GetFile("\\" & compstr & "\c$\remote_client.vbs")
objFileDel.Delete

If return = 1 Then
WshShell.Run("\\LANSWEEPERSERVER\tools$\lsremote.exe " & compstr & ""),0,True
End If



This script is run like a normal custom action with the computer name following the script in the configuration.

When it's run, a second script (remote_client.vbs) is copied to the client's c:\ drive and run using psexec. The second script is shown below:



On error resume next

intAnswer = Msgbox("Would you like Service Desk to take control of your machine?",vbYesNo, "Remote Control")

If intAnswer = vbYes Then
wscript.quit(1 Mod 255)
Else
wscript.quit(3 Mod 255)
End If



This script asks the user to accept the connection or not, then exits with an exit code, which the first script records and acts upon in determing whether to launch lsremote.exe or not.

I hope someone finds this useful
BullGates
#3 Posted : Tuesday, October 06, 2009 7:10:11 PM

Rank: Premium user

Groups: Member, Premium Users
Posts: 203
Location: PT
Thanks for sharing, I was using my own script http://www.lansweeper.co...ording-to-my-needs.aspx

now I'm considering to use lsremote the same way as you. Still when I have the time I will try to upgrade my script so it's possible to make secure connections - for now I don't have the time.

Regards,
Paulo
mrmcfu
#4 Posted : Wednesday, October 07, 2009 3:01:14 AM

Rank: Premium user

Groups: Premium Users
Posts: 19
Location: Montreal
Nice. Looks like you can program. I pretend to program by writing scripts, so anything you can translate from my .vbs scribbles into decent code would be awesome.

I just finished another similiar script that locks the workstation remotely and I'll post it tomorrow.
BullGates
#5 Posted : Wednesday, October 07, 2009 3:18:29 PM

Rank: Premium user

Groups: Member, Premium Users
Posts: 203
Location: PT
Using nircmd from www.nirsoft.net you can do that, although it will lock the workstation after until 1 minute this way:
Code:
nircmd.exe remote copy \\{computername} lockws


but if you use psexec you can lock it right away...
mrmcfu
#6 Posted : Wednesday, October 07, 2009 3:22:47 PM

Rank: Premium user

Groups: Premium Users
Posts: 19
Location: Montreal
Yeah I ended up using psexec - I try to keep the same method so that the scripts are easier to maintain:

First script -



On error resume next

compstr = wscript.arguments(0)
verify = MsgBox("Please confirm you wish to lock the desktop of " & compstr,vbYesNo, "Lock Computer")

If verify = vbNo Then
wscript.quit
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
strFilePath = "\\LANSWEEPERSERVERSHARE\remote_lock.vbs"
strDestination = "\\" & compstr & "\c$\"
Set objFileCopy = objFSO.GetFile(strFilePath)

objFileCopy.Copy(strDestination)

set WshShell = WScript.CreateObject("WScript.Shell")
return = WshShell.Run("%comspec% /c \\LANSWEEPERSERVERSHARE\psexec.exe \\" & compstr & " -i wscript.exe c:\remote_lock.vbs",0,True)

Set objFileDel = objFSO.GetFile("\\" & compstr & "\c$\remote_lock.vbs")
objFileDel.Delete



Second Script:



On Error Resume Next

Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%windir%\System32\rundll32.exe user32.dll,LockWorkStation"

------------------------------------------
BullGates
#7 Posted : Thursday, October 08, 2009 6:25:21 PM

Rank: Premium user

Groups: Member, Premium Users
Posts: 203
Location: PT
I did what you've suggested, but it's much slower than my previous solution. I've also implemented the funcionality: if user is not logged on (login window on the pc) it does not ask to connect, if user does not answer after 30s, then it automatically declines connection.

I can post the autoit code if it fits your needs.
mrmcfu
#8 Posted : Thursday, October 08, 2009 6:35:53 PM

Rank: Premium user

Groups: Premium Users
Posts: 19
Location: Montreal
Sure that would be great!
BullGates
#9 Posted : Friday, October 09, 2009 11:08:43 AM

Rank: Premium user

Groups: Member, Premium Users
Posts: 203
Location: PT
Ok, there are 2 helper components:

lslocal.au3:
Code:
Opt("TrayIconHide", 1)
Global $MainSocket, $szIPADDRESS, $nPORT
Dim $szServerPC = @ComputerName
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
Dim $ConnectedSocket = -1
Dim $nPORT = 5555

$MainSocket = TCPListen($szIPADDRESS, $nPORT)
If $MainSocket = -1 Then
    Exit
EndIf

While 1
    $ConnectedSocket = TCPAccept($MainSocket)
    If $ConnectedSocket >= 0 Then
        While 1
            $recv = TCPRecv($ConnectedSocket, 2048)
            If @error Then ExitLoop
            Select
                Case $recv = "yes"
                    MakeConnection()
                Case $recv = "no" Or $recv = "timeout"
                    Exit
            EndSelect
        WEnd
    EndIf
WEnd

Dim $msg, $recv

If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket)

Func OnAutoItStart()
    TCPStartup()
EndFunc   ;==>OnAutoItStart

Func OnAutoitExit()
    TCPCloseSocket($ConnectedSocket)
    TCPShutdown()
EndFunc   ;==>OnAutoitExit

Func MakeConnection()
    Run(@ScriptDir & "\lsremote.exe " & $cmdline[1], @ScriptDir)
    Exit
EndFunc   ;==>MakeConnection


lsremoteh.au3:
Code:
Opt("TrayIconHide", 1)
TCPStartup()
Dim $szServerPC = $cmdline[1]
Dim $szIPADDRESS = TCPNameToIP($szServerPC)
ConsoleWrite($szIPADDRESS)
Dim $nPORT = 5555
Dim $ConnectedSocket = -1

$ConnectedSocket = TCPConnect($szIPADDRESS, $nPORT)

If ProcessExists("explorer.exe") Then
    If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
    $iMsgBoxAnswer = MsgBox(262180, "Remote Control", "Would you like Service Desk to take control of your machine?", 30) ;Timeout of 30s defined
    Select
        Case $iMsgBoxAnswer = 6 ;Yes
            TCPSend($ConnectedSocket, "yes")
            Exit
        Case $iMsgBoxAnswer = 7 ;No
            TCPSend($ConnectedSocket, "no")
            Exit
        Case $iMsgBoxAnswer = -1 ;Timeout
            TCPSend($ConnectedSocket, "timeout")
            Exit
    EndSelect
Else
    TCPSend($ConnectedSocket, "yes")
    Exit
EndIf

Func OnAutoItStart()
    TCPStartup()
EndFunc   ;==>OnAutoItStart

Func OnAutoItExit()
    TCPCloseSocket($ConnectedSocket)
    TCPShutdown()
EndFunc   ;==>OnAutoItExit


The action should be:
Code:
cmd /c \\server\share$\Lansweeper\psexec.exe \\{computer} -i -s -c -f \\server\share$\Lansweeper\lsremoteh.exe %computername%| \\server\share$\Lansweeper\lslocal.exe {computer}

lsremote.exe should be on the same share as lsremoteh.exe and lslocal.exe
abolus
#10 Posted : Tuesday, December 08, 2009 7:28:08 AM

Rank: Premium user

Groups: Premium Users
Posts: 53
Location: qatar
is it possible to have a return confirmation message from expert if the user accecpt or denied the notification for remote access?
BullGates
#11 Posted : Wednesday, December 16, 2009 12:25:06 PM

Rank: Premium user

Groups: Member, Premium Users
Posts: 203
Location: PT
Yes, it's very simple to do that, just change this on lslocal.au3 (not tested):
Case $recv = "yes"
Msgbox(0,"Answear", "The user accepted connection")
MakeConnection()
Case $recv = "no" Or $recv = "timeout"
Msgbox(0,"Answear", "The user did not accepted connection")
Exit

But I find this quite annoying!
Lansweeper
#12 Posted : Tuesday, March 09, 2010 2:37:45 PM

Rank: Administration

Groups: Administration, Premium Users
Posts: 10,007
Users browsing this topic
Guest
Tag as favorite
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Contact: E-mail Lansweeper - Skype : Lansweeper
Copyright 2004 - 2011 © Hemoco bvba