Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been tasked with fixing a vendor's program that, under certain conditions, dumps gigs of junk files into a log directory. It ends up filling users' machines. My task is to figure out how to make it stop without any source code or additional running processes, and without making the program kasplode. In other words, I'm looking to use a feature of the file system to control the growth.

One idea I had was to make a hard link from that folder to NUL, as you might with /dev/null in the linux world. However, my attempts to use the mklink program to create a junction result in a message that says Local volumes are required to complete the operation.

Any ideas on how to complete the junction, or other ideas to solve the problem?

share|improve this question
    
out of curiousity: what for do you need this? –  akira May 25 '10 at 13:10
    
Symlinks are not the same as shell shortcuts. Beware of the terminology. (FWIW, in the Unix world a hardlink to /dev/null is a rare sight; symlinks are much more common.) –  grawity May 25 '10 at 13:37
    
More information (though not that much) about the "NUL" for Windows: msdn.microsoft.com/en-us/library/aa939249.aspx –  Gnoupi May 25 '10 at 13:47
    
I've been tasked with fixing a vendor's program that, under certain conditions, dumps gigs of junk files into a log directory. It ends up filling users' machines. My task is to figure out how to make it stop without any source code, and without making the program kasplode. –  minameismud May 25 '10 at 14:32
2  
Will your vendor's program crash if you change the permission level to deny write access to that folder that it sores its junk files in? –  Usta Jun 9 '12 at 2:53
show 1 more comment

7 Answers

I am just spit balling ideas here but:

If the problem program has command line switches maybe it can be turned off. I would ask the vendor first, assuming you can and haven't.

If the vendor program makes some kind of system event that windows reads, maybe you can make a script that deletes the junk folder (batch, cmd or powershell). If this is possible, remember to wait till the vendor program is done dumping.

Last resort is to set up a scheduled task to delete on windows logoff. This requires the client machines have enough space for the junk to live for the duration of the session.

If the clients are servers, thus no logoff, set it to run, say every 24 hours or how ever often this happens divided by 2. Divide by 2 is to reduce the chance of double junk so to speak..

share|improve this answer
add comment

If you can persuade the program to write its log files in the root of a drive letter, say, T:, try

subst T: NUL:

because then redirection to the bit bucket works, eg things like this work:

echo > T:\some_file

What won't work are reads from the fake T: drive, folder creation and file read access. Which sorta makes sense, but maybe your app relies on those.

share|improve this answer
add comment

No. Hard links are only available inside NTFS, and the NUL file is not an NTFS file - it's the WIN32 name of the \.\Devices\NULL namespace object, but you can't create a hardlink to it.

You could create a soft-link (a shortcut) to the NUL file if you wanted to, but I can't really think why that would be a good idea.

share|improve this answer
add comment

Why not just write a script that removes any .log files that get written to the offending directory on a regular basis (or at the beginning/end of using the program)? Granted, it's a band-aid until you can get the company to fix their program.

Such as:

do {}
While (Get-ChildItem C:\problemfile).Count = 0)
Remove-Item "c:\problemfile\*.log"
Write-Host “Program log file cleaned successfully”

I'm brand new to PoSH so this script may not work, but I think the concept is sound.

share|improve this answer
1  
Or the more compatible and arguably easier thing in batch: del <folderpath>\*.<extension>. Might want to test on a useless directory first. –  Bob Mar 5 '12 at 23:18
add comment

If you don't need the offending log file and the path/name is a known variable, try creating it as a read only file as root/privileged user to prevent it's creation.

Alternatively you could create a read only volume/partition or ramdisk of a limited size that you symlink to, to limit the size of the file.

If the program does require the log file to continue operation and 'kasplodes' when it can't write then you may need a programmatic solution such as log rotations if you've been unable to pipe to null.

share|improve this answer
add comment

You could create a separate Windows User to run the program (must be a password protected account) and then right click on the drive that the logs get written to and select properties. Then click on the Quota Tab and setup a disk space quota for that user. Finally hold shift and right click on the .exe file that starts the program and select run as different user, selecting the account you just created.

share|improve this answer
add comment

If you prefer the hard link, then you'll have to go with

C:>mklink /h "C:\Program Files\MyNewHardlinkFolder" NUL

share|improve this answer
    
I doubt that would work; NUL is not a real file, and it doesn't have any links. –  grawity May 25 '10 at 13:37
    
Doesn't. "Local NTFS volumes are required to complete the operation." –  minameismud May 25 '10 at 14:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.