Jump to content

using ObjCreate for remote machine


Recommended Posts

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:

Link to comment
Share on other sites

  • Replies 41
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

 

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Your local machiine is Windows XP as well?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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