mrScriptcl.exe

In this article we will learn how to use a program called mrScriptcl.exe. This program allows us to run .mrs files from a batch file. We do this sort of thing when we want to schedule our scripts or perhaps do other things while they are running.

The first thing we need to know is, where do we find mrscriptcl.exe, well if you look in the following directory you should find it.

[Location where Data Collection is installed]Accessoriesmrscriptcl.exe

Next we need to do is to see if we can run this command from a command prompt, to do this click on your “START” button then click “RUN” and then when promted to, type “CMD” and the press enter. This should bring up the following screen.

Command Prompt
Command Prompt

make sure your cursor is in the black box and type mrscriptcl.exe then press return , if all is well you should see

mrScriptcl.exe is on path
mrScriptcl.exe is on path

if you don’t then what it means is the your path variable on the machine is not set correctly. To fix this you need to click on your “START” button , find the “My Computer” icon and “Right Mouse Click” it and go into “Properties” this will bring up a set of tabs and you will need to click on the “Advanced” tab and you should see the following screen

System Properties
System Properties

click “Environment Variables” and in the system variables section find the path variable and edit it, the content will show lots of directory’s and one of them should be the accessories directory just mentioned. In our case it is there, so we dont need to do anything , but if you need to add it , make sure you are at the very end of the edit line and type in your path making sure that there is a semicolon in front of the last entry. When this is done you should be able to go to a new command prompt and type mrScriptcl.exe again and it should be found. If it is not it might mean that your machine needs a re-boot. If all of this fails, and you definitely have access to the file then what we can do is to specify the path of the file in our batch file. We will do this anyway just so that you can see what the file would look like.

Ok next we need to have a script to run, in this example we are going to run a tables script produced from Reports for Surveys. If you did not know , in Reports for Surveys , under the “Tools” option you have the option to “View Script For All Tables”. When you get this you will see the option to “Save As”. Do this and Results for Surveys produces all the code used to run your tables job. All you have to do is to save it to a directory on your machine somewhere as an mrs file. In our example we have called our file “Tables.mrs”

Next we need to create a batch file with some commands in it. To do this go to the directory that you saved your mrs file in and use notepad to create a file called RUNME.bat you will need to edit this file and put the following in it.

ECHO *** START OF SCRIPT ***
c:
cd temp
"[Location Of Data Collection to]Accessoriesmrscriptcl.exe" Tables.mrs
ECHO *** DONE ***
PAUSE

Before you run your tables file you will need to edit it to make it point to the correct files.  To do this look for the following line in the script,

 .Load(“short_drinks.mdd” ‘! Path removed !’, , “short_drinks.ddf” ‘! Path removed !’, “mrDataFileDsc”, “short_drinks”, “{..}”)

its arround line 16. What you will need to do is to specify the location of the files you are using,so in our case the short_drinks mdd and DDF. After adding the path your line of code might look like this.

.Load(“c:tempshort_drinks.mdd” ‘! Path removed !’, , “ctempshort_drinks.ddf” ‘! Path removed !’, “mrDataFileDsc”, “short_drinks”, “{..}”)

 After editing the mrs file we are good to test our script. Do this by just double clicking the “RUNME.bat” file in windows explorer. When you have done this correctly you will see a command prompt open up and your script run.

Script running ok
Script running ok

The final thing we may want to do is to add this batch file to a scheduler on your machine. This way, you can run your scripts on a regular basis as long as the machine is on of course. To do this, click on “START” followed by “Control Panel” and then click “Scheduled Tasks” then click on “Add Scheduled Task” and this will walk you through a wizzard to automate your script on a regular basis.

Leave a Comment

%d bloggers like this: