/build/static/layout/Breadcrumb_cap_w.png

File Copy from the Network

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

Answers (5)

Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
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
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
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")
Posted by: xythex 18 years ago
Orange Senior Belt
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
Posted by: xythex 18 years ago
Orange Senior Belt
0
WOW THANK YOU!!
That fixed the problem!

How come Wscript. doesn't work in a VBScript custom action?
Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
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.

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ