Jump to content

Recommended Posts

Posted

In my attempts to get ERD Commander tools to work within WinPE, I resorted to writing my own VBS script that will detect the local install of windows and pass these detail on to the ERD tool.

Here it is:

Dim WSHShell, FSO, dc, d, objArgs

Set objArgs = Wscript.Arguments
Set WSHShell = WScript.CreateObject("WScript.Shell")
set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Set dc = FSO.Drives

if Not FSO.FileExists(objArgs(0)) then
Wscript.Echo "Usage: " & Chr(13) & "    erdlogon.vbs cmdline [TargetRoot] " & Chr(13) & Chr(13) _
 & "To execute override detected Target Root, specify the location of" & Chr(13) _
 & "the Windows folder in place of TargetRoot."
WScript.Quit(0)
end if

if objArgs.count = 2 then

if FSO.FolderExists(objArgs(1)) then
 WSHShell.Environment("Process").item("target_root") = objArgs(1)
end if

else

For Each d in dc

 if d.DriveType = 2 then

 if FSO.FileExists(d.Path & "\WINNT\system32\config\system") then
   if FSO.FileExists(d.Path & "\WINNT\system32\config\sam") then
   if FSO.FileExists(d.Path & "\WINNT\system32\config\default") then
     if FSO.FileExists(d.Path & "\WINNT\system32\config\software") then
     WSHShell.Environment("Process").item("target_root") = d.Path & "\WINNT"
     Exit For
     end if
   end if
   end if

 elseif FSO.FileExists(d.Path & "\WINDOWS\system32\config\system") then
   if FSO.FileExists(d.Path & "\WINDOWS\system32\config\sam") then
   if FSO.FileExists(d.Path & "\WINDOWS\system32\config\default") then
     if FSO.FileExists(d.Path & "\WINDOWS\system32\config\software") then
     WSHShell.Environment("Process").item("target_root") = d.Path & "\WINDOWS"
     Exit For
     end if
   end if
   end if
 end if

 end if

Next

end if

WshShell.Exec objArgs(0)

Set WSHShell = Nothing
Set FSO = Nothing
WScript.Quit(0)

If anyone has any suggested improvements, just shout.

BTW, it needs WSH support to be installed for it to run. I can help with this if anyone is having problems.


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...