web analytics

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 […]

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:

Start server in single-user mode (sqlserver.exe -m) setup.exe /qn INSTANCENAME=instance_name REINSTALL=SQL_Engine REBUILDDATABASE=1 […]

C++: change the cursor for one button only

// handle WM_SETCURSOR in button class BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT msg) {     ::SetCursor(m_hMyCursor);     return TRUE; }

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: logon trigger

Create the table to save logon information:

CREATE TABLE logonaudittable ( event VARCHAR2(10), sid NUMBER, serial# NUMBER, TIMESTAMP DATE, username VARCHAR2(30), osuserid VARCHAR2(30), machinename VARCHAR2(64) ); […]

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     […]

MS SQL: long running queries

select spid,cmd,status,loginame,open_tran,   datediff (s,last_batch,getdate()) as [Waittime (s)] from master..sysprocesses p where open_tran > 0            and spid > 50           and datediff (s,last_batch,getdate()) > 30           and exists ( select * from master..syslockinfo                            where req_spid=p.spid and rsc_type <>2)

Oracle: long running queries

col opname FOR a40 col units FOR a10 SELECT  sid ,opname ,sofar ,totalwork ,units ,elapsed_seconds ,time_remaining FROM v$session_longops WHERE sofar != totalwork;

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 […]