question

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ asked AllenLiu-MSFT commented

Passing variables in xcopy command

I need to copy a file from the MDT server to the computer running the task sequence. Here is what I'm trying to use, but it never copies the file:
xcopy "%deployroot%\OfflineJoinDomain\%OSDComputerName%.txt" "C:\Users\Administrator\Desktop\"

Here is what works:
xcopy "Test-JoinDomain.txt" "C:\Users\Administrator\Desktop"

I've created a text file with the name of the new computer. How can I use the variable name of the computer to copy the text file?

mem-mdt
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AllenLiu-MSFT avatar image
0 Votes"
AllenLiu-MSFT answered AllenLiu-MSFT edited

Hi, anonymous user
Thank you for posting in Microsoft Q&A forum.
Try this to see if it helps:
Create a folder named computer name and put the .txt file in it.
Then use:

 xcopy "%deployroot%\OfflineJoinDomain\%OSDComputerName%\*.txt" "C:\Users\Administrator\Desktop\"


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

$$ANON_USER$$ avatar image
0 Votes"
$$ANON_USER$$ answered AllenLiu-MSFT commented

Allen,
Thanks for responding. I've tried the xcopy command before, but I haven't tried creating a folder with the computer name.

Are you suggesting I create the folder on the laptop that's getting the image?

(add this to task sequence?)
mkdir "c:\%OSDComputerName%"

(wouldn't xcopy command be different?)
xcopy "%deployroot%\OfflineJoinDomain\%OSDComputerName%*.txt" "c:\%OSDComputerName%\"

EDIT: I just tried above, but it didn't work either. How can I pass the variable name for the computer name so it creates the folder on the laptop running the task sequence?

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.