Manually set the Temp folder

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Manually set the Temp folder

Post by Tenaja »

I wish we could set a Temporary folder.

Currently, as far as I can tell, the only control we have over the Temp folder is no control, or in the Source Directory.

I wish we could put it in a specific folder. My IT guy switched me to a new antivirus, but it is a nightmare to configure. It would be a whole lot easier if I could set it to appdata\Local\PB_Tests, or something like that. The way it is now, using a shared Temp folder, makes it nearly impossible to configure.

Thanks.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Manually set the Temp folder

Post by Little John »

You can try to start PB from a batch file, where previously the temp directory is set to a location of your choice, e.g. on Windows (not tested):

Code: Select all

SET temp=C:\Users\Tenaja\AppData\Local\PB_Tests
C:\Program Files\PureBasic\PureBasic.exe %1
//edit 2015-09-16:
Here is more comprehensive code and explanation.
Last edited by Little John on Wed Sep 16, 2015 2:49 pm, edited 1 time in total.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Manually set the Temp folder

Post by Tenaja »

Is that permanent, or only for PB?
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Manually set the Temp folder

Post by Little John »

Tenaja wrote:Is that permanent, or only for PB?
That is only for the programs which are launched from that batch file (after the "SET temp=..." line).
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Manually set the Temp folder

Post by Tenaja »

I must be doing something wrong, because this will not launch the IDE, but just compile one file. That means it will not work with the debugger. Or, and I just stuck with it that way?
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Manually set the Temp folder

Post by Little John »

Works here on Windows 7 "as advertised". :-)
The file "PureBasic.exe" is the IDE.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Manually set the Temp folder

Post by Tenaja »

I get a dos box flash up and disappear too quickly to read. Maybe it does not work for me because I have a space in the directory. (starts with C:\Program Files (x86).) Is there an easy workaround?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: Manually set the Temp folder

Post by Mistrel »

Put double quotes around the path.
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Manually set the Temp folder

Post by Tenaja »

Little John wrote:You can try to start PB from a batch file, where previously the temp directory is set to a location of your choice, e.g. on Windows (not tested):

Code: Select all

SET temp=C:\Users\Tenaja\AppData\Local\PB_Tests
C:\Program Files\PureBasic\PureBasic.exe %1
Little John, I appreciate your suggestion, but everything I have tried, and I cannot prevent PB from using the Windows TEMP folder. I tried it with and without quotes around the directories, and I tried it with both of those lines on the same line, as well as on separate lines (the way they pasted). Even with the "Create temporary executable in the source directory" option set, PB still creates a *.TMP file within the \Temp folder.

The reason I need this is because my IT guy took us to a new AV, and it is not PB-friendly. (Other than PB, I prefer it over the old one; it found some malware that the old one did not find...) Unfortunately, every file the AV stops is in the AppData\Local\Temp folder, and the file extension is always *.TMP, so PB does not get to make an exe. Obviously every *.TMP file within the \Temp folder is far too generic to exclude, so I figured I would try to create a pb-specific temp folder, but that is eluding me.

I tried running PB with the \Portable switch, and even then, the AV stopped it, flagging a *.TMP file within the \Temp folder...so obviously the \Portable switch does not do what one would hope.

This was easy when I could just whitelist PureBasic_Compilation0.exe through PureBasic_Compilation9.exe, but as long as I have the debugger enabled, PB does not get past the linker.

Thanks.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Manually set the Temp folder

Post by IdeasVacuum »

I think this is an urgent matter, I hope Fred can make this tiny improvement soon.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Manually set the Temp folder

Post by Little John »

Tenaja wrote:Little John, I appreciate your suggestion, but everything I have tried, and I cannot prevent PB from using the Windows TEMP folder.
I'm sorry that the suggestion does not work for you. As I wrote, it works as expected on my system.
Tenaja wrote:Even with the "Create temporary executable in the source directory" option set, PB still creates a *.TMP file within the \Temp folder.
Then something strange seems to go on on your system. Sorry again, I've got no idea what the reason could be.
I cannot recall ever having seen PB automatically create a file with extension .TMP.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Manually set the Temp folder

Post by IdeasVacuum »

I get a dos box flash up and disappear too quickly to read.
you can add a

Code: Select all

pause
line so that you can see.

Code: Select all

SET temp=C:\Users\Tenaja\AppData\Local\PB_Tests
C:\Program Files\PureBasic\PureBasic.exe %1
pause
..... but I'm not sure if that Batch File is setting Temp for PB or re-locating Temp for the whole system?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Manually set the Temp folder

Post by Little John »

IdeasVacuum wrote:..... but I'm not sure if that Batch File is setting Temp for PB or re-locating Temp for the whole system?
http://www.purebasic.fr/english/viewtop ... 03#p456203
User avatar
Tenaja
Addict
Addict
Posts: 1959
Joined: Tue Nov 09, 2010 10:15 pm

Re: Manually set the Temp folder

Post by Tenaja »

Little John wrote:I cannot recall ever having seen PB automatically create a file with extension .TMP.
It is caught by the AV program, and the PB error message box indicates a linker error.
Post Reply