Temp File Creations

July 7, 2009 at 07:55:51
Specs: Windows XP
I have a batch file that is making calls to arp, ipconfig, etc. I want to ensure that any temporary files created by the files (e.g. arp.exe) are only created within the root directory for the running batch file.

Is this possible?

See More: Temp File Creations

Report •

July 12, 2009 at 21:55:34
One way to be absolutely sure would be to go this route, call the location of the bat file then save the directory and drive as a variable and use that for your log file creation and location pointers:
@echo off
set dir=%~dp0
ipconfig /all >>"%dir%logfile.txt"

Report •

July 13, 2009 at 08:09:51
I have already tied this, but it fails:

set ROOTPATH=%~dp0
set REPORTS=%ROOTPATH%Audit-Reports

Report •

July 13, 2009 at 08:14:22
Assuming Audit-Reports is a directory, what stands out right away is the missing trailing slash.


set ROOTPATH=%~dp0
set REPORTS=%ROOTPATH%Audit-Reports\


Otherwise, can you tell me where it fails?

Report •

Related Solutions

July 13, 2009 at 08:37:45
Even if I add the trailing slash it still fails.

For example the first binary the batch file calls is "choice."

set BINARYPATH=binaries\
%BINARYPATH%choice..... **WORKS**

If I modified the path to be:
set ROOTPATH=%~dp0
%BINARYPATH%choice..... **FAILS**

If I try this it fails too:
set ROOTPATH=%~dp0
set BINARYPATH=binaries\

Report •

July 13, 2009 at 09:17:25
I've just tested this on my end sucesfully. Calling the binary shouldn't have the trailing slash. Can you try enclosing your binary call in quotes, perhaps your directory structure or file name has spaces that are causing issues?


Also, can you take out your echo off line and post the error you're receiving?

Report •

July 13, 2009 at 10:28:59
Yes, the root path contains spaces.

C:\Test Tools\My_Tools\cmdline-tools\testing>

Here is the complete line for the choice command:

%BINARYPATH%CHOICE /N /C:123 /T3,60 Please make a selection (1 or 2) > NUL

If I enclose this line with quotes than I receive this error
"The system cannot find the path specified"

Report •

Ask Question