Wednesday, August 31, 2005

Copy User Profile

I'm trying to copy a user profile but the Copy To button is grayed
out in the dialog box in the System Control Panel applet. How can I
access this functionality?

A. The grayed out Copy To button usually occurs when you try to copy a
profile that has been used since the computer has been started. Reboot the
computer and don't log on as the profile you're trying to copy. The Copy To
button should now be available. Also remember that you can't copy the
profile you're currently logged on as.

How can I set the default domain user profile?

Most people are aware that you can set the default base profile on a per-
workstation basis by replacing the "C:\Documents and Settings\Default User"
folder on each local workstation. However, instead of performing this action
on every workstation, you can specify a domainwide default profile. To do
so, you need to save the required profile to the domain's Netlogon folder as
name "Default User" by performing the following steps:
1. Create a profile that you want to use as the default profile for all
new users and log off as the user.
2. Log on to the workstation as a domain administrator.
3. Start the System Control Panel applet (Start, Settings, Control Panel,
System).
4. Select the Advanced tab.
5. Click Settings in the User Profiles section of the tab.
6. Select the profile you created in the first step and click Copy To.
7. In the "Copy profile to" field, enter a location of <domain
controller>\netlogon\default user. In the "Permitted to use" field, click
Change and set to Everyone, as the figure at
http://list.windowsitpro.com/t?ctl=1218F:24641
shows. Click OK.
8. Click OK to the User Profiles dialog box, then click OK to the System
Properties dialog box.

When a new user logs on to a workstation for the first time, he or she will
now have a profile based on the default profile stored on the Netlogon
share. However, because end users can easily change these default profile
settings, you'll typically want to use Group Policy instead of this method
to set the mandatory configuration options. Group Policy settings will
override attempts by the user to modify the profile settings.

WMI Mac address

Q. How can I use Windows Management Instrumentation (WMI) to enumerate MAC
addresses on a machine?

A. You can enumerate a machine's list of network adapters and find the
associated MAC address. The following sample code, which you can
download at
http://list.windowsitpro.com/t?ctl=12191:24641 , prints out
the network adapter name and the MAC address. Because of space limitations,
some lines wrap to two lines.

Dim objNetworkAdapters, objAdapter, objWMI

Set objWMI = Nothing
Set objWMI = GetObject("winmgmts:")

' Get a list of IP-enabled adapters.
Set objNetworkAdapters = objWMI.ExecQuery("select * from " & _
"Win32_NetworkAdapterConfiguration where IPEnabled = 1")

For Each objAdapter In objNetworkAdapters
wscript.echo "Network adapter: " & objAdapter.Caption & " has MAC " & _
"address " & objAdapter.MacAddress
Next

Here's a sample execution output showing two adapters on the machine:

D:\temp>cscript getmac.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Network adapter: [00000009] Broadcom 570x Gigabit Integrated Controller has
MAC address 00:0F:1F:25:DC:76
Network adapter: [00000014] Intel(R) PRO/Wireless 2200BG Network Connection
has MAC address 00:0E:35:6E:2C:B4

Monday, August 29, 2005

Delphi - ForceDirectories

var sDir : string;

sDir := 'c:\apps\code\free';;

//if sDir path does not exist, create it!
if NOT DirectoryExists(sDir) then
ForceDirectories(sDir);