Posted by member 111 on 2006-02-16 11:33:40 link

Actually it is possible to switch the shell using WSH script instead of an utility, something like this (lsportable.vbs):

rem =========================================
rem LiteStep portable v1.0
rem
rem Requirements:
rem WinXP or later
rem
rem Copyright(c) Sergey Gagarin a.k.a. Seg@
rem Ekaterinburg, Feb 2006
rem =========================================

Option Explicit

' relative path to the ls executable on the flash drive
Const c_sLiteStepPath = "\LiteStep\litestep.exe"

' change this only if Explorer is not your default shell
' and you're replacing something like GeoShell or
' SuperPuperComputerClubShellWrittenByMikeIn1HourOnDelphi
Const c_sExplorer = "explorer.exe"

Dim objFS ' as Scripting.FileSystemObject
Dim objExec ' as WshScriptExec
Dim objWMIService ' as WMIService
Dim objProcess ' as ???
Dim colProcessList ' as Collection
Dim sDriveLetter ' as String
Dim objShell ' as WScript.Shell

' -------------------------------------------

'
' Set 'sShell' as shell for the current user
'
Sub SetShell(sShell)
Dim sDesktopProcess ' as String

objShell.RegWrite _
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\IniFileMapping\system.ini\boot\shell", _
"USR:Software\Microsoft\Windows NT\CurrentVersion\Winlogon", "REG_SZ"
objShell.RegWrite _
"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\WinLogon\shell", _
sShell, "REG_SZ"
If sShell = c_sExplorer Then
sDesktopProcess = "0"
Else
sDesktopProcess = "1"
End If
objShell.RegWrite _
"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DesktopProcess", _
sDesktopProcess, "REG_DWORD"
End Sub

' -------------------------------------------

' let's extract a letter of the logical disk where we're running on
Set objFS = CreateObject("Scripting.FileSystemObject")
sDriveLetter = objFS.GetDriveName(WScript.ScriptFullName)
If sDriveLetter = "" Then
' cannot determine the script's source file
WScript.Echo "Unexpected internal error"
WScript.Quit
End If
' check for existing LS.exe
If Not objFS.FileExists(sDriveLetter & c_sLiteStepPath) Then
WScript.Echo "LiteStep.exe not found. Contact Francis Gastellu for details"
WScript.Quit
End If
Set objFS = nothing

' -------------------------------------------

' set LiteStep as shell first
Set objShell = CreateObject("WScript.Shell")
SetShell sDriveLetter & c_sLiteStepPath

' -------------------------------------------

' kill the explorer
' the 'terminate' method is unavailable on Win2k, so...
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'explorer.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next

' execute litestep.exe
Set objExec = objShell.Exec(sDriveLetter & c_sLiteStepPath)

' -------------------------------------------
' you may remove the following lines
' if you need to release memory
' occupied by WSH
'
' remember that you need to set
' explorer as your shell manually
' -------------------------------------------

' wait until litestep.exe is terminated
Do While objExec.Status = 0
WScript.Sleep 1000
Loop

' set explorer to be your shell again
SetShell(c_sExplorer)
' run it!
objShell.Exec(c_sExplorer)

Set objShell = Nothing


no need to restart a machine
there is only one disadvantage - Windows wants to relaunch Explorer after termination, and it starts in the Desktop mode when LiteStep is running as a shell %)