Sign in to follow this  
Followers 0
leighlandwhitehead

using ObjCreate for remote machine

42 posts in this topic

Hi guys , 

i am using the ObjCreate function with the server name , username and password parameters so i can call windows updates on a remote machine.

i am having a problem with connecting to the remote PC , which has remote registry enabled and also the file and printer sharing is turned on.

i am currently testing with the example script (windows media player) that comes with the installer and i am having the same issue here (code below).

 

#include <MsgBoxConstants.au3>
 
; AutoItCOM 3.1.1
;
; Test file
;
; Test usage of creating objects on a remote computer
;
; Notes:
;
; - The remote Object must have DCOM (Distributed COM) functionality.
; - The remote computer must have 'Remote Registry Service' and 'File and Printersharing' turned on!
;
; To check for any DCOM-Enabled Objects, use DCOMCNFG.EXE (=Component Services MMC) on the remote computer.
 
Local $sRemoteComputer = "leighlandwtest-" ; Change this to your remote computer name
Local $sRemoteUsername = "leighlandwtest-leighland" ; Change this to your username on the remote computer
Local $sRemotePassword = "test" ; Change this to your password on the remote computer
 
; First install our own Error Handler
Global $g_nCOMError = 0, $g_oErrObj = ObjEvent("AutoIt.Error", "MyErrFunc")
 
; Open MediaPlayer on a remote computer
Local $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1", $sRemoteComputer, $sRemoteUsername, $sRemotePassword)
 
If @error Then
MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "Failed to open remote Object. Error code: " & Hex(@error, 8))
Exit
EndIf
 
MsgBox($MB_SYSTEMMODAL, "Remote Test", "ObjCreate() of a remote object successfull !")
 
Local $iEnabled = $oRemoteMedia.IsSoundCardEnabled
 
If Not @error Then
MsgBox($MB_SYSTEMMODAL, "Remote Test", "Invoking a method on a remote Object successfull!" & @CRLF & _
"Result of 'IsSoundCardEnabled?':  " & $iEnabled)
If $iEnabled = -1 Then
$oRemoteMedia.Open("c:windowsmediaWindows XP Startup.wav")
If Not @error Then MsgBox($MB_SYSTEMMODAL, "Remote Test", "Playing sound on a remote computer successful !")
EndIf
Else
MsgBox($MB_SYSTEMMODAL, "Remote Test", "Invoking a method on a remote Object Failed !")
EndIf
 
Exit
 
; ------------------------
; My custom error function
 
Func MyErrFunc()
Local $sHexnum = Hex($g_oErrObj.number, 8)
 
MsgBox($MB_SYSTEMMODAL, "", "We intercepted a COM Error!!" & @CRLF & @CRLF & _
"err.description is: " & $g_oErrObj.description & @CRLF & _
"err.windescription is: " & $g_oErrObj.windescription & @CRLF & _
"err.lastdllerror is: " & $g_oErrObj.lastdllerror & @CRLF & _
"err.scriptline is: " & $g_oErrObj.scriptline & @CRLF & _
"err.number is: " & $sHexnum & @CRLF & _
"err.source is: " & $g_oErrObj.source & @CRLF & _
"err.helpfile is: " & $g_oErrObj.helpfile & @CRLF & _
"err.helpcontext is: " & $g_oErrObj.helpcontext _
)
 
$g_nCOMError = $g_oErrObj.number
EndFunc   ;==>MyErrFunc
 

 

the script is meant to call the media player object and then play a sound on the machine however i am getting the following error :

We intercepted a COM Error!!

err.description is:

err.windescription is: No such interface supported

err.lastdllerror is: 0

err.scriptline is: 24

err.number is: 80004002

err.source is:

err.helpfile is:

err.helpcontext is:

Share this post


Link to post
Share on other sites



The script will have to actually be running on the remote machine to make interactions with the programs on that certain machine. :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Hi Mikahs , 

Thank you for your quick reply .

how would this be as the syntax's is as follows "ObjCreate ( "classname" [, "servername" [, "username" [, "password"]]] )"  

where you can set the server name, username and password?

i know that i can run the script locally however i would like to run the object by calling it from another machine.

The example script also states to supply a remote PC : 

#include <MsgBoxConstants.au3>

; Open the MediaPlayer on a REMOTE computer

Local $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1", "name-of-remote-computer")

If Not @error Then
    MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "ObjCreate() of a remote Mediaplayer Object successful !")
    $oRemoteMedia.Open(@WindowsDir & "mediatada.wav") ; Play sound if file is present
Else
    MsgBox($MB_SYSTEMMODAL, "Remote ObjCreate Test", "Failed to open remote Object. Error code: " & Hex(@error, 8))
EndIf

many thanks

Share this post


Link to post
Share on other sites

The object is created on the remote machine but everything else happens on the local machine.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

leighlandwhitehead,

We do not permit multiple accounts - I have deleted the 2 others you created in case you were wondering why they no longer worked. Please just stick to this one from now on. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

thank you :)

Share this post


Link to post
Share on other sites

Hi Water , 

thanks , would you recommend another way to manipulate a remote object ?

many thanks 

Share this post


Link to post
Share on other sites

Have a look at this example script: >link


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

My understanding is that everything object related is executed on the remote machine. Everything else on the local.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

My understanding is that everything object related is executed on the remote machine. Everything else on the local.

Same here , in the example you open the following $oRemoteMedia.Open("c:windowsmediaWindows XP Startup.wav") 

Share this post


Link to post
Share on other sites

Hi Guys, 

anyone got any more ideas ? 

thanks alot :)

Share this post


Link to post
Share on other sites

You got the COM error on line 24. Which statement is line 24 (I'm too lazy to copy your code and count the lines)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water this is the line :

Local $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer.1", $sRemoteComputer,$sRemoteUsername,$sRemotePassword)

many thanks 

Share this post


Link to post
Share on other sites

let me jump in to show you how ignorant i am when it comes to Obj stuff:  ;)  

googling 80004002 show it relates to Windows Update. why would you get error 80004002 for something related to Windows Media Player?

secondly, i was under the impression that the application you intend to connect to over DCOM should already be running. what do you get if Windows Media Player is already running on the remote machine and then you launch your script on the local machine?

and speaking of DCOM, is it enabled on the remote machine?

Share this post


Link to post
Share on other sites

When you try to run it on your local computer (means: removing , $sRemoteComputer, $sRemoteUsername, $sRemotePassword from ObjCreate), does it work?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

googling 80004002 show it relates to Windows Update. why would you get error 80004002 for something related to Windows Media Player?

secondly, i was under the impression that the application you intend to connect to over DCOM should already be running. what do you get if Windows Media Player is already running on the remote machine and then you launch your script on the local machine?

and speaking of DCOM, is it enabled on the remote machine?

80004002 is not related to Windows Update. The error simply means: No such interface supported

Usually you do an ObjGet to check if the application is already running. If True you process the returned object, if False you use ObjCreate to start up the application.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Orbs , 

i have tried this with media player open and i still receive the same error message, i have also made sure that all updates are on the remote PC.

Water - the script does run fine locally without the following params $sRemoteComputer, $sRemoteUsername, $sRemotePassword from ObjCreate

thanks 

Share this post


Link to post
Share on other sites

Your local machiine is Windows XP as well?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water , 

the machines are both windows 7 - i have amended the script i just copied in the original example 

thanks 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

What if you remove the ".1" from the classname?

Local $oRemoteMedia = ObjCreate("MediaPlayer.MediaPlayer", $sRemoteComputer, $sRemoteUsername, $sRemotePassword)
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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