jezzzzy Posted February 24, 2006 Posted February 24, 2006 (edited) I have been reading up on DCOM. I'm working on a way for my coworker to be able to control my Winamp from his PC. I have a small list of obj methods for Winamp through a plugin suggested by someone here (Wouter - I think). I have been able to successfully use these objects to control my winamp locally, however, I would like to make a script so my coworker can control it while i'm not at my desk. I have tried creating a test dcom object between our computers like this: ; Open the MediaPlayer on a REMOTE computer $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1","mycomputername") If not @error then Msgbox(0,"Remote ObjCreate Test","ObjCreate() of a remote Object successfull !") Else Msgbox(0,"Remote ObjCreate Test","Failed to open remote Object. Error code: " & hex(@error,8)) Endif It doesn't work. Get error code "00000005". I have verified that "remote registry" and "file & print" services are enabled per the help file. I have also tried specifying a username and password. I might have a better shot if I knew what the hex error codes were. Is there an index of these errors? Maybe one of you can shed some light on my problem. Edit: Also, when I try to run the script on my computer with his in the "mycomputername" area - I get error code: 80040154 Edit2: Obviously in the test code I have used a Media Player object. I did this to rule out any winamp related issues. Edited February 24, 2006 by jezzzzy
SvenP Posted March 6, 2006 Posted March 6, 2006 jezzzzy, First of all: In the AutoIt help file, under 'Function Reference->Obj/COM Reference' you can find a chapter that describes 'COM Error handling'. Using that method you can partially 'debug' COM-Related problems. An example for your script: expandcollapse popup$RemoteComputer="REMOTE"; Change this to your remote computer name $RemoteUsername="REMOTE\Administrator"; Change this to your username on the remote computer $RemotePassword="123456"; Change this to your password on the remote computer ; First install our own Error Handler $oErrObj = ObjEvent("AutoIt.Error","MyErrFunc") ; Open MediaPlayer on a remote computer $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1",$RemoteComputer,$RemoteUsername,$RemotePassword) if @error then Msgbox(0,"Remote ObjCreate Test","Failed to open remote Object. Error code: " & hex(@error,8)) exit endif Msgbox(0,"Remote Test","ObjCreate() of a remote object successfull !") $Enabled=$oRemoteMedia.IsSoundCardEnabled if not @error then Msgbox(0,"Remote Test","Invoking a method on a remote Object successfull!" & @CRLF & _ "Result of 'IsSoundCardEnabled?': " & $Enabled ) If $Enabled = -1 Then $oRemoteMedia.Open("c:\windows\media\Windows XP Startup.wav") if not @error then Msgbox(0,"Remote Test","Playing sound on a remote computer successful !") EndIf Else Msgbox(0,"Remote Test","Invoking a method on a remote Object Failed !") EndIf Exit ; ------------------------ ; My custom error function Func MyErrFunc() $hexnum=hex($oerrobj.number,8) Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _ "err.description is: " & $oErrobj.description & @CRLF & _ "err.windescription is: " & $oErrobj.windescription & @CRLF & _ "err.lastdllerror is: " & $oerrobj.lastdllerror & @CRLF & _ "err.scriptline is: " & $oerrobj.scriptline & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $oerrobj.source & @CRLF & _ "err.helpfile is: " & $oerrobj.helpfile & @CRLF & _ "err.helpcontext is: " & $oerrobj.helpcontext _ ) Seterror($oerrobj.number) EndFunc This code will show you the description of any COM error. To run remote code is getting more difficult lately because of the many MS Security patches, Antivirus software and Firewalls. Many programs are blocking remote code from being executed. The best way is to temporarily disable any antivirus/firewall software. I know, that is 'dangerous', but that would rule out these programs causing the problem. Secondly, check from the LOCAL computer if you can reach the remote computer: 1. by 'ping'ing the remote computer. 2. by checking its status by right-clicking the 'My Computer' icon, choose menu: 'Manage', then menu: Action->Connect to another computer, and enter the remote computer name. If it does not connect to the remote computer, then the problem is not in your script. On the REMOTE computer, you can check if the program you want to control is DCOM (distributed COM) enabled: 1. Click Start button->Settings->Control Panel, Choose: Administrative Tools -> Component Services 2. In the 'Component Services' program, choose: Component Services->Computers->My Computer->DCOM Config. 3. Check in the list of programs, whether your program is visible or not. If not, then you can't control the program remotely. 4. If the program is visible, right click the icon and choose 'properties'. Check if the launch permissions have been set correctly. Hope this helps, Regards, -Sven
jezzzzy Posted March 7, 2006 Author Posted March 7, 2006 Thank you for your help. With your new information I now get the error "Class not registered". I have looked in the dcomcnfg and verified that MediaPlayer is a registered com service.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now