runScript("powershell E:\\a.bat") Error

Asked by YongJianYan

In Windows 7 ,My SikuliX is on "D:\SikuliX", when I code the script ' runScript("powershell E:\\a.bat"). '
I faced the problem the path which start the script is "D:\SikuliX" but my "a.bat" content is "start Monitor ",Which Monitor is jar on E .
So response error " returncode : D:\sikulix>start Monitor -- Cannot find Monitor"
I want to know how to modify the path to execute the runScript command.

Question information

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

you have to solve this with some change dir (cd) in your a.bat or by using absolute path for monitor or with an option of the start command.

Revision history for this message
YongJianYan (sillyjims) said :
#2

runScript 's default path is the path of SikuliX? Can I change this path through SikuliX code ?
Because I try to
"""
runScript("powershell cd E:\")
runScript("powershell .\a.bat")
"""
But I failed , the command of "runScript" start from "D:\SikuliX"

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

this does not work, since both runScript or 2 independent processes running one after the other.

you have to integrate the cd into the one runScript:

- just meta code

runScript("powershell cd E:\ ; .\a.bat")

meaning
1. cd to E:\
2 then run the script

it is your job ;-) to figure out what is the best solution for that.

Revision history for this message
YongJianYan (sillyjims) said :
#4

Just a Little Misunderstood my words, whatever my script,but the path is "D:\SikuliX" .
The key point is to execute the script , "D:\SikuliX> cd E:\ a.bat" , means that current path not "E:\"
I want to change the executing path.
I have tried " os.chkdir();" ,but I failed ,any other idea can help me ?

Revision history for this message
Manfred Hampl (m-hampl) said :
#5

Can you change your e:\a.bat file to do a change directory command as first step?

e.g.

cd /d e:\
start Monitor

Revision history for this message
YongJianYan (sillyjims) said :
#8

I try to change my directory at first step, but it do not work,
because the runScript will start the command from "D:\SikuliX"
You can check in log.
only I can do , change my bat script. which add to absolute path.
But if my bat command like "cp - ***" it fails when my bat set absolute path

Revision history for this message
Manfred Hampl (m-hampl) said :
#9

You have two possibilities for starting commands and scripts:

1. the command (or script) is located in a directory that is part of the path
or
2. you provide the absolute path in the command

I suggest that you do the following:

In sikuli you start the script by providing its full path, e.g.
runScript("powershell E:\\a.bat")

AND

Inside the E:\a.bat script you also provide the full path for all commands that you execute in this script, or you set the path and/or change directory inside this script in a way that it works from whatever current directory it is started.
This has nothing to do with sikuli, but is plain Windows command and script execution.

Have you already tried modifying the E:\a.bat script by adding a change directory command as the first instruction?

I cannot understand how a "cp - ***" would fail if you provide the full path.
Note: "cp" is the syntax of the copy command on Unix system; on Windows it has to be "copy". Maybe that is the cause of an error message.

Revision history for this message
YongJianYan (sillyjims) said :
#10

thanks a lot.
I just do it from your fisrt suguestion .