wSHShell Minimized

twdavis
Member Posts: 79
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.
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
-
Hi!
You should be able to do something like this:IF ISCLEAR(WshShell) THEN CREATE(WshShell); WshMode := 7; WaitForEndOfCommand := TRUE; ReturnCode := WshShell.Run(’cmd.exe /c C:\Program Files\NOVA\viaWARP\Utilities\AutoProcess.exe’,WshMode,WaitForEndOfCommand);
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.0 -
Check also this : http://www.mibuso.com/forum/viewtopic.php?t=12417Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Thank you for your replies.
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.exeFunction RunApp (_commandline,_runModally) IF ISCLEAR(wSHShell2) THEN CREATE(wSHShell2); WshMode := 0; WaitForEndOfCommand := FALSE; Execute := 'cmd.exe /c '+'start "" /MIN "' + _commandline + '"'; ReturnCode := wSHShell2.Run(Execute,WshMode,WaitForEndOfCommand); IF NOT _runModally THEN EXIT(0);
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.0 -
Check out Pskill http://technet.microsoft.com/en-us/sysinternals/bb896683.aspx.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Taskkill is also a possibility... http://technet.microsoft.com/en-us/library/cc725602.aspx0
-
That worked perfectly.
Thanks for the replies.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions