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?
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)
Please log in to answer
Posted by:
brenthunter2005
18 years ago
Posted by:
brenthunter2005
18 years ago
Posted by:
xythex
18 years ago
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
Posted by:
brenthunter2005
18 years ago
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.
so that the conversation will remain readable.