Open SAS program in new instance

2019-07-20 15:00发布

问题:

I'm trying to figure out a way to open SAS programs in new instances of the Enhanced Editor by default on click.

The question has been asked before but no luck.

This paper describes the way a program is opened with the Enhanced Editor. The full command is :

"C:\PROGRA~1\SASHome\SASFOU~1\9.3\core\sasexe\SASOACT.EXE" action=Open
datatype=SASFile filename="%1" progid=SAS.Application.903 

The author explains that:

The sasoact.exe program is used to launch an OLE automation session of SAS. Automation is a mechanism through which one Windows application can control another application programmatically. When you double-click a SAS file type, sasoact.exe checks to see if an existing OLE automation session of SAS is running. If not, it then invokes an OLE automation session of SAS. Once there is an active SAS automation server session, any further calls from sasoact.exe are handled by the existing SAS session instead of in a new SAS session.

I guess having only one OLE session is usefull in some way or another but it's really annoying when you have to manually open a new EE instance every time you want to run multiple jobs. Not to mention that sasoact targets the first session initiated and if a job is already running on that session well your program is not going to open.

Is there a way to directly request a new instance of the OLE session or perhaps "trick" sasoact.exe into not seeing the opened sessions ?

[EDIT] Well too bad it's been closed as duplicate because the answer is substantially different than the other question's. Also it might help others who do not want to run their programs from a batch file. Here is the registry key that works:

"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -initstmt "dm 'whost;include ''%1'' ';"  

I added it in HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command so now I have a neat little extra option in my drop-down menu that effectively opens programs in new sessions on click:

回答1:

A similar thread showing the use of a batch file to open a SAS program in a new session is available here.

If you want to open a .sas program in a new session by simply clicking the program here is how to do it:

You have to add an entry to the registry. Be careful when messing around with registry files, always back up your entries.

Open the registry editor (WIN+R > regedit).
In the directory HKEY_CLASSES_ROOT\SAS.Program.701\shell\ create a sub-directory with a meaningful name(right-click on shell > New > Key). I named mine "Open New". In this new sub-directory create another sub named command. You should now have a path that looks like:
HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command
In here, right-click on the file on the registry file on the right > Modify and add the following in the Value data field (change the path of sas.exe if needed)

"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -NOTUTORIALDLG -initstmt "dm 'whost;include ''%1'' ';"

Close the editor. You should now have the new option specified in the drop-down menu of the right-click on a .sas program:

This option will open your program with the Enhanced Editor in a new SAS session.

Now if you want it to work for double-clicking I suppose you'd have to replace the value in the Open sub-directory with the one from above. I haven't done it and I don't recommend it, the extra option in the drop-down is enough for me.



标签: sas ole