I am trying to run a script to copy files from a specific location in the user folder to a network folder using %USERNAME%.

The idea is to periodically backup a users NK2 file. I am using xcopy to do the copy and the command works out side of Kace but doesn't work in Kace's scripting.

The basics are:

Directory: C:\Windows\System32
File: xcopy.exe
parameters /D "C:\Documents and Settings\%USERNAME%\Application Data\Microsoft\Outlook\*.*" "H:\outlook data"

Does anyone know another way of using Kace to copy out of the user profile? Or have any suggestions?
Answer Summary:
Running as a bat fixed it. I should have done that in the first place.
1 Comment   [ + ] Show comment


  • Can i stire up an old thread please ... I'm having he same issue, but i am using a .bat file. still i get the computername instead of the username when using $username$. how did you resolve this and do you have an example for me?

Community Chosen Answer

Who are you running the script as? By default everything runs as local system. This is probably why %username% isn't working.
Answered 04/02/2012 by: dchristian
Red Belt

  • I am trying to run it as the user logged in.
    • Have you tried running it as a shell script? You should just be able to copy and paste your bat file right into the script text. Make sure you change the script name from script.sh to script.bat
  • what version of the agent are you running?
  • We are running v5.3.53053. I actully wasn't running it as a bat file but rather calling xcopy to run with these parameters. I will try it as a bat file.

All Answers

Running as a bat fixed it. I should have done that in the first place.
Answered 04/02/2012 by: nwhistler
Senior Purple Belt