Friday, March 30, 2007

Disable System Beep

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Beep]
"Start"=dword:00000004

Print Server Migration

Dim strComputer, sPrinterPath, sPrinterName, sOldPrntSrv, sNewPrntSrv

sOldPrntSrv = "OldPrintServer"
sNewPrntSrv = "NewPrintServer"

Set WshNetwork = CreateObject("WScript.Network")

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery("Select * from Win32_Printer")

For Each objPrinter in colInstalledPrinters
sPrinterPath = UCase(objPrinter.Name)
Length = Len(sPrinterPath)
sPrinterName = Right(sPrinterPath,Length - InStrRev(sPrinterPath,"\"))

If Instr(sPrinterPath, sNewPrntSrv) Then
If Length > 27 Then
WshNetwork.RemovePrinterConnection sPrinterPath
WshNetwork.AddWindowsPrinterConnection UCase("\\" & sNewPrntSrv & "\" & sPrinterName)
End If
End If

If Instr(sPrinterPath, sOldPrntSrv) Then
WshNetwork.RemovePrinterConnection sPrinterPath
WshNetwork.AddWindowsPrinterConnection UCase("\\" & sNewPrntSrv & "\" & sPrinterName)
End If

Next

VBScript : IfMember and MapNetworkDrive

Set wshnetwork = CreateObject("Wscript.Network")
Set fso = CreateObject("Scripting.FileSystemObject")

Private Function IsMember(groupName)

Set wshnetwork = CreateObject("WScript.Network")
domain = wshnetwork.UserDomain
user = wshnetwork.UserName
flgIsMember = false
Set userObj = GetObject("WinNT://" & domain & "/" & user & ",user")
For Each grp In userObj.Groups
If grp.Name = groupName Then
flgIsMember = true
Exit For
End If
Next
IsMember = flgIsMember
Set userObj = nothing
Set wshnetwork = nothing

End Function

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objAdapter In colAdapters
If Not IsNull(objAdapter.IPAddress) Then
For i = LBound(objAdapter.IPAddress) To UBound(objAdapter.IPAddress)
address = objAdapter.IPAddress(i)
VLANX = instr(address, "10.14.3.")
If VLANX = 1 Then
IFM = IsMember("GG-VLS-SEN-CAO")
Set wshnetwork = CreateObject("Wscript.Network")
user = wshnetwork.UserName
If IFM = true then
If fso.folderexists("X:\")=False Then
WshNetwork.MapNetworkDrive "X:", "\\Paris\" & user
Else
WshNetwork.RemoveNetworkDrive "X:"
WshNetwork.MapNetworkDrive "X:", "\\Paris\" & user
End If
End If
End If
Next
End If
Next

M1 = IsMember("GG-HelpDesk")
Set wshnetwork = CreateObject("Wscript.Network")
user = wshnetwork.UserName
If M1 = true then
If fso.folderexists("R:\")=False Then
WshNetwork.MapNetworkDrive "R:", "\\Tokyo\HelpDesk"
Else
WshNetwork.RemoveNetworkDrive "R:"
WshNetwork.MapNetworkDrive "R:", "\\Tokyo\HelpDesk"
End If
End If

M2 = IsMember("GG-Project")
Set wshnetwork = CreateObject("Wscript.Network")
user = wshnetwork.UserName
If M2 = true then
If fso.folderexists("F:\")=False Then
WshNetwork.MapNetworkDrive "F:", "\\NewYork\project"
Else
WshNetwork.RemoveNetworkDrive "F:"
WshNetwork.MapNetworkDrive "F:", "\\NewYork\project"
End If
If fso.folderexists("M:\")=False Then
WshNetwork.MapNetworkDrive "M:", "\\NewYork\report"
Else
WshNetwork.RemoveNetworkDrive "M:"
WshNetwork.MapNetworkDrive "M:", "\\NewYork\report"
End If
End If

M3 = IsMember("GG-HR")
Set wshnetwork = CreateObject("Wscript.Network")
user = wshnetwork.UserName
If M3 = true then
If fso.folderexists("R:\")=False Then
WshNetwork.MapNetworkDrive "R:", "\\Hamilton\HR"
Else
WshNetwork.RemoveNetworkDrive "R:"
WshNetwork.MapNetworkDrive "R:", "\\Hamilton\HR"
End If
If fso.folderexists("X:\")=False Then
WshNetwork.MapNetworkDrive "X:", "\\vls-sen-s04\CV"
Else
WshNetwork.RemoveNetworkDrive "X:"
WshNetwork.MapNetworkDrive "X:", "\\vls-sen-s04\CV"
End If
End If

M4 = IsMember("GG-Director")
Set wshnetwork = CreateObject("Wscript.Network")
user = wshnetwork.UserName
If M4 = true then
If fso.folderexists("H:\")=False Then
WshNetwork.MapNetworkDrive "H:", "\\NewYork\Director"
Else
WshNetwork.RemoveNetworkDrive "H:"
WshNetwork.MapNetworkDrive "H:", "\\NewYork\Director"
End If
End If

Windows XP : Very Slow to Open a Session

If Windows XP with MUI Language Pack very slow (more than 10 minutes) to open a session, it's because of difference between the following value. Set all these MultiUILanguageId and MUILanguagePending the same value to resolve this problem.


Windows Registry Editor Version 5.00

[HKEY_USERS\S-1-5-18\Control Panel\Desktop]
"MultiUILanguageId"="0000040c"
"MUILanguagePending"="0000040c"

[HKEY_USERS\S-1-5-19\Control Panel\Desktop]
"MultiUILanguageId"="0000040c"
"MUILanguagePending"="0000040c"

[HKEY_USERS\S-1-5-20\Control Panel\Desktop]
"MultiUILanguageId"="0000040c"
"MUILanguagePending"="0000040c"

How to use cusrmgr.exe

CUsrMgr Ver 1.0 Jan98 by G.Zanzen (c) MCS Central Europe
Sets a random password to a user
usage: -u UserName [-m \\MachineName] \\ default LocalMachine
Resetting Password Function
-p Set to a random password
-P xxx Sets password to xxx
User Functions
-r xxx Renames user to xxx
-d xxx deletes user xxx
Group Functions
-rlg xxx yyy Renames local group xxx to yyy
-rgg xxx yyy Renames global group xxx to yyy
-alg xxx Add user (-u UserName) to local group xxx
-agg xxx Add user (-u UserName) to global group xxx
-dlg xxx deletes user (-u UserName) from local group xxx
-dgg xxx deletes user (-u UserName) from global group xxx
SetProperties Functions
-c xxx sets Comment to xxx
-f xxx sets Full Name to xxx
-U xxx sets UserProfile to xxx
-n xxx sets LogonScript to xxx
-h xxx sets HomeDir to xxx

-H x sets HomeDirDrive to x

+s xxxx sets property xxxx
-s xxxx resets property xxxx
where xxxx can be any of the following properties:
MustChangePassword
CanNotChangePassword
PasswordNeverExpires
AccountDisabled
AccountLockout
RASUser
returns 0 on success

Add User/Group to Localgroup with cusrmgr.exe

copy \\vls-sen-sdc01\netlogon\cusrmgr.exe C:\

C:

REM Add User Mayer Password:P@sSwoRd
net user Mayer P@sSwoRd /add

REM Add User Mayer to Localgroup Administrators
net localgroup administrators Mayer /add

REM Add Group "Domain\GroupName" to Localgroup Administrators
net localgroup administrators Domain\GroupName /add

REM Rename User Administrator to NewAdmin Password:NewPass
cusrmgr -u administrator -r NewAdmin -P NewPass

REM Set User Mayer's password to NewP@sSwoRd
cusrmgr -u Mayer -P NewP@sSwoRd

REM Add User Mayer to Localgroup Administrators
cusrmgr -u Mayer -alg administrators

del C:\cusrmgr.exe
net time \\vls-sen-sdc01 /set /y

Install/Uninstall MSN

Here are the command line switches to install MSN 7.x silently, agreeing to the EULA question, not having the toolbar installed, nor the MSN search engine, and setting the home page to null.


MsnMsgs.msi IAGREE="Yes" ADDEXPLORERTOOLBAR="" SETSEARCHENGINE="" SETHOMEPAGE="" /qb-


To uninstall MSN Messenger v7.0 use this :

msiexec /qn /x {ABEB838C-A1A7-4C5D-B7E1-8B4314600816}


Install MSN 7.5

Install_MSN_Messenger.exe /C:"msiexec.exe /i MsnMsgs.msi /qb-! IAGREE='' ADDEXPLORERTOOLBAR='' SETSEARCHENGINE='' SETHOMEPAGE=''"


Disable MSN Messenger from AutoUpdating :

Hive:HKEY_LOCAL_MACHINE
Key: Software\Policies\Microsoft\Messenger\Client
Name: PreventAutoUpdate
Type: REG_DWORD
Value: 1

Thursday, March 29, 2007

Configuring Network Script

If you don't have any network cards, you are most likely not going to create any configuration files relating to network cards. If that is the case, you must remove the network symlinks from all the runlevel directories (/etc/rc.d/rc*.d)

Configuring default gateway
If you're on a network you may need to setup the default gateway for this machine. This is done by adding the proper values to the /etc/sysconfig/network file by running the following:


cat >> /etc/sysconfig/network << "EOF"
GATEWAY=192.168.1.2
GATEWAY_IF=eth0
EOF


The values for GATEWAY and GATEWAY_IF need to be changed to match your network setup. GATEWAY contains the IP address of the default gateway, and GATEWAY_IF contains the network interface through which the default gateway can be reached.

Creating network interface configuration files
Which interfaces are brought up and down by the network script depends on the files in the /etc/sysconfig/network-devices directory. This directory should contain files in the form of ifconfig.xyz, where xyz is a network interface name (such as eth0 or eth0:1)
If you decide to rename or move this /etc/sysconfig/network-devices directory, make sure you update the /etc/sysconfig/rc file as well and update the network_devices by providing it with the new path.
The following command creates a sample ifconfig.eth0 file:

cat > /etc/sysconfig/network-devices/ifconfig.eth0 << "EOF"
ONBOOT=yes
IP=192.168.1.1
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
EOF


Of course, the values of those variables have to be changed in every file to match the proper setup. If the ONBOOT variable is set to yes, the network script will bring it up during boot up of the system. If set to anything else but yes it will be ignored by the network script and thus not brought up.

 
visitors since March 26 2007
©2007