BookmarkSubscribeRSS Feed
Merlin82
Calcite | Level 5

Hi all,
I'm having difficulties with temporary file location when running vbs script. I've set Environment variables in the SEGuide.exe.config and it's working fine when using SAS EG normally. But when I run code from VBS using

Set app = CreateObject("SASEGObjectModel.Application.7.1")

application log says:


DEBUG SAS.EG.Scripting.Application [(null)] - No Environment Section found in the app.config file


Where can I find this app.config file to set those env variables? How to set this?

Can someone help?


Thanks in advance

 

10 REPLIES 10
ChrisHemedinger
Community Manager

SEGuide.exe.config is not applied when running a script, as the executing process is CSCRIPT.exe or VBSCRIPT.exe.

To temporarily redirect the TEMP directory for your script, you will probably need to use a batch/cmd file to wrap the script. Example:

 

set TEMP=your-temp-path
%windir%\syswow64\cscript.exe path-to-your-eg-script.vbs

 

Save that to a BAT or CMD file, and then use that Windows batch file as the target for your scheduled job.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Merlin82
Calcite | Level 5

Thanks for tip.

Unfortunately it didn't work. When running script it still uses old TEMP folder.
ChrisHemedinger
Community Manager

Try setting the environment variable EGTMP to the desired path.  Maybe even set that as a machine-level environment variable to see if EG will pick that up.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Merlin82
Calcite | Level 5

I've tried to set EGTMP, TEMP and TMP using Windows Environment Variables but EG didn't picked it up. Only way for EG to change TEMP folders was to put it in the SEGuide.exe.config. Maybe it should be put there but with specific type for SAS.EG.Scripting but I cannot find any materials regarding this config file. I am thinking about something like this:

  <configSections>

    <section name="Environment1"
             type="SAS.EG.Configuration.EnvironmentSection, SAS.EG.Scripting"/>

 </configSections>

 

and then add section

  <Environment1>
 <Variables>
  <add name="EGTMP" value="path" />
  <add name="TEMP" value="path" />
  <add name="TMP" value="path" />
 </Variables>
  </Environment1>

 

Tried different combination of types but it didn't work.

ChrisHemedinger
Community Manager

Going through some old notes and found this potential workaround.  Add a ChDir to the top of your script, before creating the EG application object.

 

' redirect unwanted output (directory must exist)
ChDir ("c:\temp\scrap")

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Merlin82
Calcite | Level 5

After adding this right before

Set app = CreateObject("SASEGObjectModel.Application.7.1")

it's giving me an error during execution:

 

Error #1F4

In Function CreateObject

Variable is undefined

 

Folder used in ChDir exists.

ChrisHemedinger
Community Manager

Whoops, sorry about that.  ChDir is a VBA function (for use in Office apps), not VBScript in general.

 

To change the working directory:

 

Set objShell = CreateObject("Wscript.Shell")
objShell.CurrentDirectory = "C:\temp\scrap"

 However, now that I write this, I don't know that this will redirect the temp folder.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
CaseySmith
SAS Employee

To Chris' point earlier, since cscript.exe or wscript.exe are the executing processes when running via scripting (rather than SEGuide.exe), SEGuide.exe.config will not get picked up.  However, if you create a cscript.exe.config or wscript.exe.config in the same directory as the executable (ex. C:\Windows\SysWOW64 for 32-bit EG, C:\Windows\System32 for 64-bit EG), the config options will get picked up by EG when run via scripting.  (I confirmed.)  (For example, copy SEGuide.exe.config to the appropriate directory and rename it for the appropriate executable.)  Note: Since those locations are system file locations, you'll likely need admin privileges to create a file there.

 

Casey


Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

Merlin82
Calcite | Level 5

Since I don't have admin privileges to place config in System32 and SysWOW64 folder I'll have to catch an IT team to do this for me. When I'll try this I'll let you know if that worked for me as well.

 

Thanks for a great tip.

Merlin82
Calcite | Level 5

It didn't work for me. IT put wscript.exe.config and cscript.exe.config (they are the same as SEGuide.exe.config) in System32 and SysWOW64 folders. It looks like it's picking up config since in application log there is no line saying

DEBUG SAS.EG.Scripting.Application [(null)] - No Environment Section found in the app.config file

like it was before.

But the temp folder is created in old location, not in the one specified in config file.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1963 views
  • 1 like
  • 3 in conversation