Trying to launch an EXE or LNK file

Asked by Shawn Robertson

Sikuli 1.1.1 Nightly November build
Windows 10 x64

Good morning,

in my automation scripts I was defining an app instance like this:

import mySettings
import os
import DBChecks

program = App(os.path.join(r"C:\tssmoketest", Settings.Version, "program.exe"))

I then would call that in this context:

program.open()
DBChecks.checkFor_CantConnectError()
DBChecks.checkFor_EntitlementError()

the problem now is that our EXE has changed in code and now calls a separate DLL file that also resides in that same directory. What happens now is that when Im calling the EXE using an app instance, it is being called in a weird state that ignores that DLL file.

I can reproduce this manually by going to command prompt in windows, CD\ to C:\ and then calling the application by the full path C:\tssmoketest\2017\program.exe

if I go into command prompt and CD\ tssmoketest\2017

and then just call program.exe

I have no issues which is why our desktop shortcut has no issues either because the shortcut establishes a "start in" directory.

Since my development team is not going to fix the issue since customers would never call it this way, i need a work around so I tried this:

os.chdir(os.path.join(r"C:\tssmoketest", Setings.Version,))
os.system(program.exe)
DBChecks.checkFor_CantConnectError()
DBChecks.checkFor_EntitlementError()

but running this way didnt work because the program would launch and then nothing else would happen. it was like the IDE was waiting for ever and I had to shift+ctrl+c to stop the script.

then i thought what if I could just call the LNK file on the desktop since I know its there and I know its path.

I tried using

subprocess.Popen(r"C:\Users", "Public", "Desktop", "program.LNK")

but I guess subprocess or Popen isnt in Jython so then I tried:

os.system(r"C:\Users", "Public", "Desktop", "program.LNK")

but it did the same thing as earlier where the program launched but IDE is frozen or waiting for ever.

I'm sorry this sounds so complicated and maybe there is an easier way to do what i'm trying to do but in reality im simply looking for something as elegant as:

program = App(os.path.join(r"C:\tssmoketest", Settings.Version, "program.exe"))
program.open()

but with the ability to define a start in directory JUST for that instance

so that I do not have to do the less pretty method of:

type('r', keyModifier.WIN)
wait(.5)
paste('CMD'
wait(.5)
type('cd\tssmoketest\2017', + Key.ENTER)
wait(.5)
type('program.exe', + Key.ENTER)
wait(.5)

thank you for any advice or help.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

have a look at subprocess.popen()
http://www.jython.org/docs/library/subprocess.html

... there you can specify the complete eco-system, the program should run in.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

ok, and to get it running in parallel, you have to issue a suitable start command.

directly calling your program will pause your script until your program finishes, which is surely not, what you want.

Another general approach:
run from commandline and add the folder where your program resides to system path locally in the batchfile, so the dll would be found this way.

Can you help with this problem?

Provide an answer of your own, or ask Shawn Robertson for more information if necessary.

To post a message you must log in.