| || |
Resolving Windows Environment Variables
For a new script i need to call a file located in the current users profile. To do this i need to resolve the windows environment variable "userprofile". I tried it many ways, but i can't seem to find a working one...
SystemUtil.Run "%Userprofile%\Eigene Dateien\BSH-Info\Export001.pdf", "", "", "open"
...for example does not work...
Any help will be appreciated [img]/images/graemlins/smile.gif[/img]
Re: Resolving Windows Environment Variables
I don't get it, i tried this before, but now it works...
Here's the solution:
Set wshShell = CreateObject( "WScript.Shell" )
Userprofile = wshshell.ExpandEnvironmentStrings("%USERPROFILE%")
Yes, you mentioned it works now but not before. Mine works in a VBS script that calls QTP but not in QTP.
I suspect something erratic in QTP's settings: it's so easy to toggle of/on Visual Basic, activex, etc.
Working scripts that emailed result, now don't recognize the ActiveX email object in the QTP code.
My consclusion (looking for a better one): if it seems intermittant,
a. double check or log your File | Settings | Propety Settings,
b. make sure you don't have two competing copies of function libraries since sometimes the Fie | Resource | Fimction "make default" reverts to theq QTP folder deep within Program Files.
"No where near expert, but have been abused by the best minds at HP and Micro$oft"
Set oWS = CreateObject("WScript.Shell")
set oPEnv = oWS.Environment("Process")
If you want more out of QTP Environmental variables use WSH
If you use WSH, the below article will give you more info.