Jump to content

RDP issue


rs232
 Share

Recommended Posts

Hi all, I used autoit cometime ago to write a script to map a network scanner from a windows xp machine whenever the scanner IP address gets online.

Yes, something very trivial but the software scanner doesn't do this automatically! (thanks Epson)

This windws XP machine it's a VM and it's accessed via the network only.

To cut a long story short, I did write and use this script for long time until one day it stopped. I looked and re-looked at the code many times but then I noticed that I was doing something different (as a user). Instead of using XP remotely using teamviewer which interacts with windows as it

is, I started to use RDP from my laptop. That was enough to make my script not working.

When I say not working via RDP I mean:

- the scanner does always get mapped to win XP no matter what

- the scanner does receive the scanning profiles from XP no matter what

- however if I try to scan any document the scanner doesn't send anything back to windowsXP (no pdf stored).

When I re-log using teamviewer (forcing thus the rdp connection to disconnect) the scanner can finally send documents to XP.

You can find the script here below:

#ce $IniFile1 = $CmdLine[1]
#ce $IniFile2 = $CmdLine[2]
$p=1
$plast=0
$loop=1
  stop()
  start()
$var = Ping("10.10.10.20",250)
If $var Then; also possible:  If @error = 0 Then ...
#ce Msgbox(0,"Status","Online, roundtrip was:" & $var)
$p=1
$plast=1
Else
$p=0
$plast=0
EndIf
#ce #######################################################################
while $loop > 0
Sleep(10000)
$var = Ping("10.10.10.20",250)
#ce #######################################################################
If $var Then; also possible:  If @error = 0 Then ...
#ce Msgbox(0,"Status","Before:" & $p & $plast)
$p=1
if $plast = 0 Then
  stop()
  start()
EndIf
Else
$p=0
EndIf
$plast=$p
#ce Msgbox(0,"Status","After:" & $p & $plast)
WEnd

Func stop()
#ce $list = ProcessList("MFPAgent.exe")
#ce for $i = 1 to $list[0][0]
#ce  ProcessClose( $list[$i][1] )
#ce  next
ProcessClose( "MFPAgent.exe" )
WHILE ProcessExists("MFPAgent.exe")
Sleep(1000)
WEND
_RefreshSystemTray()
EndFunc
Func start()
Run( "C:\Program Files\MFP Server Utilities\MFPAgent.exe" , "C:\Program Files\MFP Server Utilities", "SW_MINIMIZED" )
EndFunc
; ===================================================================
; _RefreshSystemTray($nDealy = 1000) ;
; Removes any dead icons from the notification area.
; Parameters:
;   $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's
;      "Hide Inactive Icons" feature (In milliseconds).
; Returns:
;   Sets @error on failure:
;      1 - Tray couldn't be found.
;      2 - DllCall error.
; ===================================================================
Func _RefreshSystemTray($nDelay = 1000)
; Save Opt settings 
Local $oldMatchMode = Opt("WinTitleMatchMode", 4)   
Local $oldChildMode = Opt("WinSearchChildren", 1)   
Local $error = 0    
Do; Pseudo loop     
  Local $hWnd = WinGetHandle("classname=TrayNotifyWnd")     
  If @error Then            
   $error = 1           
   ExitLoop     
  EndIf

  Local $hControl = ControlGetHandle($hWnd, "", "Button1")
; We're on XP and the Hide Inactive Icons button is there, so expand it     
  If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then         
   ControlClick($hWnd, "", $hControl)           
   Sleep($nDelay)       
  EndIf             

  Local $posStart = MouseGetPos()       
  Local $posWin = WinGetPos($hWnd)                

  Local $y = $posWin[1]     
  While $y < $posWin[3] + $posWin[1]            
   Local $x = $posWin[0]            
   While $x < $posWin[2] + $posWin[0]               
    DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y)              
    If @error Then                  
     $error = 2                 
     ExitLoop 3; Jump out of While/While/Do             
    EndIf               
    $x = $x + 8         
   WEnd         
   $y = $y + 8      
  WEnd      
  DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1])    
; We're on XP so we need to hide the inactive icons again.      
  If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then         
   ControlClick($hWnd, "", $hControl)       
  EndIf 
Until 1 
; Restore Opt settings  
Opt("WinTitleMatchMode", $oldMatchMode) 
Opt("WinSearchChildren", $oldChildMode) 
SetError($error)
EndFunc; _RefreshSystemTray()

NOTE: if I'm connected to windows XP via RDP and I map the scanner manually this still doesn't work! So I really think this is a limit in the way the scanner software was developed, but before give up I just wanted to ask you opinion, if anybody please direct me in the right direction?

Many thanks!

rs232

Link to comment
Share on other sites

Are you RDP'd into the console session?

I don't know if this would make a difference in your specific issue, but I have had non console session gotchas in the past.

The switch for mstsc will be "admin" or "console" depending on the version of mstsc.

Could be completely unrelated, but food for thought, and something to try :)

Link to comment
Share on other sites

Thanks for the input!

Good point! Any way to verify this?

In my understanding windows XP supports only console RDP unless you patch the termserv.dll with a third party one. I didn't patch anything so I guess has to be console but I can't be 100% sure...

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...