Monday, 5 July 2010

Command line in Windows world

To delete files older than X days through command line Forfiles can be used:
forfiles /p s:\Backups /d -10 /c "cmd /c del @path"

To redirect error output to standard output:
mingw32-make 1 > output.txt 2>&1

Check error level:
if errorlevel 1 command

Change network configuration with netsh command Show configuration: 
netsh interface ip show config

Configure interface "LAN": 
netsh interface ip set address name="LAN" static 10.64.167.191 255.255.255.0 10.64.167.1 1

Dump configuration of interface:
netsh -c interface dump > c:\location1.txt

Load saved configuration:
netsh -f c:\location1.txt

Configure interface to DHCP mode:
netsh interface ip set address "LAN" dhcp

Configure DNS to DHCP mode:
netsh interface ip set dns "LAN" dhcp

Add scheduled task via command line:

schtasks /create /d thu /sc weekly /tn backup_thursday /tr f:\Admin\thursday_backup.bat

Copy directories:
xcopy F:\dir1 F:\Backup\dir2 /s /y

Show open ports on firewall:
netsh firewall show portopening ENABLE


Show user's OU and other information:
adfind -sc u:nagios dn
Configure NTP synchronisation with Linux

w32tm /config /update /manualpeerlist:"192.168.1.2,0x8" /syncfromflags:MANUAL
net stop w32time
net start w32time

Ping does not work

Today I would like to discuss a banal situation: host A is directly connected to host B, ping from host A to host B does not work. What are...