OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

getting the user's TEMP directory in windows

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Ichthus
General User
General User


Joined: 23 May 2004
Posts: 6

PostPosted: Sun May 23, 2004 9:25 pm    Post subject: getting the user's TEMP directory in windows Reply with quote

Trying to write a script that saves a copy of the current document in the user's windows temp directory. This is set as a environment variable in windows, and you can see it at the command line by typing "echo %TEMP%" which gives "C:\DOCUME~1\Username\LOCALS~1\Temp".

Is there a way I can get the value of this variable inside a Macro? I tried:

ConvertToURL( "%TEMP%" )

which gives

file:///%25TEMP%25

Thanks in advance,
Kevin
Back to top
View user's profile Send private message
bitfarmer
General User
General User


Joined: 06 May 2004
Posts: 39
Location: Murcia, Spain

PostPosted: Sun May 23, 2004 11:30 pm    Post subject: Reply with quote

You can also make a shellexecute of "SET > C:\tempo.txt", then load the tempo.txt file and look for a line beginning with "TEMP=" , the path is on the rest of this line.
Back to top
View user's profile Send private message Visit poster's website
Ichthus
General User
General User


Joined: 23 May 2004
Posts: 6

PostPosted: Mon May 24, 2004 4:49 am    Post subject: Reply with quote

That is one idea... but I was hoping for something a little cleaner. To add to your idea though, it would be easier to do a shell execute of "echo %TEMP% > C:\tempo.txt"... cause that would make the only line in the file as the temp path... no searching Smile

Anyone else have a better way? Thanks Smile
Back to top
View user's profile Send private message
Cybb20
Super User
Super User


Joined: 02 Mar 2004
Posts: 1569
Location: Frankfurt, Germany

PostPosted: Mon May 24, 2004 6:37 am    Post subject: Reply with quote

it's a simple command to get the Temp directory, at least for Windows. I don't know if you can do the same for Unix or for the Mac.
Code:
msgbox Environ("TEMP")


Hope that helps.
Christian
_________________
- Knowledge is Power -
Back to top
View user's profile Send private message Send e-mail
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon May 24, 2004 6:58 am    Post subject: Reply with quote

Just FYI....

There is another completely different way to find what OOo thinks the temp file is.

OOo has this thing called Path Settings. You can alter the path settings by doing.....
Tools --> Options --> OpenOffice.org --> Paths

The path for "Temporary Files" is where OOo thinks temporary files go.

You can display the Temp setting of PathSettings like this....
Code:
Sub Main
   oPathSettings = CreateUnoService( "com.sun.star.util.PathSettings" )

   ' Example of how to get a single property you are after.
   MsgBox( oPathSettings.Temp )
End Sub


The Environment variable trick makes assumptions about the underlying operating system. Using PathSettings abstracts you away from whatever mechanism the underlying OS uses to indicate a "temp" folder. Even if the OS doesn't have a temp folder, OOo will have one and PathSettings will point to it.

The PathSettings service has many properties, including the Temp property. If you look at the other properties, you can see that the above technique is useful for finding other important paths known to OOo.

Here is an article I wrote over in Code Snippets that displays all of the settings in PathSettings....

Display your PathSettings
http://www.oooforum.org/forum/viewtopic.php?t=7459

Here are some other relevant past threads....

http://www.oooforum.org/forum/viewtopic.php?t=4913
http://www.oooforum.org/forum/viewtopic.php?t=4613
http://www.oooforum.org/forum/viewtopic.php?t=3707

Use the Tools library (soffice) to get path settings...
http://www.oooforum.org/forum/viewtopic.php?t=5720
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Ichthus
General User
General User


Joined: 23 May 2004
Posts: 6

PostPosted: Mon May 24, 2004 9:40 am    Post subject: Reply with quote

Thank you thank you to both of your replies. The Environ() call was what I was looking for, and will probably work for my situation since it will only be running on windows. But I may use the other one, just for kicks. Thanks guys Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group