noonereallycares Posted September 4, 2004 Posted September 4, 2004 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, objArgsSet objArgs = Wscript.ArgumentsSet WSHShell = WScript.CreateObject("WScript.Shell")set FSO = WScript.CreateObject("Scripting.FileSystemObject")Set dc = FSO.Drivesif 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 ifif objArgs.count = 2 then if FSO.FolderExists(objArgs(1)) then WSHShell.Environment("Process").item("target_root") = objArgs(1) end ifelse 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 Nextend ifWshShell.Exec objArgs(0)Set WSHShell = NothingSet FSO = NothingWScript.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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now