Windows server 2003 and Windows XP – How to script file download from FTP server

Posted by Mark | Posted in Scripting, Windows 2003, Windows XP | Posted on 22-07-2009

1

Do you know how to script basicĀ  FTP server connect/copy operations?

I`ll show you that.

Lets assume you want every Friday at 06:00pm to connect to specific FTP server and download all files from it to directory named D:\Scanfiles.

On your Windows server 2003 or Windows XP start notepad and type:

@echo off
echo user username> ftpbat.dat
echo password>> ftpbat.dat
echo prompt>> ftpbat.dat
echo mget *.*>> ftpbat.dat
echo quit>> ftpbat.dat
ftp -n -s:ftpbat.dat FTPserverIP
del ftpbat.dat

notepad

Save file as ftp.bat and place it in D:\Scanfiles folder.

Change this data:

username – your ftp username
password – your ftp password
FTPserverIP – ip address of ftp server to connect

After that create new scheduled task to run ftp.bat file every Friday at 06:00pm .

Cheers! :)

Windows server 2003 and Windows XP – How to shedule disk defragmenting

Posted by Mark | Posted in Scripting, Windows 2003, Windows XP | Posted on 07-07-2009

0

I`ll show you how to create very nice .bat script which will defragment your disks and generate report in log file.

This script was tested on Windows server 2003 or Windows XP machines.

Ok then, lets say you want to defragment C: and D: disks every Monday and Friday starting job at 10:00pm.

Also you want to store log file on C:\Tools folder.

OK, lets open notepad and copy paste this text:

@Ecxo off
Set logfile=C:\Tools\defrag.log
Echo Start %date%,%time% >>%logfile%
Echo *************************** >>%logfile%
Echo Defragmenting C: disk >>%logfile%
Echo. >>%logfile%
defrag.exe c: -f >>%logfile%
Echo *************************** >>%logfile%
Echo Defragmenting D: disk >>%logfile%
Echo. >>%logfile%
defrag.exe d: -f >>%logfile%
Echo *************************** >>%logfile%
Echo Finished %date%,%time% >>%logfile%
Echo *************************** >>%logfile%

Save this file as Defrag.bat and place it to C:\Tools folder

Now open command line and shedule defragmenting by typing:

at 10:00pm /every:M,F C:\Tools\Defrag.bat

defrag

Press “Enter”

And we are finished !