PDA

View Full Version : ERROR HANDLING: Redirect REGEDIT pop-up errors (WNT)



pzgt92
03-26-2002, 10:51 PM
I'm using "regedit /s <MyRegFile.reg>" at the DOS command prompt. Is there a way to redirect the errors I obtain from regedit so they don't appear in a pop-up box? Has anyone tried anything similar?

POBrien
03-27-2002, 06:11 PM
what do you mean by errors made? If an error message appears then the reg file wasn't merged.

An error would most likely mean that the reg file format isn't correct.

Can you please explain the exact circumstances in detail so we can understand your needs?

Pat

pzgt92
03-27-2002, 09:15 PM
Pat, I will try to give a better understanding of what I am trying to accomplish...
I am currently using the CreateProcess function to install a list of REG files from within my Visual C++ program. The message being sent to the system reads: "regedit /s MyRegFile.reg>". On occaision I get errors. In most cases the REG file format is ok; I’m thinking that the errors are due to multiple PCs trying to merge the same file at the same time (over a network) and that the file may become locked to other processes while it is being used.
I would like to add some error handling within my program to intercept the error without displaying a pop-up box, as a keyboard is not always readily available. So far I've attempted to redirect the stderr/stdout to a file using cmd line params (i.e. 1> and 2>) but didn’t have any luck with regedit. Also tried creating a child process with redirected output by setting dwFlags to STARTF_USESTDHANDLES. The only MSDN functions I’ve found allow adding only one key at a time, not the entire file which makes things difficult.

POBrien
03-28-2002, 12:09 AM
Does your program's internal code execute external reg files on a hard drive?

I don't know anything about C ++

However, in VB 6.0 I use the

on error resume next

line between certain lines of code that error out while the program runs in NTx but not 9x.

Im sure C++ must have something similar.

I'd check planetsourcecode.com for some error handling code.


I don't think it's related to multiple simultaneous reads of the reg file (from the stations) because thats the default behavior when running a reg file in a login script.

I know what you mean though... It would be nice to drill down to the root cause.

Have you tried to isolate the error times. ie: it happens on a particular station or when a particular user is logged in.

Maybe a permissions issue and the subkey/value or value data is affected?

Can you post back with the exact error message?

Pat

pzgt92
04-02-2002, 04:13 PM
Yes, CreateProcess will execute the external reg file(s) on a hard drive. I’ve used the try/catch statement inside my VC++ program but that will only catch errors returned from the CreateProcess function, which creates the new process.

try
{
CreateProcess( <new process> )
}
catch(...) // catch all errors in the above
{
// Do something
}

The CreateProcess doesn’t error out even if regedit fails to merge the file. Can on error resume next command be notified of error from other applications? I haven’t found anything that notifies us of system or application errors.

Problem happens intermittently and independent of user and station.

The error message reads as follows, waiting for the OK button to be pressed:
Cannot import <some reg file name>
Error writing to the registry
also received:
Cannot import <some reg file name>
Error reading the file. There may be a disk error or the file may be corrupt

POBrien
04-02-2002, 04:34 PM
Im wondering if it's related to the contents of the reg file itself.

Meaning...

If there are entries listed for the

[HKEY_USERS\.DEFAULT branch

NT may not allow the merge.

Pat

pzgt92
04-04-2002, 05:54 PM
Pat,
Thank you for your assistance with this issue. I made the decision to stop looking for the cause and error redirction...didn't have any luck in any of these areas after trying for a long time.

I was howerver successfull in looping through the window handle list and check to see if the PID of the window matches the PID from my Createprocess function. Since I'm using a silent merge, the only possibility of a regedit window with my PID is if an error occured. I can then kill the regedit process to get rid of the pop-up and then handle the error internally to my program.

Again, thank you for the time and effort you put in to help me.

POBrien
04-04-2002, 05:58 PM
You're welcome. I'm glad you came up with a variation.

I thought the Hkey_Users issue was it as I received the same error messages myself in the past.

Pat