VBScript Custom Action 38 GetParentFolderName Will Not Resolve
I dare say this can be done more simply and/or more elegantly and/or even better than what I have thrown together here, but we all start somewhere right?
This is my situation:
I have 3 different files, that need to be copied to 3 different folders. I'm using a transform on the Firefox ESR MSI, which will be installed via ConfigMgr. Previously when running other *.BAT or *.CMD files I've used '%~dp0' to resolve the path, but I can't use that with a CA 38! I know I don't have to, but I would like to try and use a MSI in my ConfigMgr Deployment Type rather than a BAT/CMD file. I started by trying to run 3 separate CA FileCopies, but ran into CA Target length limits. Then I thought to use my CA to call a CMD file which has the 3 FileCopy commands in it and so now, this is my CA Target:
dim filesys, DIR : Set filesys = CreateObject("Scripting.FileSystemObject") : DIR = filesys.GetParentFolderName("Wscript.ScriptFullName") : Set shell = CreateObject("WScript.Shell") : shell.Run DIR & "\filecopy.cmd"
And this is what my MSI log yells back at me:
MSI (s) (00:1C) [04:43:21:447]: Product: Mozilla Firefox 68.7.0esr x64 en-GB -- Error 1720. There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor. Custom action CA_CustFileCopy script error -2147024894, : Line 1, Column 193,
Column 193 brings me to:
shell.Run DIR & "\filecopy.cmd"
In it's own *.VBS file, my CA Target above - without quotes around Wscript.ScriptFullName - works a treat and does what I want it to!
I've been running in cirlces for ages now and just don't know what else to try because, well, I just don't know enough.
Would someone mind either helping a noob out or pointing a noob towards some useful resources to read up or both, please?
Thanks in advance,
The (let's call it) interpreter for MSI Custom Actions isn't Windows Scripting Host so any use of that object (as in "WScript[dot]something") will fail. If you were to include the script in a transform and external CAB and execute it using CScript, it would work. If you had included error-trapping and logging in the script, you'd have seen the appropriate error in the log. Also, because I'm paranoid, I have each statement separate and each is error-trapped. In scripting, always assume that NOTHING is going to work, even stuff like creating FileSystemObject. Now, adding reams of "If err.number <>0 Then..." statements is a nuisance so get hold of the excellent BugAssert code: it's used by quite a few scripts that Microsoft pushed out.
In any event, why are you using script to copy files? Why not simply include the required files in a transform and external CAB?
If that is right, then whatever the MSI CA is reading/accessing in, what is that eqivalent for ("Wscript.ScriptFullName") in the GetParentFolderName part of my CA?
It is correct, yes. I don't know what the equivalent is, if indeed there is one. For CAs that required WScript objects, I've always added them as separate files. You could load the DLL into an object explorer and browse it but wouldn't it be simpler to debug why the transform didn't work?
First things first: what tool are you using to create the transform? If it's Orca/InstEdit, this is going to be uphill! You need to create the component(s), make additions to the File and Media tables, etc., etc. There are a few free MSI editing tools arouind if you Google long and deep enough.
Second: what did the verbose log tell you when you tested the transform? You took a log, right?