Please note that you can subscribe to the individual forums. A subscription for news only covers the news.
Hi... I know I can launch a program outside of Virtual Master using launch=, but is there a way of closing the program as well?
Thanks,
Chazz
Hi Chazz,
If the program supports the command line you can write a batch file to close it and then launch the batch file. Assuming that you are using windows you can use the taskkill command to close any process. This is like using the task manager to close a program; depending on the program it may or may not show errors when closed that way.
Kathy
Thank you Kathy! I will definitely look into that.
Hi,
There is a small program called AutoIt3 Script Editor which has its own scripting functions that can open, close and manipulate other programs. It is quite easy to use. I am using it to see if I can tie control of everything to VM.
Interesting!! Please let us know what happens.
Chazz
Hi again,
It works perfectly, and is extremely simple to use.
I have created tiny executables for every program I need to use and VM can call them from the script like any other for both opening and closing. Other manipulation is also possible but will be more complex.
best wishes
Excellent! Thanks for sharing! I'm excited to explore the possibilities.
Chazz
Hello.
Just phishing for advice. This Q&A was great. I'd never heard of batch files, but after several minutes of internet research I followed the advice on some forum and set up a folder of task-killers, mostly to close docx files and Paint (shame). It works and is a nice feature. But it immediatley seemed to slow down the open and close times, quite dramtically. Sometimes VM and the computer get out of synch while bats are yet to complete their biz, particularly with Word and shame. This seems to affect Word even when VM isn't running, as if the existence of the batch files is having some effect.
I’ve ignored it for a year or two... but does this sound normal? Can bats be dangerous? Am I perhaps taking risks with the system?
Hello Simon,
As with most programs where you don't know/trust the source bat files can be dangerous. It's a little hard to judge if you have an issue resulting from there use. Can you describe what exactly the bat file is doing? Is it self contained or does it launch a third party task killer? Is it always running looking to stop programs or just when virmst asks it to?
-Ms. O
Hello Ms. O
Thanks for responding.
There are a dozen batch files in one folder, the VM folder, along with VM.exe. Several close panes of MS Word with this format:
@Echo Off
Taskkill /Fi "WindowTitle eq Homework.docx - Word"
Others close Paint and WordPad (here at Tech Vanguard) like this:
@echo
cls
Taskkill /IM wordpad.exe
An opinion on that syntax would be useful.
The files are called via the Launch command, and mostly in Before and Done procedures.
The delay time is highly changeable. The CPU usually goes into the red when launching Word and the programme is ‘not responding’ for between a few and thirty seconds or more. The changeability makes testing tricky, but things seem to speed up when I remove the bats from the VM folder.
I’ve realised today that the Launch command holds up a procedure until the launch has been successful. Thus a delay executing the batch can cause entanglements, with procedures kicking off before previous procedures have finished. I’d spelled out a case here but accidentally deleted it without saving, saving you over two hundred words. But it’s true, I swear. If it becomes relevant I'll provide the report and some script, but I have to run now - 6th Jan is gift day round here. Must oblige and shop.
Thanks again for the interest. I continue to be suspicious of the possible influence of batch files.
Simon
Hi Simon,
I'm not an expert here, but I doubt that batch files not being executed in the VM folder can delay the program. Or anything else.
Have you tried executing Taskkill from the Launch command? Without using a batch file. It might work, but I have not tested it.
Sven
Thanks Sven.
I will take that as a considerably more expert opinion than mine. The problem is most likely that this computer just runs slowly sometimes, for which I blame.... Rishi Sunak.
I’m not sure how I would structure the statement with Launch. The syntax is alien to me - hieroglyphs copied whole from an unofficial source.
My new, slightly deeper understanding of how VM handles the Launch function is useful.
Just for reading practise (so quit now if you’re busy!), the problem I didn’t spell out earlier was in this construction.
[Job-Work]
BeforeProcedure=...
DoneProcedure=...
[Procedure-BeforeProcedure]
Case=First
When=!zzDeadline<!zzNow
Procedure=Late Job Start
;delivers a comment
Setflag=JobLate
Case=End
Launch=...WorkSheet.docx
[Procedure-Done Procedure]
Launch=...CloseWorkSheet.bat
Case=First
When=JobLate
Procredure=Late Job Done
;punish etc
Case=End
When processing the Doneprocedure, VM report acknowledges ‘Launching file’, but the remainder of the procedure hangs. Sub is able to start the next job. By the time she’s got through the Beforeprocedure, the bat has ‘launched successfully’: the document (currently required) closes(!) and the condition calls Late Job Done. Sub is now being punished for handing the previous piece of work in late.
Moving the bat file to the BeforeDoneProcedure may cure this particular loophole since the assignment tray does not display other jobs at this time.
Many thanks again. Still not sure why Word is so slow and CPU-thirsty at times, but I don’t have the will for testing right now. In good time....
All the best
Simon
I take no responsibility for Word! 😉
I have some suggestions. I have not tested them, and I am not sure it will work. But you can give it a try, if you wish.
First, divide your Done Procedure in two. To make sure that the punishment is for the right job.
[Procedure-Before Done Procedure]
Case=First
When=JobLate
Procedure=Late Job Done
;punish etc
Case=End
Second. The Launch command does wait for the launch to be completed, but not for the launched process to end. However, there is an undocumented command that waits for the launched process to be completed. I created it for some tests, and then forgot about it. But I think it will work. LaunchWait will hang the reminder of the procedure until the launched process has completed.
[Procedure-Done Procedure]
LaunchWait=...CloseWorkSheet.bat
Third. The above will not hang the whole program, and thus not preventing the sub from starting the next job. But you can do that with the Resource keyword.
Add eg. Resource=Word to all jobs that runs this way. Two jobs using the same resource cannot be started simultaneously.
[Job-Work]
Resource=Word
BeforeProcedure=...
BeforeDoneProcedure=...
DoneProcedure=...
As said, all this is theory, I am not sure whether it will work.
Then of course, there is a quite different approach: 😀
[Procedure-Before Done Procedure]
message=Close the Word document and then click OK.
Sven
Haha! But having VM open and close external programmes is so much... sexier.
The resource keyword sounds right - I see it in the manual now.* And Launchwait may solve issues with bats elsewhere. I’ll experiment. Many thanks for the tips and ideas.
*Yes, I should study it more.
I agree. 🙂
Please let me know if it works.
Sven