From: Rich on
I have a few hundred computers that haven't been defragged in years. I was
wondering if rather than doing it manually, if someone had a script where if
i just put all the computer names in a txt file, it would iterate through the
list and perform a "defrag c: -f" on them all from my workstation. The
workstations all have the same local administrator password, so the process
would be the same for each. I just dont know how to write scripts.

I know if i were going to do this manually from my computer I would run the
command below for each ComputerName

psexec \\ComputerName -u administrator -p MyPassword
c:\windows\system32\defrag c: -f

I just dont know how to make a script do that for each computer name in a
file, one computer per line.
From: Todd Vargo on
Rich wrote:
>I have a few hundred computers that haven't been defragged in years. I was
> wondering if rather than doing it manually, if someone had a script where
> if
> i just put all the computer names in a txt file, it would iterate through
> the
> list and perform a "defrag c: -f" on them all from my workstation. The
> workstations all have the same local administrator password, so the
> process
> would be the same for each. I just dont know how to write scripts.
>
> I know if i were going to do this manually from my computer I would run
> the
> command below for each ComputerName
>
> psexec \\ComputerName -u administrator -p MyPassword
> c:\windows\system32\defrag c: -f
>
> I just dont know how to make a script do that for each computer name in a
> file, one computer per line.

@echo off
for /f "delims=" %%a in (workstation.txt) do call :process "%%a"
goto :eof

:process
echo %%a
psexec \\%%a -u administrator -p MyPassword
c:\windows\system32\defrag c: -f

From: Todd Vargo on
Todd Vargo wrote:
> Rich wrote:
>>I have a few hundred computers that haven't been defragged in years. I
>>was
>> wondering if rather than doing it manually, if someone had a script where
>> if
>> i just put all the computer names in a txt file, it would iterate through
>> the
>> list and perform a "defrag c: -f" on them all from my workstation. The
>> workstations all have the same local administrator password, so the
>> process
>> would be the same for each. I just dont know how to write scripts.
>>
>> I know if i were going to do this manually from my computer I would run
>> the
>> command below for each ComputerName
>>
>> psexec \\ComputerName -u administrator -p MyPassword
>> c:\windows\system32\defrag c: -f
>>
>> I just dont know how to make a script do that for each computer name in a
>> file, one computer per line.
>
> @echo off
> for /f "delims=" %%a in (workstation.txt) do call :process "%%a"
> goto :eof
>
> :process
> echo %%a
> psexec \\%%a -u administrator -p MyPassword
> c:\windows\system32\defrag c: -f

Oops, I forgot to mention, that was batch code but this group is for
vbscript. For further assistance with batch code, please use a batch group.