Cannot push .ini file to each user profile

May 13, 2011 at 10:12:34
Specs: Windows XP and 7
I'm trying to push out an .ini file to each remote user profile via a batch script. The .ini file sits on the server and needs to go into the \Application Data folder (for Win XP) for each profile that logs in (\AppData\Roaming folder for Win7). That way the software installed on their laptop runs for our config. Here's what I initially tried:

@ECHO OFF
IF "%allusersprofile%"=="C:\ProgramData" GOTO WIN7
XCOPY "\\ServerName\C:\File\file.ini" "%UserProfile%\Application Data\" /C /S /D /Y /I /V
EXIT
:WIN7
XCOPY "\\ServerName\C:\File\file.ini" "%UserProfile%\AppData\Roaming\" /C /S /D /Y /I /V
EXIT

This didn't work. At first we were thinking it's because the Application Data/AppData folders are "Read Only". But then I tried this as a test which worked - same location, just spelling out the path to the remote PC:

ECHO ON
XCOPY "\\ServerName\C:\File\file.ini" "\\PC\c$\USERS\metheuser\appdata\roaming\" /C /S /D /Y /I /V
EXIT

When I check the SET in CMD, the path for %UserProfile% comes up with the C drive as "C:" - not "C$". So now I'm thinking it may be a security/authentication issue. Without placing the local admin name and PW in the BAT file, is there any other workaround or other suggestions?


See More: Cannot push .ini file to each user profile

Report •

#1
May 13, 2011 at 10:15:24
If I do the following, which is essentially the fully expressed %userprofile% cmd, it does not work:

ECHO ON
XCOPY "\\ServerName\C:\File\file.ini" "\\PC\c:\USERS\metheuser\appdata\roaming\" /C /S /D /Y /I /V
EXIT

The error I always get is "Invalid drive specification". Note the ":" instead of the "$" after the "C".


Report •

#2
May 13, 2011 at 15:37:21
Would it help to create a shortcut to the batch, then under properties/shortcut/advanced (depending on your OS), check Run as Admin, and then access the batch via the shortcut?

But in your use of environmental variables, aren't you omitting the client computer name?


Report •

#3
May 13, 2011 at 15:54:48
Doing the shortcut is a good idea, may play with that option. But we want it to be brainless/in the background for our users.

I should have mentioned I'm trying to add this to their login script. That way they always have the latest version when they log in. And hence the lack of client computer name (the login scripts runs as the connecting PC, right?).


Report •

Related Solutions

#4
May 13, 2011 at 16:27:00
Ok, the "push out" term led me to think the batch was on the server. Your EVs seem ok. As for using the shortcut, just link to it rather than the batch.

Report •

#5
May 16, 2011 at 14:09:01
Finally got it working. If we pointed the XCopy to a location anywhere within the profile it would copy the whole folder structure (not just the file) to the Desktop (Win7) or the profile folder (XP). So I changed it to XCopy to just the C: drive then used a Move cmd to the final location.

@ECHO off
IF "%allusersprofile%"=="C:\ProgramData" GOTO WIN7
XCOPY "\\Server\File\File.ini" "C:\" /C /S /D /Y /I /V
MOVE "C:\File.ini" "C:\Documents and Settings\%Username%\Application Data\"
EXIT
:WIN7
XCOPY "\\Server\File\File.ini" "C:\" /C /S /D /Y /I /V
MOVE "C:\File.ini" "C:\Users\%Username%\AppData\Roaming\"
EXIT

I can't think of any other way to expedite it any better - and to keep it seemless and "no hands" for users.


Report •

Ask Question