Ole help with ProcessWindowStyle.Minimized

Started by DirkM, September 28, 2015, 02:16:13 PM

Previous topic - Next topic

DirkM

Hello everybody,

I'm trying to execute a command but need to do something while it's running. I got my code working with the exception of hiding the CMD window while the exe is running. I found that objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized should do the trick but in WinBatch I get the following error: 3246: Ole Object: Object does not exist, or period used instead of comma.

Does anybody have an idea what I am missing?

Thanks,
Dirk

ObjectClrOption("use","System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
objProcess   = ObjectClrNew("System.Diagnostics.Process")
objProcess.StartInfo.UseShellExecute = ObjectType("BOOL", 1)
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized
objProcess.StartInfo.FileName = 'Notepad'
objProcess.StartInfo.Arguments = 'test.txt'
objProcess.Start()
objProcess.WaitForExit()
objProcess.Dispose()
Message ('','done')

td

There are numerous simpler ways to do this but to keep the task strictly within CLR hosting, you need the following:
Code (winbatch) Select
; Enumerations need to be instantiated.
ObjectClrOption("use","System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
enumProcStyles = ObjectClrNew( 'System.Diagnostics.ProcessWindowStyle' )

objProcess   = ObjectClrNew("System.Diagnostics.Process")
objProcess.StartInfo.UseShellExecute = ObjectType("BOOL", 1)

; Property typing is strictly enforced on StartInfo's WindowStyle property
; so you need to perform a type cast.
objProcess.StartInfo.WindowStyle = ObjectClrType('System.Diagnostics.ProcessWindowStyle', enumProcStyles.Minimized)
objProcess.StartInfo.FileName = 'Notepad'
objProcess.StartInfo.Arguments = 'test.txt'
objProcess.Start()
objProcess.WaitForExit()
objProcess.Dispose()
Message ('','done')

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

DirkM