View Full Version : Set file attribute of external file


tranchemontaigne
02-03-2009, 05:44 AM
I have a database that extracts a batch file and then executes this file as part of an OnExit procedure

What I want to do is set the file attribute of this extracted batch file to be hidden.

My code looks like this:


strFileAndPath = CurrentProject.Path & "\ClearTempFiles.bat"
'This code works great!
Call fnExtractBLOB(100, "t02_Inventory", strFileAndPath)
Call Shell(strFileAndPath)

'Attempts to set the file attribute of ClearTempFiles.bat to hidden
strFileAndPath = "C:\WINDOWS\system32\cmd.exe ATTRIB +H " & strFileAndPath
Call Shell(strFileAndPath)

'closes the database
CloseCurrentDatabase


When I run this code a command window opens, but the ATTRIB instruction is lost.

Any ideas?


Acknowledgement: Special thanks goes to Leigh Purvis for the excellent sample database on BLOB handling within MS Access (http://www.databasedevelopment.co.uk/examples.htm (http://www.databasedevelopment.co.uk/examples.htm))
________
Bmw r68 (http://www.cyclechaos.com/wiki/BMW_R68)

ByteMyzer
02-03-2009, 09:42 AM
Try changing:
strFileAndPath = "C:\WINDOWS\system32\cmd.exe ATTRIB +H " & strFileAndPath
Call Shell(strFileAndPath)
...to
SetAttr strFileAndPath, vbHidden