- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for tip.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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")
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.