[Dataperf] DP-created text file on user's desktop

Tim Rude timrude at hotmail.com
Mon Apr 24 23:50:23 CEST 2017

I need DP to be able to create a text file on the user's desktop. Sounds 
simple enough, but the folder that actually appears as the desktop is 
different for every user. For user TRR, the folder (on Win7) is 
C:\Users\TRR\Desktop, but for user JoeBob the folder is 
C:\Users\JoeBob\Desktop. I didn't see any way inside of DP to determine 
the correct folder, and DP doesn't translate environment variables (so 
asking DP to output to %USERPROFILE%\Desktop doesn't work).

I'm presently using the /SID=sessionID command line with DP. I always 
the start the database from a batch file, so I made the command-line in 
the batch file this:

     DP.EXE database.str /SID=%USERPROFILE%

Now inside my DP reports, I can access the passed SID value as 
user.field[0]. This is valid even if the database has no UserID panel 

So, to output a text file on the user's desktop, I configure the report 
to initially output to C:\NUL. Then at the very beginning of the report 
I have the following:

---Store Value in Report Variable 250 ---
---Turn File Off---
---Begin Writing to Filename in Report Variable 250 ---
---Turn File On---

This works fine as long as all parts of the desktop path fit the 8.3 
specs. But for XP there are spaces in the %USERPROFILE% so it's a no-go 
for XP. And if a username had spaces in it (is that allowed?) or was 
longer than 8 chars, it won't work under any OS. Anybody know a quick 
way to (inside a batch file) convert a long path to a short (8.3) one?

One other idea that I've floated around is to include this in the batch 

subst /d Q: > nul
subst Q: "%userprofile%/Desktop"
DP.EXE database.str
subst /d Q: > nul

Then in my DP reports, I simply output to Q:\output.txt. That seems to 
get around the 8.3 issues for DP nicely, but is a bit messier since its 
effects aren't contained to the database (i.e. the user sees a drive Q: 
in My Computer while the database is running, and what happens if the 
user already has Q: mapped to something...).

One other thing of note is that the database does not run under Shell, 
so no shell/macro-based solutions are viable.

Any better suggestions or ideas?

Tim Rude

More information about the Dataperf mailing list