The version of GPMC that is included with Windows Server 2008 and later and that is also in the Remote Server Administration Tools (RSAT) are not causing this problem.
The error is shown and the event is logged by the Windows Hard Error Handler. You can modify the behavior of this handler:
124873 Disabling System Hard Error Message Dialog Boxes
http://support.microsoft.com/default.aspx?scid=kb;EN-US;124873
The basic approach is to set ErrorMode to 2 and back to 0 in a separate script host executable, like this:
reg add HKLM\System\CurrentControlSet\Control\Windows /v ErrorMode /t REG_DWORD /d 2 /f
call cscript BackupAllGPOs.wsf
reg add HKLM\System\CurrentControlSet\Control\Windows /v ErrorMode /t REG_DWORD /d 0 /f
If the script working with the GPMC objects is embedded in a bigger script and you can't have an "outer" script, you can set ErrorMode=2 directly in the script when you are working with the GPMC objects, and have the operating system set ErrorMode=0 with an event triggered task which you can configure with this command:
eventtriggers /create /TR "Set ErrorMode=0" /L System /T Information /SO "Application Popup" /EID 26 /TK "reg add HKLM\system\currentControlSet\control\windows /v ErrorMode /t REG_DWORD /d 0 /f" /RU ""
If the script is not running at Administrator Level or LocalSystem, it cannot write to the registry key where ErrorMode is located. To solve this problem, you can write a custom event in the script, and create a second event trigger consume it to set ErrorMode=2.
Examples for eventlogging:
http://msdn.microsoft.com/en-us/library/f9shkfdd(v=VS.80).aspx
http://support.microsoft.com/kb/301279
Note: To register the event source you need to run as administrator. Logging the event can be done as lower privilege account (e.g. Backup Operator).
Event triggers cannot be edited the same way as regular scheduled tasks. A limited set of options is available through the UI and SCHTASKS. When you do this, for some of the possible changes you lose the user the task is running under. You can reset the user the task is running under to LocalSystem using this script:
Dir "%windir%\Set ErrorMode*.job" >temp-Job-List.Txt
For /f "delims=§" %%f in (temp-Job-List.Txt) do schtasks /change /TN "%%~nf" /RU ""
Del temp-Job-List.Txt
“§” would be any character not used in the job names.