6/28/2006

Admin Blog Has Moved

I found that wordpress's blog is easier to maintain. I have exported my Admin Blog to here.

5/12/2006

MSH is now Microsoft PowerShell


I haven't played with Monad shell for a while, the next thing I know there is a new scripting language called "Microsoft PowerShell". At first, I thought it's a brand new language, but actually they renamed Monad and made it PowerShell.

After installation, I tried to run one of my earlier Monad scripts. Just like the previous updates of Monad, the default execution policy is "Restricted". Under this policy, you can use PowerShell interactively. No scripts are allowed. If you like to run your own scripts without signing, you need to change the execution policy. Now there is a cmdlet to change policy without using regedit. Here is the cmdlet to change the policy to RemoteSigned.


Set-ExecutionPolicy RemoteSigned

5/10/2006

Windows Hidden File Attribute

Recently, I used xcopy to backup all the files from a bad hard drive to another drive under Windows XP. After all the files got copied, the directory is hidden and cannot be seen. I tried to use attrib.exe to remove the hidden attribute, however the command warned me that the directory's system attribute is set and I cannot change it.


H:\>attrib -h enterprise
Not resetting system file - H:\enterprise

H:\>attrib -a enterprise
Not resetting hidden file - H:\enterprise

H:\>attrib -a -h enterprise
Not resetting system file - H:\enterprise


I then tried to read the online help. It turns out I need to specify the /s and /d switches, too. So, the command should be used like this.


H:\>attrib /s /d -s -h enterprise

4/30/2006

Run Applications Written for Other Languages (Windows XP)

If you ever install applications written for other languages in Windows 98, you know that most of the time the user interface is not readable. With introduction of Windows 2000 and Windows XP, Microsoft has added the ability to display application user interface in other language. I'll show the steps to enable the system to show the application written for Japanese.

  1. Click on "Start" button and select "Control Panel" to bring up Control Panel.
  2. Click on "Date, Time, Language, and Regional Options" to bring up the following dialog.
  3. Click on "Regional and Language Options" to bring up the next dialog.
  4. In this dialog, click on the "Advanced" tab. In the "Language for non-Unicode programs" section, select the language you want. In this case, I picked Japanese. Finally, click on OK to close the dialog. You need to reboot the computer to use the new settings.

3/24/2006

Fedora Core 5 Installation Notes

Just downloaded the FC5 DVD iso from the mirror site. Here are some of the notes. The test machine is Acer Ferrari 3400. Note that most commands require root privilege. So, use su or sudo to obtain a root shell first. I tried the i386 distribution first, but later I used the x86_64 architecture.

Burning DVD
After the DVD iso got downloaded. I need to burn a DVD using it. I used this command to format a DVD-RW disc I have in the drive.


dvd+rw-format -f /dev/cdrom


I then open the Nautilus file manager and browse to the directory where the iso file is. Right click on the iso file and select "Write to Disc..." to burn the disc.

KDE
The default installation doesn't install KDE. My first take is to use the new Package Manager to add KDE. However, the Package Manager tried to download the files from the mirror sites. It was very slow. Since I already have the installation DVD, so I decided to use that to install KDE.

The public keys are not imported to the system. The first step is to import the public key.


rpm --import /media/disk/RPM-GPG-KEY*


Note that /media/disk is the path to my DVD. Substitute the one for your system. Now I can use yum localinstall to install KDE.


yum localinstall /media/disk/Fedora/RPMS/kde*


Ok, I know this is lame. I am lazy and I don't want to type in the names one by one. This will install every packages whose name starts with kde. You will install some extra packages if you use this command.

Extra Yum Repositories
Even though the current Fedora has tons of packages. Some of the necessary ones for functional desktop are not included. There are two nice repositories:livna and freshrpms. To use these two repositories, just type:


rpm -ihv http://rpm.livna.org/fedora/5/x86_64/livna-release-5-4.noarch.rpm
rpm -ihv http://ayo.freshrpms.net/fedora/linux/5/x86_64/RPMS.freshrpms/freshrpms-release-1.1-1.fc.noarch.rpm


DVD Player
To my surprise, the default player doesn't play DVD. I found this great guide on installing DVD player. Here are the commands.


yum -y install xine xine-lib xine-skins


Macromedia Flash

It turns out my decision to use x86_64 is a bad one. Currently, there is no Flash player/plugin for x86_64. After a little research on the web, I found that I can install i386 version of FireFox. Here is the info I found. First create a file called fedora-base-i386.repo in /etc/yum.repos.d .


[base-i386]
name=base-i386
baseurl=http://download.fedora.redhat.com/pub/fedora/linux/core/$releasever/i386/os/
gpgcheck=1
enabled=0


Use the following command to uninstall the 64 bit FireFox and install the 32 bit version.


rpm -e firefox
yum --enablerepo=base-i386 install firefox.i386


Now, we can install the 32 bit flash plugin. Copy this file to your /etc/yum.repo.d . Use this command to install the flash plugin.


yum -y install flash-plugin


Media Player
Most sites that I visit use Quicktime as video format. I need mplayer for those Quicktime movie files. The installation of mplayer is straight forward. Just use this command to install it.


yum -y --disablerepo=livna install mplayer mplayer-skins mplayer-fonts


However, I still need the browser plug-in for my browser. Remember that I installed the 32 bit FireFox, therefore I need the 32 bit plug-in. First, I need to uninstall 64 bit mozilla as the 32 bit mplayerplug-in needs 32 bit mozilla.


rpm -e mozilla yelp


Now, I need to install the 32 bit mplayerplug-in from livna-i386 repository. I created a file livna-i386.repo in the /etc/yum.repos.d directory.


name=Livna for Fedora Core $releasever - i386 - Base
baseurl=
http://rpm.livna.org/fedora/$releasever/i386/
http://livna.cat.pdx.edu/fedora/$releasever/i386/
http://wftp.tu-chemnitz.de/pub/linux/livna/fedora/$releasever/i386/
http://ftp-stud.fht-esslingen.de/pub/Mirrors/rpm.livna.org/fedora/$releasever/i386/
failovermethod=priority
#mirrorlist=http://rpm.livna.org/mirrorlist-5
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-livna


After the repo is setup, I can use yum to install the 32 bit mplayerplug-in.


yum -y --eanablerepo=livna-i386,base-i386 mplayerplug-in.i386



Wireless Card
There is no Linux wireless driver for Ferrari 3400. The alternative is to use ndiswrapper package, so that I can use the Windows driver.


yum -y install ndiswrapper


You can use lspci to find out the wireless card of your system. My Ferrari 3400 uses Broadcom Corporation BCM4306 card. You can download the 64 bit driver from here. Unzip the driver and install it.


ndiswrapper -i netbc564.inf


You can use `ndiswrapper -l` to see if the driver got installed correctly. The next step is to modify the file /etc/modprobe.conf and add a line to it.


alias wlan0 ndiswrapper


Now, it's time to rebuild the modules.dep file and load the kernel module.


depmod -a
modprobe ndiswrapper


The wireless router I am using uses WPA. I need to setup wpa_supplicant in order to enable WPA. The configuration file for wpa_supplicant is /etc/wpa_supplicant/wpa_supplicant.conf. Here is an example for a network using WPA-PSK.


ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=wheel

network={
ssid="SSIDNAME"
key_mgmt=WPA-PSK
psk="your_password"
}


You might want to check your /etc/sysconfig/wpa_supplicant file for interface and driver. Here is one example.


INTERFACES="-iwlan0"
DRIVERS="-Dndiswrapper"


Start the wpa_supplicant service by using this command.


service wpa_supplicant start


The last step is to use system-config-network-gui to add a wlan0 device to your system and activate it. If you run into problem while activate the wlan0 device. You might want to run wpa_supplicant in command line to debug it.


wpa_supplicant -i wlan0 -D ndiswrapper -c /etc/wpa_supplicant/wpa_supplicant -dd


Active Directory Integration
To integrate my laptop with our Active Directory, I use system-config-authentication .

Check the box under Winbind to enable Winbind support for user information. Click on "Configure Winbind..." to bring up Winbind Settings dialog. Enter the following info.

Winbind Domain: DOMAIN-NAME
Security Model: ads
Winbind ADS Realm: DOMAIN-NAME.COM
Winbind Domain Controllers: dc.domain-name.com
Template Shell: /bin/bash

The default Template Shell is /bin/false which will disable users' login. Click on "Join Domain" button to join the domain. Click on "OK" will bring you back to Authentication dialog. Click on Authentication tab and check the box under Winbind to enable authendication. Now you can pull user info from Active Directory and your machine can also authenticate with Active Directory. However, the system won't create user's home directory for you. You need to modify gdm and login files in /etc/pam.d directory, so that a home directory will be created automatically whenever a new user tries to logon. Here is an example of pam file.


#%PAM-1.0
auth required pam_env.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
session include system-auth
session required pam_loginuid.so
session optional pam_console.so
session required pam_mkhomedir.so skel=/etc/skel umask=0022


Here is an example of login file.


#%PAM-1.0
auth required pam_securetty.so
auth include system-auth
account required pam_nologin.so
account include system-auth
password include system-auth
# pam_selinux.so close should be the first session rule
session required pam_selinux.so close
session include system-auth
session required pam_loginuid.so
session optional pam_console.so
session required pam_mkhomedir.so umask=0022
# pam_selinux.so open should be the last session rule
session required pam_selinux.so open


Reboot the machine and you can login using Active Directory credential. Remember to enter the user name in this format: DOMAIN-NAME\username . Also, if you need to use ssh to login, the syntax is:


ssh DOMAIN-NAME\\username@host.domain-name.com


Remote Administration
There are two applications that I use everyday to manage my network: remote desktop and vnc. To install them, type:


yum -y install rdesktop
yum -y install vnc


I usually run rdesktop with these options:


rdesktop -g 1024x768 -a 16 server.domain-name.com


This would connect the rdesktop client to server using a 1024x768 display with 16 bit color depth. The use of vnc is simpler.


vncviewer server2.domain-name.com


One thing about the vncviewer is that there is no menu for you to select on screen. You need to press "F8" to get the options.

[...to be continued]

3/20/2006

Setup RAID on Dimension 8400

We have a Dimension 8400 that came with a single SATA drive. Recently, we retired some IDE drives that we want to add to the system. These IDE drives are kinda old, so the reliability is a concern. If we can set these IDE drives up as RAID 1 (Mirror), it would give us some kind of protection if one of the drives fails. Dimension 8400 has an onboard RAID controller for SATA drives. However, the spare drives are all IDE. The solution is to buy SATA to IDE adapter to conver these IDE drives to SATA drives. When buying the SATA to IDE adapters, make sure you have the Y-split power connectors and SATA cables. Some adapters don't include these, and you might need to purchase them separately.

Once we got all pieces together, we ran into another problem. During boot, we didn't get to the screen where you can setup RAID volumes. It turns out, you need to go to the bios setting to enable it. The option you need is Drives->SATA Operation. Select the third option "RAID on". Save the bios setting and boot again. You'll see the RAID configuration screen right after the Dell logo. Press "Ctrl-I" immediately to setup the RAID volumes.

3/02/2006

WQL and Path

I am playing around with WQL today. For a longest time, I couldn't get this query to work.


Set colFiles = objWMIService.ExecQuery ("SELECT * FROM CIM_DataFile" & _
" WHERE Drive = 'c:' AND Extension = 'mdb' And Path = '\windows\' ")


Have you noticed anything wrong with the query? It's the Path! I found that you need to use double back slash instead of single back slash. So, the correct Query should be like this.


Set colFiles = objWMIService.ExecQuery ("SELECT * FROM CIM_DataFile" & _
" WHERE Drive = 'c:' AND Extension = 'mdb' And Path = '\\windows\\' ")


Also, I found that if you have "!=" in your query, the query runs very very slowly.

2/28/2006

Create a Hyperlink in Excel Spreadsheet Using VBScript

Someone at the newsgroup asked this question. This is the VBScript that I wrote to accomplish this.


Dim objExcel
Set objExcel = WScript.CreateObject("Excel.Application")

objExcel.Visible = TRUE
objExcel.Workbooks.Open "C:\bin\test.xls"
objExcel.Workbooks(1).Activate
objExcel.Workbooks(1).Worksheets(1).Range("A1").Select

Dim sLinkAddress
sLinkAddress = "http://www.google.com"

objExcel.Workbooks(1).Worksheets(1).Hyperlinks.Add _
objExcel.Selection, sLinkAddress
objExcel.Workbooks(1).SaveAs "C:\bin\test.xls"
objExcel.Quit

set objExcel = nothing

2/09/2006

Popular Web 2.0 Colors

Here is the list of the popular colors for web 2.0.

del.icio.us #0000FE
WordPress #306996
wink #387FD1
Flock #439CF0
SocialText #73A395
Technorati #4DBB00
Odeo #FF42A6
flickr #FE0094

2/04/2006

XviD Files Crash Windows Explorer

I copied some XviD encoded AVI files to a machine without XviD codec installed. Whenever I open the folder containing these files. The Windows Explorer crashes with the following event created in the Application log.


Event Type: Information
Event Source: Winlogon
Event Category: None
Event ID: 1002
Date: 2/2/2006
Time: 12:27:02 PM
User: N/A
Computer: MyComputer
Description:
The shell stopped unexpectedly and Explorer.exe was restarted.

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.


I was puzzled by this behaviour at first. The default application to handle AVI files is Windows Media Player. Oh! I forgot to mention that the machine is running Windows XP Professional SP2 with all the updates. The Windows Media Player version is 9. My first take is to upgrade the Media Player to 10. However, Windows Explorer still crashes after the Media Player upgrade. My second take is to install the XviD codec. After I installed the XviD codec, the crashes stopped. I am able to browse those files using Windows Explorer without crashing.

1/23/2006

Intel iMac and Samsung ML-2551N

We usually use the IP Printer option in Mac OS X when setting up network printer in our environment. We got this shiny iMac with Intel Dual Core processor the other day and had tons of troubles setting up a Samsung ML-2551N network printer.

First, we tried IP Printer with either Samsung driver or the generice driver. Both didn't work. After 20 minutes or so, I was about to give up. I decided to try Default Browser in Printer Setup. The ML-2551N showed up as two entries. One with Bonjour connection and the other with Appletalk connection. If I set up the printer using the Bonjour connection, it still doesn't work. Finally, I set up the printer using the Appletalk connection and it works perfectly afterward.

7/13/2005

Silent Install for Firefox and Thunderbird

"Firefox Setup 1.0.5.exe" -ms
"Thunderbird Setup 1.0.2.exe" -ms

5/10/2005

VB Script wrapper function for regular expression.


Function Found(strTarget, strPattern)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = strPattern
regEx.IgnoreCase = False
Found = regEx.Test(strTarget)
set regEx = Nothing
End Function

WMI script to find files last accessed on a certain date.


dtDate = "5/2/2005"
strSearchFolder = "C:\Windows"

Set objFSO = CreateObject("Scripting.FileSystemObject")
WScript.Echo "File(s) last accessed on: " & dtDate & " in: " & strSearchFolder
EnumAndCheckFiles objFSO.GetFolder(strSearchFolder), dtDate

Sub EnumAndCheckFiles(objFolder, dtDate)
Set objFiles = objFolder.Files
For Each objFile in objFiles
CheckFile objFile, dtDate
Next
For Each objSubfolder in objFolder.SubFolders
EnumAndCheckFiles objSubfolder, dtDate
Next
End Sub

Sub CheckFile(objFile, dtDate)
If DateDiff("d", objFile.DateLastAccessed, dtDate) = 0 Then
WScript.Echo objFile.Path
End if
End Sub



5/02/2005

Mac OS 10.4 Tiger Stealth Mode

The new stealth mode in Tiger is just this ipfw command

ipfw -q add 20000 deny icmp from any to me in icmptypes 8

4/25/2005

Free Windows Rootkits Detection Tools

RootkitRevealer
http://www.sysinternals.com/ntw2k/freeware/rootkitreveal.shtml

4/08/2005

WMI and Day Light saving time

If you use the "Bias" property of Win32_TimeZone to convert time to UTC time, remember to check "DayLightInEffect" property of Win32_ComputerSystem to determine if you need to adjust the "Bias" according to Day Light saving time.

3/30/2005

Use Computer Management to manage remote computer.

compmgmt.msc /computer:remote_computer

2/08/2005

Batch file to list all the methods in WMI command line tool (wmic).


@ECHO OFF

FOR /F %%a IN ('wmic alias list instance ^| FIND /v "Friend" ') DO (
FOR /F %%b IN ('wmic %%a /? ^| FIND /i "%%a CALL"' ) DO (
ECHO wmic %%b CALL /?
wmic %%b CALL /?
)
)

10/28/2004

Disable Windows XP SP2 Firewall

Windows XP Service Pack 2 enables firewall by default. To prevent firewall enabled after installation, apply the registry setting BEFORE install SP2.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile]
"EnableFirewall"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile]
"EnableFirewall"=dword:00000000

10/19/2004

To set FireFox as your default browser for Mac OS 10.3,

  1. Open Safari. Yes, this is strange but you have to change it in Safari.
  2. Click Safari -> Preferences...
  3. Select FireFox in the "Default Web Browser" listbox.

9/10/2004

Hide your Windows computer from Network Neighborhood

Use the following command.

net config server /hidden:yes