Calling VBS CreateObject("someapp.someapp", "remote PC") for a COM interface on another machine? - vbscript

Disclaimer: Yes, I think this questions boils down to understanding some DCOM basics and what VBS CreateObject actually does/needs:
I have a 3rd party application that offers an automation interface via (D?)COM.
The interface is automatically registered when we install the application and it works fine when running simple VBS scripts locally:
This works fine on the same machine:
Dim oAppApi
WScript.Echo "Hello, try to connect ..."
Set oAppApi = CreateObject("theapp.theapp") ' Note that this will either start the application or connect to an already started instance
WScript.Echo oAppApi.APIVersion
oAppApi.DisconnectFromTool
This also works on the same machine:
Dim oAppApi
WScript.Echo "Hello, try to connect ..."
Set oAppApi = CreateObject("theapp.theapp", "localhost")
WScript.Echo oAppApi.APIVersion
oAppApi.DisconnectFromTool
This will fail when run on another PC in the same network:
Dim oAppApi
WScript.Echo "Hello, try to connect ..."
Set oAppApi = CreateObject("theapp.theapp", "machineNameWithAppInstalled") ' FAIL: ActiveX component can't create object
What would be neccessary to make this simple VBScript work from the remote machine?
Would anything need to be installed on the client machine? (COM proxy DLL or somesuch?)
Does the ServerName.TypeNameof CreateObject need to be known on the client side?
Do we have to do some DMCOMCnfg magic on the server?
Additional Details:
Since, from what I know of COM, this might depend on how the stuff is registered, here's my "trace" through the registry for "TheApp.TheApp" on the application PC:
[HKEY_CLASSES_ROOT\TheApp.TheApp]
#="com.company.toolAPI.theapp.theapp"
[HKEY_CLASSES_ROOT\TheApp.TheApp\CLSID]
#="{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}"
[HKEY_CLASSES_ROOT\TheApp.TheApp\CurVer]
#="TheApp.TheApp.7.2"
...
[HKEY_CLASSES_ROOT\TheApp.TheApp.7.2]
#="TheApp.TheApp"
[HKEY_CLASSES_ROOT\TheApp.TheApp.7.2\CLSID]
#="{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}"
...
[HKEY_CLASSES_ROOT\AppID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}]
#="THEAPP72 Server"
"DllSurrogate"=""
"RunAs"="Interactive User"
...
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}]
#="com.company.toolAPI.theapp.theapp"
"AppID"="{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}\Implemented Categories]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}\InprocServer32]
#="mscoree.dll"
"ThreadingModel"="Both"
"Class"="com.company.toolAPI.theapp.theapp"
"Assembly"="TheAppCOM, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c9b6e760b808c9f9"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Company/THEAPP7.2/interface/TheAppCOM.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}\InprocServer32\11.0.0.0]
"Class"="com.company.toolAPI.theapp.theapp"
"Assembly"="TheAppCOM, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c9b6e760b808c9f9"
"RuntimeVersion"="v2.0.50727"
"CodeBase"="file:///C:/Company/THEAPP7.2/interface/TheAppCOM.DLL"
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{0CBEA087-0CC7-4D15-A659-8B3AC68B82E1}\ProgId]
#="TheApp.TheApp"

I used RDS.DataSpace to access a 'middle-tier' dcom server.
Example: http://www.oblique.ch/ms/rds25.html#_Toc483670219

Related

MSXML load url failes only on Windows 2016 server

I am trying to modify an old VB6 application so that it can be used on Windows server 2016. At the moment it works well on Windows XP and Windows 7/10.
But for WIndows Server 2016 I do not get it going. I want to grab temperature data via https://xml.buienradar.nl. In the vb6 project I make a reference to msxml6 which I installed on the Windows 2016 server.
At xmldoc.Load ("https: \ xml.buienradar.nl") I get the error: The download of the specified resource has failed.
Firewall is disabled. Does anyone have any idea? I do not have the idea that it goes wrong with the msxml6.dll. Why does this work with all other operating systems?
Set xmldoc = New DOMDocument60
xmldoc.async = False
If xmldoc.Load("https:\\xml.buienradar.nl") = False Then
LogPrint "Load error: " & xmldoc.parseError.url & " - " &
xmldoc.parseError.reason
Else
-- grab data --
End If

Microsoft VBScript runtime error: Permission denied: 'CreateObject' when creating CDONTS.NEWMAIL

I'm making changes to a website written in classic asp.
My system is a Windows 7 64-bit.
I've been able to get the website to run, after setting it up as a classic asp running on IIS6.
When it attempts to execute the following code, I get the permission denied error:
from1 = "Kevin#company.com"
to1 = "staff1#company.com"
to2 = "staff2#company.net"
to3 = "staff3#client.com"
strTo = to1
If Len(strTo) > 0 Then
If Len(to2) > 0 Then
strTo = strTo & ";" & to2
End If
Else
strTo = to2
End If
If Len(strTo) > 0 Then
If Len(to3) > 0 Then
strTo = strTo & ";" & to3
End If
Else
strTo = to3
End If
body = reqApprName & "<br />" & reqApprPhone & "<br />" & reqApprEmail & "<br />Loan Number: "_
& loannum & "<br /><br />Please do not reply back to this email. The Vendor has provided the following "_
& "comment associated with this order.<br /><br />" & reqUndueInfluenceComment
Set ObjMail = CreateObject("CDONTS.Newmail")
ObjMail.From = from1
ObjMail.To = strTo
ObjMail.Subject = "Appraisal Order "&OrderNum&" by Vendor"
ObjMail.BodyFormat = 0
ObjMail.MailFormat = 0
ObjMail.Body = body
ObjMail.Send
Set ObjMail = Nothing
I'm puzzled, since I've never had a problem with CDONTS before. Then again, I've never tried using it on a Windows 7 64 bit machine, using 32 bit classic asp.
Does anyone have any ideas?
Thanks, all.
PS: I get the error on the create object for CDONTS.NewMail
When you try to send a message, you may receive the following error message:
Microsoft VBScript runtime error '800a0046' Permission denied
This problem occurs when an application is run out-of-process in IIS.
When this problem occurs, the user context of the process changes from the IUSR_MachineName account that does have access to the IIS metabase to the IWAM_MachineName account that does not have access to the IIS metabase.
Typically, this error has two causes.
Cause 1
The user under whom the .asp page is running or the script is running does not have permissions to the Pickup directory.
Typically, the Pickup directory is found in the following locations:
For computers that are running IIS only:
C:\Inetpub\Mailroot\Pickup
For computers that are running Microsoft Exchange 5.5:
Exchsrvr\Mailroot\Pickup
For computers that are running Exchange 2000:
\Program files\Exchsrvr\Mailroot\Vsi #\Pickup
Solution
The user under whom the .asp page is running or the script is running must have Modify (Change) permission to the Pickup directory so that the NewMail object can create the .eml file.
Cause 2
The page is running in its own memory space and is being denied access to the IIS metabase. To verify this, follow these steps:
Click Start, click Run, type Inetmgr, and then click OK.
Right-click either the root directory or the virtual directory that contains your page, and then click Properties.
If you right-clicked the root directory in step 2, click the Home Directory tab.
If you right-clicked the virtual directory in step 2, click the Virtual Directory tab.
On a computer that is running Windows NT, determine whether the Run in separate memory space check box is checked.
If the Run in separate memory space check box is checked, click to clear the check box. Alternatively, on the Properties menu of the SMTP service, click the Operators tab, and then add the IWAM_MachineName account.
On a computer that is running Windows 2000, determine whether the Application Protection setting is set to High (Isolated). If the Application Protection setting is set to High (Isolated), set the Application Protection setting to Medium (Pooled). Alternatively, on the Properties menu of the SMTP service, click the Security tab, and then add the IWAM_MachineName account to the Operators account.
Support.Microsoft.com

Active component cant create obj error

I am trying to script for file transferring ,its works fine when am clicking manually the script.But when am trying to run as Scheduling task i receiving an error "Active component cant create obj",i don't know what went wrong in my script?
For your reference i have my script below.
Dim Mysite
Set MySite = CreateObject("CuteFTPPro.TEConnection")
Set fso = CreateObject("Scripting.FileSystemObject")
MySite.Protocol = "FTP"
MySite.Host = "www.domainname.com"
MySite.Login = "xxxxx"
MySite.Password = "xxx"
MySite.UseProxy = "BOTH"
MySite.Connect
MySite.UploadAsync "C:\sampletest\abc.flv"
MySite.RemoteFolder = "/test/abc.flv"
MySite.Disconnect
MySite.Close
FYI my machine is windows 2008 64 bit system
In most cases issue raised by one of the following:
User does not have proper permission to run a scheduler
User does not have proper access to the folders/files listed
Application you are using running under different permission set for logged in user and system account which is used by Task Scheduler.
OS is not recognizing what application version it have to execute 32 or 64 bit when attempt to execute scheduled task.
Take a closer look on those situations, make adjustments and it will work.

How can I get the "Microsoft ODBC for Oracle" driver to work in Windows 7

I have an old VB6 app that I need to get working on a Windows 7 x64 workstation (at least for a little while).
It's failing on me when I try to connect to my test database (Oracle 10gR2). I get an "ORA-06413: Connection not open error."
Now, I recognise that the "Microsoft ODBC for Oracle" driver is deprecated because it doesn't play nice with newer versions of Oracle. It seems to work fine with the same database on an XP box I have access to.
I also see that the driver seems to still exist on Windows 7 x64 (at least when I look at the 32 bit version of the ODBC data Source Administrator tool: c:\Windows\SysWOW64\odbcad32.exe in the Drivers tab.
On the XP box, it doesn't seem to matter what I see up for an ODBC connection, it seems to bypass any sort of predefined connection.
Attached is the relevant code. Is there any way to make this work in Win7x64?
Global g_sConnectionString As String
Global g_oConn As ADODB.Connection
Public Sub CreateOracleConn()
Err.Clear
On Error Goto ConnectionError
g_sConnectionString = "Driver={Microsoft ODBC for Oracle}; " _
& "SERVER=" & "MyHost" _
& ";UID=" & "MyUserID" _
& ";PWD=" & "MyPassword & ";"
Set g_oConn = New ADODB.Connection
g_oConn.Open g_sConnectionString '<-- fails here
Exit Sub
ConnectionError:
If Err.Number <> 0 Then
'Clean up from the error
End If
End Sub
The problem entirely relates to where Visual Basic 6 is installed. By default it is installed in C:\Program Files (x86)\Microsoft Visual Studio\VB98\VB6.EXE
If you change its location to something like:
C:\ProgramFilesX86\Microsoft Visual Studio\VB98\VB6.EXE
It runs properly.

WMI namespace root\cimv2 not available on Win2k?

I'm trying to run the following VBScript code on a Win2k SP4:
strComputer = "."
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
It works on XP and Win7 without problems, but on this 2k box I get the following error:
C:\test_wmi.vbs(3, 1) (null): 0x8004100E
The error description is: Namespace specified cannot be found.
When I query the namespaces on root, using this code:
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root")
Set colNameSpaces = objSwbemServices.InstancesOf("__NAMESPACE")
For Each objNameSpace In colNameSpaces
Wscript.Echo objNameSpace.Name
Next
I get this:
DEFAULT
SECURITY
WMI
directory
aspnet
As far as I have read, CIMV2 namespace should be there. Any ideas???
Thanks!
yorch.
I was on Windows Server 2003, Service Pack 2, and yorch's solution didn't work for me. Finally I found this page, and followed the instructions for Server 2003:
http://www.djordjepejic.com/kb68/index.php/article/winmgmt-could-not-initialize-the-core-parts-solved-even/
For Windows Server 2003
Use the following command to detect and repair a corrupted WMI Repository:
rundll32 wbemupgd, RepairWMISetup
Yes, it should be there. There is a tool called wmidiag.vbs that can help you diagnose WMI problems, but before using it try watching a couple of 'webcasts' that explain how to use it (here and here)
Finally, what worked for me was rebuilding the WMI Repository. This is what I did:
Stop the WMI service (net stop winmgmt)
Go to %windows%/system32/wbem (in my win2k, winnt, on XP would be windows)
Rename or remove the repository directory
Start the WMI service again (net start winmgmt)
Also, this method could have helped (to reinstall WMI into the Registry):
winmgmt /clearadap
winmgmt /kill
winmgmt /unregserver
winmgmt /regserver
winmgmt /resyncperf
Thanks Uros for your help, both webcasts and the tool were very helpful.

Resources