i have a 2 part problem.
I have read thru all of the associated automation posts concerning the Shell and the wSHShell.
I tried all of them in my code.
the wSHShell.exec(text001) works fine and starts the executable. The problem (part 1) is i would like to have it started in the minimized state. Part 2: how can i determine if the exe is already running so that i do not start it again. I tried the clear(wSHshell) but that does not 'kill' the running exe.
Text001 is defined as C:\Program Files\NOVA\viaWARP\Utilities\AutoProcess.exe
create(wSHShell);
wSHExec := wSHShell.Exec(Text001);
clear(wSHShell);
I tried the wSHShell.RUN(Text001,7,FALSE) but i get an error:
"An exception has occurred. Automation server returned error (HRESULT) -2147352567. The component did not provide the exception description.".
i also tried the :
Execute := STRSUBSTNO('start "" /MIN "%1"',Text001);
SHELL(ENVIRON('comspec'),'/c',Execute);
this DID start the exe minimized BUT it naturally opened the window with the message 'You are starting...' that the create(wSHShell) eliminates.
I could use some expert advice.
0
Comments
You should be able to do something like this:
WshShell is defined as ‘Windows Script Host Object Model’.WshShell
WshMode is an integer and is used to handle the Window Style (minimized, maximize etc.). Valid values can be found here.
The ReturnCode tells you have the execution went.
My techblog
Meet me @ LinkedIn
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Here is what i used:
wSHShell2 is a global var in the codeunit.
_commandline is a local var in the Function RunApp value: c:\program files\nova\viaWarp\utilities\AutoProcess.exe
This function is called from within a codeunit that is 'run' from a form.
I still have the problem with the second time that this codeunit is run from the form, the wSHShell2 variable is 'uninitialized' and a second instance of the executable is started.
it just dawned on me that the variables in the codeunit automatically get cleared before and after the code unit is run.
Is there a way to read the "Task Manager" from Navision to determine if a process is already running?
OR
Is there a way to 'kill' a process started via the above function?
Thanks for your help.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
My techblog
Meet me @ LinkedIn
Thanks for the replies.