DOS Box still appears even when bundle run as Hidden

  • 7010068
  • 27-Jan-2012
  • 30-Apr-2012

Environment

Novell ZENworks 11 Configuration Management Bundles
Novell ZENworks 10 Configuration Management Bundles

Situation

This can happen when Environment Variables are in use.

Example scenario:
  • Create c:\temp\test.bat on a test workstation containing a simple test line;  e.g. time /t >> c:\temp\flag.txt
  • ZCC > Bundles > New Bundle > Windows Bundle > Empty Bundle > Name=MyBundle
    • Define Additional > Actions > Launch > Add > Launch Executable
    • General > Command=c:\temp\test.bat (i.e.  as above)
    • Advanced > Run as Logged-in User, Display Mode Hidden
  • Associate the bundle and run it
Notice c:\temp\flag.txt gets created and a DOS box does not appear - this is as expected.
  • Now edit the bundle
    • General > Environment variables > Add > MyVar=Something
  • Rerun the bundle on the workstation.
Notice c:\temp\flag.txt gets created and a DOS box does appear - this is incorrect.

Resolution

Add environment variables at the bundle level rather than action level; e.g.
  • Navigate to <bundle> > Settings > System Variables > Add (under system variables)
See also KB 7009975 - Shell Programs create visible Command Prompt Window when set to run hidden - https://www.novell.com/support/search.do?searchString=7009975

Additional Information

This is a documented Microsoft issue: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.windowstyle.aspx (check notes under Remarks header).

Whilst investigating this, engineering did a test which showed that this is not specific to batch files and is seen with all executables.  For example, a sample program running outside of ZCM that creates the process (notepad.exe) with the following start info:

   myProcess.StartInfo.UseShellExecute = false
   myProcess.StartInfo.CreateNoWindow = true
   myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden

Even in this case, the notepad is visible, showing that the issue is with Microsoft.

The UseShellExecutable property should be set to false whenever environment variables defined in process start info are used.  If it is set to true, there is an exception saying - "The Process object must have the UseShellExecute property set to false in order to use environment variables".  When UseShellExecutable property is true, the properties set in the process start info are respected. If it is set to false, some of the properties might get ignored.  In short, to use Hidden, UseShellExecute should be true, but it cant be true in this case as environment variables are in use.  These are all Microsoft requirements.