Could SIkuli change some environment variables at runtine?

Asked by Asheru

Hello,

I'm wondering if Sikuli could possibly change some system environment variables at runtime, like windows path for example or others?

While running some tests we are missing some dependencies needed by our app that is tested. Those are relying on some system variables and we want to eliminate this possibility.

Thanks

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

Not a feature.

You have to do that in some wrapper (command script, ...).

Or in your SikuliX script/program using the JNA features (JNA 5.3.1 is bundled with SukuliX already).

An example for manipulating the Windows path you can find in the sources:
class: org.sikuli.script.support.RunTime::addToWindowsSystemPath

Revision history for this message
Asheru (asheru93) said :
#2

Ok thanks.
But while executing a normal script it does not change anything related to that, right?

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

--- But while executing a normal script it does not change anything related to that, right?
not while running, but before starting the script run, the lib path is added to the end of the Windows path.
But this does not clash with any wrapper actions.

Revision history for this message
Asheru (asheru93) said :
#5

Sorry, my bad. I was not clear enough.

To be more specific, the problem is:

We are testing an app(MyTestApp let's call it) and we have a large suite of tests built with sikulix+python. This are executed on two virtual machines from TFS.

'MyTestApp' uses a module called 'pdftk' when you open a pdf doc from this app. The app is adding at installation to windows Path this : C:\Program Files (x86)\PDFtk\bin, in order for this module to work.

On the VM when sikuli script is trying to open a PDF file the path to PDFTK is not found anymore.
It works locally, no problem.

I know it should not have any impact no matter how many things you have in windows PATH, but could it possibly be something from sikuli like changing something in path variable or something similar that could affect other paths already present there?

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

ok, you can do that in a script:

try:
  import org.sikuli.natives.WinUtil as Windows
  path = Windows.getEnv("PATH") # get current path
  # manipulate the path string
  newPath = Windows.setEnv("PATH", changedPath) # change it
  if (newPathh == changedPath):
     pass #worked
except:
  pass # did not work

Can you help with this problem?

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

To post a message you must log in.