Link to home
Start Free TrialLog in
Avatar of jknuce

asked on

Status "Open" for Reg.exe Load when launched using the WshShell Exec Method

I am loading a Win PE registry hive using a VBscript and the WshShell exec method. I am using the status property as a indicator to proceed. However, the status returned is always 0, even after the registry hive is loaded. Am I doing something wrong?
Option Explicit
Call ExecCmd("%comspec% /k reg.exe load HKLM\WIM_SOFTWARE ""C:\PE2-Image\mount\windows\system32\config\software""")

Sub ExecCmd(cmd)
  Dim objShell,objExec
  Set objShell = CreateObject("WScript.Shell")
  Set objExec = objShell.Exec(cmd)
	Do While objExec.Status = 0
		Wscript.echo "Process Still Open = " & objExec.Status
		wscript.Sleep 100
		Wscript.echo "Process Closed = " & objExec.Status
End Sub

Open in new window

Avatar of Darren Collins
Darren Collins
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jknuce


That appears to be it. I should have caught this, but it did not cross my mind because I was running another sample command (imagex /info), with the /k switch and it would close after reporting the information exepected. Thanks for solving my headache. You deserve all points and more. Thanks again.
You're welcome, thanks for the grade.  The other thing I was going to say was that I'm not sure you even to call reg.exe within a Cmd window:  Reg.exe is a program in its own right, so you may only just need to:
Call ExecCmd("reg.exe load HKLM\WIM_SOFTWARE ""C:\PE2-Image\mount\windows\system32\config\software""")

Open in new window