WMI+VBS: how to get the domain name


Option Explicit
On Error Resume Next

Dim strComputer, objNetwork, objWMIService
Dim colItems, objItem

Set objNetwork = WScript.CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
WScript.Echo "Computer = " & strComputer

Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&strComputer&"\root\cimv2")

Set colItems = objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
For Each objItem in colItems
Wscript.Echo "Domain = " & objItem.domain
Next

There is also WMI FAQ on Microsoft site.

MS Word: replace spaces to non-breaking

To insert it manually, use Ctrl+Shift+Space


Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Normal")
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = "^s"
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute Replace:=wdReplaceAll

MS SQL & Sybase: recreate master database

Sybase:
before 12.5: buildmaster (bldmatr for NT)
buildmaster -d master_device -s size_in_2k_pages

12.5 and later: dataserver with some options (sqlsvr for NT)
dataserver -d master_device -b size -forcebuild -z page_size -Z size_of_master_db

MS SQL:

before MS 2005:
rebuildm utility (GUI)

MS SQL 2005:

  1. Start server in single-user mode (sqlserver.exe -m)
  2. setup.exe /qn INSTANCENAME=instance_name REINSTALL=SQL_Engine REBUILDDATABASE=1 SAPWD=new_SA_Password
  3. Restart server in normal mode

Check the default browser

The following section in registry should be checked:

HKEY_CLASSES_ROOT\http\shell\open\command
Key: (default)

Most (but not all) browsers check it to determine the current browser.


currentBrowser = RegistryGet("HKEY_CLASSES_ROOT","http\shell\open\command","")
MsgBox( currentBrowser )

Some browsers could create additional section HKEY_CLASSES_ROOT\http\shell\OpenWith\command, which helps to avoid the conflict with IE settings.

Oracle: password function

Find the name of the current password function


SELECT * FROM DBA_PROFILES WHERE RESOURCE_NAME='PASSWORD_VERIFY_FUNCTION';

Change the password function for the profile:


ALTER PROFILE &profile. LIMIT PASSWORD_VERIFY_FUNCTION &function_name.;

Example of the password function:


CREATE OR REPLACE FUNCTION dummy_func
(USERNAME VARCHAR2, PASSWORD VARCHAR2, OLD_PASSWORD VARCHAR2)
RETURN BOOLEAN IS
BEGIN
IF NLS_LOWER(password) = NLS_LOWER(username) THEN
raise_application_error(-20001, 'Password is the same as the username');
END IF;
RETURN(TRUE);
END;

Oracle: PERFSTAT.STATS$MUTEX_SLEEP_PK violated

There is a known problem with Oracle statspack report in 10g, which could cost You at least one lost statspack snapshot.

The following message is written into the alert log:


ORA-00001: unique constraint (PERFSTAT.STATS$MUTEX_SLEEP_PK) violated
ORA-06512: at “PERFSTAT.STATSPACK”, line 5264
ORA-06512: at “PERFSTAT.STATSPACK”, line 104
ORA-06512: at line 1

There is a Note 382993.1 in Metalink, which describes this bug.

The workaround is simple:

alter table perfstat.stats$mutex_sleep disable constraint STATS$MUTEX_SLEEP_PK;

create index perfstat.STATS$MUTEX_SLEEP_PK on
STATS$MUTEX_SLEEP(SNAP_ID,DBID,INSTANCE_NUMBER,MUTEX_TYPE,LOCATION);

… and check the Metalink for the news, if the bug was fixed.

[amazon-product]007222360X[/amazon-product]