I have a rather large file to copy from the network to the local machine. I would like to use the MoveFile table to do it so that I have a progress bar while it is being copied.

My original plan was to use a vbscript custom action in the Execute Imediate sequence to find the next available drive letter, map it to the location using the logged on user's security context, and then populate a variable with the new driveletter.

Then when the actual copy happened in the Execute Deferred sequence it would use the drive letter in the variable.


However, I cannot seem to get the:

WScript.Network.MapNetworkDrive to work in any sequence in my VBScript. In addition I am unable to just copy from the URL in the Execute Deferred sequence because of course it is running under the SYSTEM context without rights to the share.

How would you handle this?
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

2
Can you post your vbscript, as I suspect you are using "WScript.Network.MapNetworkDrive". With vbscript custom actions you are unable to do this.

You need to create the networking object first

eg:
Set objNetwork = CreateObject("WScript.Network")
objNetwork.MapNetworkDrive etc etc etc
Answered 02/17/2006 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Here is the script. This works fine outside of an MSI when I manually supply UNCLOC and REM out all of the Session.Propertys. However in the MSI DriveExists doesn't work and neither does MapNetworkDrive


' This VBSCRIPT maps the MSI Property UNCLOC to the next available drive
' If successful it returns the drive letter in the variable NEWDRIVE
' If the mapping fails it sets the property SCRFAIL with the error description
Option Explicit
On Error Resume Next

Dim WshNetwork, ObjFileSys, chrnum, NewDrive, UNCLOC

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set ObjFileSys = Wscript.CreateObject("Scripting.FileSystemObject")

chrnum = "69"
NewDrive = "0"
UNCLOC = Session.Property("UNCLOC")

Do Until NewDrive <> "0"
if Not objFileSys.DriveExists(Chr(chrnum) & ":") = TRUE Then NewDrive = Chr(chrnum)
chrnum = chrnum + 1
If chrnum > 90 then
Err.Raise vbObjectError + 99,,"No Drives Available to Map"
NewDrive = "NODRIVE"
End If
Loop

If Err.Number = 0 Then wshNetwork.MapNetworkDrive NewDrive & ":",UNCLOC
If Err.Number <> 0 Then Session.Property("SCRFAIL") = Err.Description
If NewDrive <> "NODRIVE" Then Session.Property("NEWDRIVE") = NewDrive

Set WshNetwork = Nothing
Set ObjFileSys = Nothing
Set chrnum = Nothing
Set NewDrive = Nothing
Set UNCLOC = Nothing
Answered 02/17/2006 by: xythex
Orange Senior Belt

Please log in to comment
2
Remove the references to WSCRIPT as you can't use them like that in vbscript custom actions.

eg:Set WshNetwork = CreateObject("WScript.Network")
Set ObjFileSys = CreateObject("Scripting.FileSystemObject")
Answered 02/17/2006 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
0
WOW THANK YOU!!
That fixed the problem!

How come Wscript. doesn't work in a VBScript custom action?
Answered 02/17/2006 by: xythex
Orange Senior Belt

Please log in to comment
0
Here is an extract from the Windows Installer SDK:

The installer runs script custom actions directly and does not use the Windows Script Host. The WScript object cannot be used inside a script custom action because this object is provided by the Windows Script Host. Objects in the Windows Script Host object model can only be used in custom actions if Windows Script Host is installed on the computer by creating new instances of the object, with a call to CreateObject, and providing the ProgId of the object (for example "WScript.Shell"). Depending on the type of script custom action, access to some objects and methods of the Windows Script Host object model may be denied for security reasons.

Answered 02/21/2006 by: brenthunter2005
Fifth Degree Brown Belt

Please log in to comment
Answer this question or Comment on this question for clarity