windows - Create file for every script instance -
i've created script below obtain folder size of c:\users linux tool du. script distributed via gpo users.
xcopy \\0.0.0.0\netlogon\gnu-core-utils\du.exe c:\profile-size-script\ /i /s /y xcopy \\0.0.0.0\netlogon\gnu-core-utils\libintl3.dll c:\profile-size-script\ /i /s /y xcopy \\0.0.0.0\netlogon\gnu-core-utils\libiconv2.dll c:\profile-size-script\ /i /s /y c: cd c:\profile-size-script du -hs c:\users\* > \\0.0.0.0\userfolder\%username%.txt
lines explained below:
- copies file called du.exe location c:\profile-size-script
- copies file called libintl3.dll same location.
- copies file called libiconv2.dll
- change drive c: in case cmd starts @ different drive letter.
- change same folder size
- use du folder size , echo output \0.0.0.0\userfolder\%username%.txt.
the issue script not creating new file each user appending firstly created file %username%.txt
i think you're looking this:
xcopy \\0.0.0.0\netlogon\gnu-core-utils\du.exe c:\profile-size-script\ /i /s /y xcopy \\0.0.0.0\netlogon\gnu-core-utils\libintl3.dll c:\profile-size-script\ /i /s /y xcopy \\0.0.0.0\netlogon\gnu-core-utils\libiconv2.dll c:\profile-size-script\ /i /s /y cd /d c:\profile-size-script /d %%u in (c:\users\*) (du -hs c:\users\* > \\0.0.0.0\userfolder\%u%.txt)
the for /d
loop reads through each of folders , executes du.exe
command each folder (%%u
) finds. check out for /?
more information , other possibilities.
additional note: cd /d
command allows change drive letter , directory @ same time. alternately, can skip c:
, cd
lines altogether if run commands without changing directory using explicit path this:
xcopy... /d %%u in (c:\users\*) ( c:\profile-size-script\du.exe -hs c:\users\* > \\0.0.0.0\userfolder\%u%.txt)
Comments
Post a Comment