NEXPERT-AG
asked on
Script to replace old file / shortcut with a new one
I got a migration of a software tonight. The users start the software using a *.FP7 file, which is usually called mondo.fp7. Now the problem is that I need to replace this mondo.fp7 file with a new one called mondo_11.fp7 file.
The users placed this mondo.fp7 file on different locations, the majority on the desktop. Now I need to replace this mondo.fp7 wherever it's located in the users profile with the new mondo_11.fp7 file.
As this migration takes place in a large environment I would like to script the "find mondo.fp7 and replace with mondo_11.fp7 wherever it's located" taks.
Help is appreciated.
The users placed this mondo.fp7 file on different locations, the majority on the desktop. Now I need to replace this mondo.fp7 wherever it's located in the users profile with the new mondo_11.fp7 file.
As this migration takes place in a large environment I would like to script the "find mondo.fp7 and replace with mondo_11.fp7 wherever it's located" taks.
Help is appreciated.
ASKER
Thanks jawa29, but I would like to run a script logged in as administrator and replace the files from a central location, rather than having a script ever user needs to run from his profile.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Probably adding a logon script should be the solution..
Bye Gastone Canali
Bye Gastone Canali
@echo off
:: replacefile.cmd
:: Replace the file found inside the user profile
:: bye Gastone Canali
::
:: Add this script as "logon script"
::
:: Setting up a Logon Script
:: http://technet.microsoft.com/en-us/library/bb742376.aspx
setlocal
rem file to be searched
set searchedFile=mondo.fp7
rem complete file name with path (whe the new file is located)
set newFile=\\myDomainController\netlogon\mondo_11.fp7
rem Search based From userprofile Root ex.: C:\Documents and Settings\user1
cd /d %USERPROFILE%
rem if already Done goto end
if exist repalce.done goto :_END
echo on
for /f "tokens=*" %%F in ('dir "%searchedFile%" /s /w /b') do copy /y %newFile% %searchedFile%
if "%errorlevel%"=="1" goto :_END
echo %date%>repalce.done
:_END
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This script will search for a file within the current users profile, it will then copy a new file from a given location and then delete the original if the copy was successful.
Hope it helps
Jawa29
Open in new window