Need to push two files to each user profile on each machine on our network.

C:\Users\jstrickland\AppData\Roaming\Microsoft\Templates is an example of the location I need to push the two files to.

My problem is how do I account for the different user profile names in the script?

I've tried %username% but that doesn't seem to work.

Any thoughts?

Answer Summary:
0 Comments   [ - ] Hide Comments


Please log in to comment

Community Chosen Answer



Use %APPDATA%\Microsoft\Templates.

Answered 08/19/2013 by: dugullett
Red Belt

  • Sorry that doesn't seem to work either.
    I'm trying to unzip the folder directly into the location since I have two files that need to go into the folder. Should this go to all profiles on the machine or just the one that I'm signed in as?
    • Are you doing this through managed install? That will run as SYSTEM, and not recognize that directory. You will need to run this as a script as logged in user.
      • Running it as a script. Just changed it to an Online Script and set it to run as All logged in users. Still no results in the user that is logged into the machine I'm testing this on.
      • It needs to be "as user logged into console".
  • Sadly still didn't work. Not sure what to try at this point.
    • What are the steps you are taking in the script? Verify, Remediation, etc.
  • " On success" Unzip the dependancy to %APPDATA%\Microsoft\Templates

    That's all.
    • I've never unzipped a file there, but I'm wondering if you have the same results copying the file? Also see about changing the directory to C:\temp? Maybe there's an issue with the variable. I seem to recall reading that somewhere.

      I'm assuming it works when you do not use the variable and put the exact path?
  • Ok I'm unzipping to "C:\Install\Scripts" and the files both show up there.
    Looks like that worked. Very strange since I tried these exact steps earlier, just with the
    %UserName% variable instead of the %AppData% variable.

    Thanks very much.
    • Not sure if it's related, but the release notes for 5.5 has this listed for resolved issues. Maybe it's not recognizing that one either?

      3511: Scripts fail when the target path contains the variable %PROGRAMFILES%.
  • Not sure why the unzip wasn't working, but the unzip and copy worked.
Please log in to comment
Answer this question or Comment on this question for clarity



I know you have an answer, but wanted to provide an alternative way.  Say you to copy a file from the root of each profile on the system to a subfolder within the same profile on that system, you could do this in a batch.  Note:  This example is obviously for W7, but could be easily altered for other copies or XP

@echo off
cd /D C:\Users
for /D %%a in (*.*) do COPY /Y "%%a\file" "%%a\path\file.ext"




Answered 08/20/2013 by: drose23
Second Degree Blue Belt

Please log in to comment