As usual in Windows we can do similar things in quote many different ways, but by taking advantage of the built-in MDT objects we can often easy the pain. Here is a sample for copying a folder, using the MDT progress bar, properties, logging and error handling.
Here is an example that copies a folder named StuffToCopy folder from Applications on your deployment server, to C:Windows\Temp on the client.
Save the script as ZTICopyFolder.wsf (Windows Script File) in your scripts folder. This is needed since we are including the components from the core utility script (ZTIUtility.vbs) from MDT.
<job id="ZTICopyFolder"> <script language="VBScript" src="ZTIUtility.vbs"/> <script language="VBScript"> Option Explicit Dim iRetVal On Error Resume Next iRetVal = ZTIProcess ProcessResults iRetVal On Error Goto 0 Function ZTIProcess() ' Declare the variables Dim sSourceFolder Dim sTargetFolder ' Define Source and Target folders sSourceFolder = oEnvironment.Item("DeployRoot") & "\Applications\StuffToCopy" sTargetFolder = "C:\Windows\Temp\StuffToCopy" oLogging.CreateEntry "Copying " & sSourceFolder & " folder to the local machine", LogTypeInfo ' Optional progess logging to the task sequence progress bar oLogging.ReportProgress "Copying " & sSourceFolder & " folder to the local machine", 20 ' Do the actual copying oFSO.CopyFolder sSourceFolder, sTargetFolder, true End Function </script> </job>
Can't say I have, but if you add a pause to the task sequence prior to the script run, and then start process monitor (sysinternals), you can normally learn more about the error.
Have you ever encountered permission denied error when copying files to local machines desktop folder from deployment share during execution of task sequence?
I have a simple VBScript that is trying to copy a file from deployment share to "C:UsersAdministratorDesktop" during deployment. I get access denied error and I just don't understand what is causing this. If I change the script so that it copies this file under the root of C drive it works.
Answered this offline… Johan
Johan, I need to ask a more basic "basic" question, I think. My MDT setup is quite simple. It's DHCP workgroup, connected to a simple 2003 server with DHCP running, and a target PC, no other network nodes. I set it up last year, to verify a customer could deploy Windows 7 to the target with MDT. A year later now, another customer wants to deploy the AMD Catalyst drivers as well, with MDT, same target. Windows still deploys just fine, but I can't add these drivers. At first, I added the AMD Catalyst Install as an application, but the… Read more »
Hi John, I had been calling oUtility.VerifyPathExists(strDest) earlier in the script to make sure that the destination folder is there. I've not run across really any problems with how things are working, I'm probably just being paranoid with building a robust script. So I guess there's no way to directly access the return value that is used in the logging for ZTIUtility? My thought is that since I can't get a return value on whether the operation actually succeeded (I can only tell by the SUCCESS or FAILURE log entries as shown above), if I return the custom method as… Read more »
For foldercopy you can simply check if the folder exist before doing the copy operation.
If oFSO.FolderExists(oEnvironment.Item("DestinationLogicalDrive") & "MyHappyFolder") then
' Copy the folder
' Folder does not exist, log error
Johan, I've been modifying custom WSF templates to install non-standard apps (much like your Quicktime installer, etc.) I'm doing a folder copy using ZTIUtility's CopyFolderEx. I can get it to work fine, but the problem I'm running across is that it doesn't return any code. When I run, the log will tell me SUCCESS or FAILURE, but the actual "oFileHandling.CopyFolderEx" function will not return a value, so I can't do further modification based on success or failure. What I'm asking I suppose is how can I get the success or failure code from ZTIUtility for the copy folder operation? Example… Read more »
This is great. Thanks Johan. I have wanted this for a while now. Now I will just need to tweak it a little to pull the sources location from an argument.