Friday, May 02, 2008

Microsoft Windows startup Registry Settings

INFO: Run, RunOnce, RunServices, RunServicesOnce and Startup:

I believe this is pretty much a bulk of the information set by Xteq X-Setup. For those who don't want to make the purchase for a very simple edit, the following is the except from the Microsoft KB article

General order of loading:

  1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
  2. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices
  3. <Logon Prompt>
  4. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce Not supported in NT 3.51 and ignored by XP and 2000 in safe mode
  5. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
  6. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
  7. StartUp Folder
  8. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce Not supported in NT 3.51 and ignored by XP and 2000 in safe mode


However,
With the exception of the HKEY_LOCAL_MACHINE\...\RunOnce key, all keys and their entries are loaded asynchronously. Therefore, all entries in the RunServices and RunServicesOnce keys can potentially run at the same time.

Entries in the HKEY_LOCAL_MACHINE\...\RunOnce key are loaded synchronously in an undefined order.

Because the HKEY_LOCAL_MACHINE\...\RunOnce key is loaded synchronously, all of its entries must finish loading before the HKEY_LOCAL_MACHINE\...\Run, HKEY_CURRENT_USER\...\Run, HKEY_CURRENT_USER\...\RunOnce, and Startup Folder entries can be loaded.

Labels: , ,

Friday, April 11, 2008

WMIC service cheat sheet.

Microsoft's documentation is thorough, but I got a lot more out of the above link.

Labels:

Thursday, April 10, 2008

Time since last boot (Windows, VBScript)

I don't remember where I found this, I was just happy to find code that did this.

 strComputer = "." ' Local computer 
set objWMIDateTime = CreateObject("WbemScripting.SWbemDateTime")
set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
set colOS = objWMI.InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
objWMIDateTime.Value = objOS.LastBootUpTime
Wscript.Echo "Last Boot Up Time: " & objWMIDateTime.GetVarDate & vbcrlf & _
"Time Since Last Boot: " & TimeSpan(objWMIDateTime.GetVarDate,Now) & _
" (hh:mm:ss)"
next

Function TimeSpan(dt1, dt2)
' Function to display the difference between
' 2 dates in hh:mm:ss format
If (isDate(dt1) And IsDate(dt2)) = false Then
TimeSpan = "00:00:00"
Exit Function
End If

seconds = Abs(DateDiff("S", dt1, dt2))
minutes = seconds \ 60
hours = minutes \ 60
minutes = minutes mod 60
seconds = seconds mod 60

if len(hours) = 1 then hours = "0" & hours

TimeSpan = hours & ":" & _
RIGHT("00" & minutes, 2) & ":" & _
RIGHT("00" & seconds, 2)
End Function

Labels:

Thursday, March 27, 2008

Getting size estimates for tables in SQL SERVER 2000


-- SQL Server tables and row counts

declare tables_cursor cursor for
select name from sysobjects where xtype='U'
declare @table_name sysname

open tables_cursor
fetch next from tables_cursor INTO @table_name

while @@fetch_status = 0
begin
exec sp_spaceused @table_name
fetch next from tables_cursor INTO @table_name
end
close tables_cursor
deallocate tables_cursor

Tuesday, March 25, 2008

Restoredb.bat

Using osql and trusted connection for SQL Server 2000.


@echo off

if {%2}=={} (
call :Usage
goto :EOF
)
net stop mssqlserver
net start mssqlserver
osql -E -d master -Q "restore database
%1 from disk='%2' with replace"

goto :EOF
::Subroutine area

:Usage
@echo Syntax: call restoredb.bat DatabaseName
FullDatabaseBackupPath


goto :EOF

Friday, March 07, 2008

"Playtime" project: Porting Didiwiki to C#.NET

I'm hoping to find time to throw at least a quick port of DidiWiki to C#.NET together.

Reference 1: Creating your own Web Server using C# - This article is from 2001, so there might be a significantly better way of doing things.

Update: This CodeGuru page looks like a more original version of the same page.

Reference 2: Didiwiki Source Code that I've saved off. Original maintainer is no longer maintaining.

Labels: , ,

Saturday, March 01, 2008

Importing a runningahead log.xml into SQL Server 2005 using OPENXML

I don't currently have a work-based use for 2005, so I thought I'd use the only readily available collection of data that I have at my disposal... my running log. This is an export file from RunningAhead.com. I don't think I'm completely loading the XML data yet, and I don't have database tables to load to yet, either. However, this is my implementation of some OPENXML examples.


DECLARE @hdoc int
DECLARE @xmlDoc XML
SET @xmlDoc = (
  SELECT * FROM OPENROWSET (
    BULK 'C:\projects\runningahead\log.1.321C02\log.xml', SINGLE_CLOB
  ) AS xmlData
)
SELECT @xmlDoc

EXEC sp_xml_preparedocument @hdoc OUTPUT, @xmlDoc

SELECT * FROM
OPENXML(@hdoc, '/RunningAHEADLog/CourseCollection/Course', 2)
WITH
(
        ID varchar(32),
        Name varchar(255) ,
        Surface varchar(255),
        City varchar(255),
        State char(3),
        Notes varchar(255)
)

SELECT * FROM
OPENXML(@hdoc, '/RunningAHEADLog/EquipmentCollection/Shoe', 2)
WITH
(

        ID varchar(32),
        Make varchar(255) ,
        Model varchar(255),
        Serial char(20),
        InitDistance decimal(7,2),
        PurchaseDate datetime,
        Retired char(3),
        Size char(10),
        SizeSystem char(40)
)

SELECT * FROM
OPENXML(@hdoc, '/RunningAHEADLog/EventCollection/Run', 2)
WITH
(
        ID char(32),
        Date datetime,
        Time datetime,
        Type char(15),
        Weight decimal(4,1),
        WeightUnit char(12),
        AvgHR tinyint,
        MaxHR tinyint,
        Quality tinyint,
        Effort tinyint,
        CourseID char(32),
        Distance decimal(8,2),
        DistanceUnit char(12),
        Duration char(20)
)


EXEC sp_xml_removedocument @hdoc

Labels: ,