Activex component can't create object:'xyz' - vbscript

I have written the following piece of VB script which opens
an existing aplication xyz from the path I specfied.
The application (a custom windows application) opens succesfully.
(I would like to use the automation interface of this application
in my vb script.) for that I call CreateObject.
But, then I also get the error Activex component can't create object: 'xyz' for the line Set xyzObj = CreateObject("xyz").
The error is from this line, since if I remove this line there is no error.
Dim objShell
Set objShell = CreateObject( "WScript.Shell" )
objShell.Exec("C:\abc\def\xyz.exe")
Set xyzObj = CreateObject("xyz")
Set objShell = Nothing

You can't use CreateObject like that with a external program, started in your script or otherwise. CreateObject loads a COM-object that is registered on your pc. Google on vbscript and COM objects and you'll find plenty of info like at http://technet.microsoft.com/en-us/library/ee156598.aspx. If you want to interact with a started program you could use the sendkeys method or better use the autoit com object , see http://www.autoitscript.com/autoit3/docs/intro/ComRef.htm

Related

Import registry where registry is disabled by GPO

I am currently trying to import a registry file in a logon script that uses VBScript. However a group of users have registry/cmd disabled through the group policy (unchangeable due to policy). The code works for users that have registry/cmd access just not for the rest.
Dim wsh
Set wsh = WScript.CreateObject("WScript.Shell")
wsh.Run "%SystemRoot%\regedit.exe /S \\LogonServer\LogonFiles\reg\languages.reg", , True

How do I instantiate Lotus 123 Application

I am opening Lotus files to get data from them. How do I instantiate the Lotus application without using GetObject? I have a reference to "Lotus 123". I am using Lotus SmartSuite 97.
This code works OK but it seeems I should be able to instantiate the Lotus application directly instead of using GetObject.
'get LotusWin
Dim LotusApp As Lotus123.Application
Dim wb As Lotus123.Document
Set wb = GetObject("C:\Temp\TestCopy.WK3", "Lotus123.Workbook")
Set LotusApp = wb.Application
LotusApp.Visible = True
wb.Activate
I tried to use Dim LotusApp As New Lotus123.Application but it give a compile error: Invalid use of New keyword.
I tried to use Dim LotusApp As New Lotus123 but it give a compile error: Expected user-defined type, not project.
I am using Excel VBA as my platform to run the code, but this is not an Excel question so please don't suggest adding an Excel tag.
Also I'm not interested in converting files to Excel.
How do I instantiate the Lotus application without using GetObject?
GetObject() returns a reference to an object provided by a COM component, in your case Lotus123.
As you are communicating with Lotus123 via COM, and Lotus123 apparently does not support the "As New" syntax (which wasn't properly supported even in VB6, and Lotus123 is way older) I see no alternative to using GetObject().

Get msi installer filename from custom action script

we have msi installer build with MSI Factory with a couple of custom action scripts (lua & vbs). one of the scripts try to get a custom property from package and write it to file after successfully installation. this custom property is added to downloaded package via MSI.ChangeMSIProperty in asp.NET handler when download was requested with parameters. problem is, that property change brokes the signature of msi file, so we try to add some data to the msi filename. now I need to change that vbscript to handle this. but I can't get the installers filename.
Dim data, tokens
Dim fso, f
Dim setupExeFilename, setupExeFilenameParts
data = Session.Property("CustomActionData")
tokens = Split(data,"|")
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateTextFile(tokens(0) & "\\data.txt", True)
if tokens(1) = "_DEFAULT_" then
setupExeFilename = Session.Property("SETUPEXENAME")
setupExeFilenameParts = Split(data,".")
f.Write setupExeFilenameParts(UBound(setupExeFilenameParts) - 1)
else
f.Write tokens(1)
end if
f.Close
I found Session.Property("SETUPEXENAME") somewhere but doesn't work for me. I search for some property in Session, Session.Property, Session.ProductProperty, Installer but no luck yet. Installer object is present as I try, but no property returns what I need.
If not Installer is nothing then
msgbox "Installer ok"
msgbox Installer.version
end if
is it possible to get the installer filename?
The OriginalDatabase property has what you are looking for. However your reference to CustomActionData tells me your custom action is running in the deferred context. You won't have access to this property. Whatever custom action that is running in immediate and serializing your CustomActionData property will have to obtain this property and put it into CustomActionData.
You should be warned that VB/JScript custom actions are famous for their fragility. You mention SETUPEXENAME so I assume you are using InstallShield as this is an InstallShield property. I'd suggest using InstallScript, C/C++ or C# instead. If you choose InstallScript, I have a sample CustomActionData serialization/deserialization pattern over on InstallSite.org. If C#, it's built into the Microsoft.Deployment.WindowsInstaller library's Session class.

how to open multiple url's in multiple browsers using VBscript (like multithreading)

Is multithreading possible using vbscript. i have to form fill a web page in multiple browsers/tabs, so that, i hope can reduce the completion time. Please suggest.
Vbscript does not natively have any methods for launching separate threads although if you try then it's more of "emulation" of multi-threading than anything else
You can check this documentation
To open a url in vbscript you can try something like this:-
set wShell = CreateObject("Shell.Application")
wShell.Open "C:\temp\abc.txt"

VBS file communication/execution

I have a ftp server that i have written VBS scripts for, now I need an easy way to run them from my website. So i want to open my website, enter the username, password, users name and click submit, it must then run the VBS and insert the data and the VBS will then create the user on the FTP.
What is the best way to do this? should I load the VBS stuff into a application with webservice listener and build and execute it and then my site must communicate via the webservice, or should i rather build a local asp page and host it which when posted too runs the vbs file and gives it the data. Please explain how you would go about coding it if you leave a response :D
You could use
<%
Dim oWShell
Set oWShell = Server.CreateObject("WScript.Shell")
strCommand = "cmd.exe /c cscript C:\AbsolutePath\To\Your\VBSFile.vbs"
oWShell.Run strCommand, 1, true
Set oWShell = Nothing
%>
WShell and WShell.Run requires elevated access permissions on the web server. Make sure that the authenticated user (or IUsr) has those permissions.

Resources