locked
Copy file from virtual package to client machine's C: drive RRS feed

  • Question

  • I need to include two files (one batch file, one XML file) in an App-V package so that I can copy them to the client machine's C: drive (let's say C:\Temp) and then execute the batch file. What is the best way to do this?

    http://social.technet.microsoft.com/Forums/en-US/appvgeneralsequencing/thread/1fa881c6-5a25-4cf3-890f-5f960afa7e7e

    The solution found in the above thread seems like the right path to follow. The OSD scripting discussed in that thread covers copying files to the AppData folder. How would I copy the folder/files from the virtual environment to a location such as C:\Temp?

     

    Tuesday, October 25, 2011 7:59 PM

Answers

  • Use this approach to run a command prompt into the virtual environment and try copying the file by running the same commands in the script: http://blog.stealthpuppy.com/virtualisation/app-v-faq-27-how-do-i-get-an-application-into-the-app-v-bubble-for-troubleshooting/

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    • Proposed as answer by znack Wednesday, November 23, 2011 11:43 AM
    • Marked as answer by Aaron.ParkerModerator Friday, November 16, 2012 11:14 PM
    Friday, November 18, 2011 5:23 PM
    Moderator
  • <SCRIPT EVENT="LAUNCH" PROTECT="TRUE"  TIMEOUT="0" TIMING="PRE" WAIT="TRUE">  

    <SCRIPTBODY>XCOPY /S /Y "%SFT_MNT%\FolderName\batchfile.bat" "C:\Temp\batchfile.bat" \n

    XCOPY /S /Y "%SFT_MNT%\FolderName\xmlfile.xml" "C:\Temp\xmlfile.xml"</SCRIPTBODY>

    </SCRIPT>



    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.


    • Proposed as answer by znack Friday, October 28, 2011 9:47 AM
    • Edited by Aaron.ParkerModerator Friday, November 18, 2011 5:24 PM Changed PROTECT="FALSE" to PROTECT="TRUE"
    • Marked as answer by Aaron.ParkerModerator Friday, November 16, 2012 11:13 PM
    Tuesday, October 25, 2011 8:47 PM
    Moderator

All replies

  • <SCRIPT EVENT="LAUNCH" PROTECT="TRUE"  TIMEOUT="0" TIMING="PRE" WAIT="TRUE">  

    <SCRIPTBODY>XCOPY /S /Y "%SFT_MNT%\FolderName\batchfile.bat" "C:\Temp\batchfile.bat" \n

    XCOPY /S /Y "%SFT_MNT%\FolderName\xmlfile.xml" "C:\Temp\xmlfile.xml"</SCRIPTBODY>

    </SCRIPT>



    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.


    • Proposed as answer by znack Friday, October 28, 2011 9:47 AM
    • Edited by Aaron.ParkerModerator Friday, November 18, 2011 5:24 PM Changed PROTECT="FALSE" to PROTECT="TRUE"
    • Marked as answer by Aaron.ParkerModerator Friday, November 16, 2012 11:13 PM
    Tuesday, October 25, 2011 8:47 PM
    Moderator
  • Can I test this script in standalone mode/by installing the App-V package with the MSI?

    Wednesday, October 26, 2011 4:42 PM
  • Yes, but you'll have to make the changes in the Sequencer because it places a copy of the OSD files into the MSI. Use the SFTMIME ADD PACKAGE command to add to a local client instead - this will use the OSD files stored outside of the MSI.

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    Wednesday, October 26, 2011 4:47 PM
    Moderator
  • One improvement maybe could be to use standard env. variables as much as possible e.g. not to hardcode c:\temp into script as on some machines that folder might not exist: XCOPY /S /Y "%SFT_MNT%\FolderName\batchfile.bat" "%temp%\batchfile.bat"

    This way you can be always sure that the target exists (of course you have to use those variables in later scripts as well if you intend to execute the .bat file you copied out...) on each machine.

     

     


    br,
    Kalle Saunamäki
    http://blog.gridmetric.com/
    Tuesday, November 1, 2011 8:19 AM
    Moderator
  • With the following script:

     

    <SCRIPT EVENT="LAUNCH" PROTECT="FALSE" TIMING="PRE" WAIT="TRUE">
       <SCRIPTBODY LANGUAGE="Batch">XCOPY /S /Y "%SFT_MNT%\Temp\test.bat" "C:\Temp\test.bat"</SCRIPTBODY>
      </SCRIPT>

     

    I caught a screenshot of the command prompt showing the following error:

     Invalid drive specification
    0 File(s) copied

    Friday, November 18, 2011 2:52 PM
  • Change PROTECT=FALSE to PROTECT=TRUE, that way the script will run inside the virtual environment. My mistake in my original posting.

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    Friday, November 18, 2011 2:56 PM
    Moderator
  • That fixed the "Invalid drive specification" error but now I am getting:

    "Sharing violation"

    Friday, November 18, 2011 3:11 PM
  • Use this approach to run a command prompt into the virtual environment and try copying the file by running the same commands in the script: http://blog.stealthpuppy.com/virtualisation/app-v-faq-27-how-do-i-get-an-application-into-the-app-v-bubble-for-troubleshooting/

    This forum post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.
    • Proposed as answer by znack Wednesday, November 23, 2011 11:43 AM
    • Marked as answer by Aaron.ParkerModerator Friday, November 16, 2012 11:14 PM
    Friday, November 18, 2011 5:23 PM
    Moderator
  • You can use a batch script or VBS to copy those two files from A location to B location ( C:\Temp) and call it in the OSD file.

    Open OSD file and navigate to <DEPENDENCY>section. Below to it add the SCRIPT section and you can refer to an existing script by its file name. or enter the syntax of the commands directly .Based on the needs you can set SCRIPT TIMING and EVENT to PRE STREAM, PRE LAUNCH etc.

    If you want your script to run within the virtual environment, do Keep PROTECT=TRUE, or else if you want the script to be run outside the bubble then change it to FALSE.In your case keep it to TRUE so that the script runs inside the bubble and copies the files to c:\Temp. 

    Friday, June 19, 2015 2:32 PM