Forum Discussion
- KittRegular Contributor
Thanks for sharing. Is there a particular reason you want to minimize the cmd window, instead of just closing the window after the command is run? It would be nice to have some extra context as to what your end goal is.
Either way, here's an example using a file (in this case). Any shell commands longer than one line I usually thrown in a .bat or .ps1 file, but here's how to do it...
1) Just create a .txt file with the following contents:
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit net stop service exit
**NOTE: if you don't want cmd window to close, remove && exit from line 1 and exit from line 3
2) Save As stopNetService.bat and add the file to your TestComplete > Stores > Files collection.
3) Double click the batch file to run and test that it does what you want
4) In TestComplete, create a new function as follows:
function stopNetService() { // stop net service .bat var batch = Sys.OleObject("WScript.Shell"); var stopNetService = batch.Run(Project.Path + "\\Stores\\Files\\stopNetService.bat"); Log.Checkpoint("| Net Service Stopped |"); Sys.Refresh(); }
5) Use this function stopNetService() throughout your test as you please.
- pwangOccasional Contributor
Thanks for patiently answering my questions!! The solution works for me.
- KittRegular Contributor
- pwangOccasional Contributor
Thank you for your reply, But I can still not find the solution for the problem.
I don't use .bar or .ps1, My code is like this:
CommandLine = 'net stop service';
var oExec = Sys.OleObject("WScript.Shell").Exec(CommandLine);if (oExec.StdOut.AtEndOfStream) { ...}
Related Content
- 12 years ago
- 3 years ago
- 7 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago