|
Answer» Can you assisted with commands or examples to get me STARTED? I needed to create a batch file to run based on a list of WINDOWS profile usernames to include the default profile. This batch file will be running in SCCM package.
I will be working on Windows XP and 7 but I may want to separate and create two batch files for each OS to simplify the process.
1.) I need to create the list. dir c:\users\*.>users.txt dir c:\”Documents and Settings\*.>users.txt”
2.) Delete a file from all Windows 7 profiles based on the list.
>>C:\Users\%username%\FAVORITES\
3.) Then add a file to all Windows 7 and XP profiles based on the list. Win7 >>C:\Users\%username%\Favorites >>C:\Users\%username%\Desktop WinXP >>C:\Documents and Settings\%username%\Desktop >>C:\Documents and Settings\%username%\Favorites
I think this will work regardless of XP or 7.
Code: [Select]echo off for /f "tokens=*" %%I in ("%USERPROFILE%") do set pPath=%%~dpI pushd "%pPath%" for /f "tokens=*" %%A in ('dir /ad /A-S /b') do ( DEL "%%~fA\favorites\somefile.txt" ) POPDThanks for the post that did it for me! Maybe someone else can use this also.
echo off :FIND VERSION ver | findstr /i "5\.1\." > nul IF %ERRORLEVEL% EQU 0 goto WindowsXP ver | findstr /i "6\.1\." > nul IF %ERRORLEVEL% EQU 0 goto WINDOWS7
:WindowsXP for /f "tokens=*" %%I in ("%USERPROFILE%") do set pPath=%%~dpI pushd "%pPath%"
for /f "tokens=*" %%A in ('dir /ad /A-S /b') do ( )
echo copy to folder...
for /f "tokens=*" %%A in ('dir /ad /A-S /b') do ( copy "c:\pass\pass_Self-Service-4.7.url" "%%~fA\favorites\" )
echo copy for desktop copy "c:\pass\pass_Self-Service-4.7.url" c:\documents and settings\all users\desktop
:Windows7 for /f "tokens=*" %%I in ("%USERPROFILE%") do set pPath=%%~dpI pushd "%pPath%"
for /f "tokens=*" %%A in ('dir /ad /A-S /b') do ( DEL "%%~fA\favorites\PB_Sites\PASS Self-Service.url" )
echo copy to folder...
for /f "tokens=*" %%A in ('dir /ad /A-S /b') do ( copy "c:\pass\pass_Self-Service-4.7.url" "%%~fA\favorites\PB_Sites\" )
echo copy for desktop copy "c:\pass\pass_Self-Service-4.7.url" c:\users\public\desktop
|