Let>SCRIPT_DIR=c:\Macro Scheduler

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Locked
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Let>SCRIPT_DIR=c:\Macro Scheduler

Post by armsys » Sat Dec 20, 2008 11:50 pm

Is it possible to alter the default macro scheduler folder(s) on the fly inside a script?
Say, Let>SCRIPT_DIR=c:\Macro Scheduler

The purpose is maximize the flexibility of the script without hard coding the default path for the called macros. The same set of macros could be located in various locations.

The global change of the system default path for the macros can be done in:
HKEY_USERS\S-1-5-21-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\Software\MJTNET\MSched11\DataDir
Question: Does the key allow multiple paths of macros?

Nonetheless, so far my calling macros fails. For instance, Macro>MyMacro.scp will cause trouble to MS. How to rectify the issue while avoiding hard coding the path?

The reason that I raise this issue here is the fact my pathless macros used to run faultlessly until V11.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Sun Dec 21, 2008 4:28 am

If that path is in the registry, then you could use RegistryReadKey and RegistryWriteKey.

1. Read the normal default registry key into a variable for later restoration.
RegistryReadKey>root_key,key,entry,vDefaultValue

2. Write the value that you want into the registry.
RegistryWriteKey>root_key,key,entry,NewDefaultPath

3. Do your macro things as desired.

4. Write the stored variable back to the registry to restore default path.
RegistryWriteKey>root_key,key,entry,vDefaultValue
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Dec 21, 2008 1:45 pm

The *default* location is My Documents\Macro Scheduler 11. But you can point groups at any folder you like and even modify the main General group to point anywhere you like. Just right click on the group and select Group Properties. When you create a new group it will default to whatever is set in DataDir in the registry (Documents\Macro Scheduler 11 by default) but you can change it in Group Properties. If you don't want to have to do this then run regedit and change the value of the DataDir key under HKCU\Software\MJTNET\MSched11
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Sun Dec 21, 2008 2:08 pm

Hi Marcus,
Yes, today everything in MS11 behaves exactly the way you describe. It wasn't the case yesterday. Particularly I did modify HKCU\Software\MJTNET\MSched11\DataDir. Still MS11 complained about missing macros.

BTW, Can I change the value of SCRIPT_DIR? Will MS look up the SCRIPT_DIR when searching for the called macro?

Does MS support multiple paths of macros?
For example, HKCU\Software\MJTNET\MSched11\DataDir=C:\A, C:\B, C:\C.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Dec 21, 2008 2:18 pm

Well of course if you change DataDir it won't find your existing macros because macros.dat, groups.ini and groups.dat which store details about the macros all live in DataDir. So after changing it it won't see the original ones. Changing any of the registry entries is done entirely at your own risk.

If you want to change the folder I urge you to simply modify the Group Properties.

Yes, you can have more than one folder. Create a new group and give it a different path. In Macro Scheduler you can have as many groups as you like and each one can point to a different physical folder. Just right click on the group and select Group Properties.

You can modify SCRIPT_DIR if you like - as you can modify any variable. Of course the new value will only be visible to the running script - just like any variable. Since SCRIPT_DIR refers to the location of the running script it makes no sense to me to change it, but you can do what you like. It certainly makes no sense to me that SCRIPT_DIR should NOT refer to the location of the script!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Dec 22, 2008 8:04 am

To Bob,
Having not seen you for a long while. Thanks a lot for help. I'm sorry for my poor presentation. The core issue is about the Macro> command. It seems the syntax has changed under V11. Specifically, it requires the .scp file extension. Otherwise, MS will complain, which didn't occur in the previous versions.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 22, 2008 8:17 am

The Macro> command has NOT changed in v11. Since about v7 (don't remember exactly when - look in the history) it has always required a full path and filename. However, if a path and extension is omitted it will look in the CURRENT working directory for the file.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Dec 22, 2008 8:42 am

Apparently the so-called CURRENT working directory is exactly the install folder, namely, C:\Program Files\Macro Scheduler 11, as shown in the MS error dialog box.

Admittedly, I did change my own macros folder after installing v11. It used to reside in the same folder of the install folder. That is, both msched.exe and my macros/scripts share the same folder. Now all macros/scripts reside in C:\Macros. That may explain until v11 installation I had never encountered any trouble with my pathless and extenionless macro specification, eg, Macro>AppInit.

Hope I can explain myself crystal clear.

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Post by armsys » Mon Dec 22, 2008 8:51 am

Definitely appending .scp to a macro filename could resolve all the problems I have posted here.

Under the combination of following conditions, Macro Scheduler will fail:
1. The called macro is not in the install folder, namely, C:\Program Files\Macro Scheduler 11;
2. The called macro is not explicitly specified with an absolute path;
3. The called macro is not explicitly specified with .scp.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 22, 2008 8:59 am

From the help file topic for Macro.

Executes another script file. file_name must be a filename of a macro file. It is advisable to specify the full path should the path of the script file differ from the current path or change during the execution of the calling macro.

That is the first paragraph.

From the history list (http://www.mjtnet.com/mswhatsnew.htm):

Version 7.1 11/2002

** IMPORTANT CHANGE **
The Macro> command must now always be given a full filename rather than just an internal macro name, e.g.:
Macro>c:\my_macros\samplescript.scp


So it has been this way since 2002.

This thread is now closed.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Locked
cron
Sign up to our newsletter for free automation tips, tricks & discounts