[AccessD] A2003:BAT/CMD file not outputting to log file if run from VBA

Darren darren at activebilling.com.au
Wed Nov 6 18:51:31 CST 2013


Hi Jim,
Interestingly I did have the full path for the log file (I had played with
just the log file path too)
But neither worked unless I double clicked the relevant file from the
folder. 
Running it VBA with Full Path or just file name gave me nothing.
Well, I thought it was nothing. The file was being written out - Just to the
MyDocs folder.
The solution was to add quotes about the full path of the logfile. 
In my myriad of hours and hours testing I thought I had tried at least a few
incarnations with quotes about the full path.
Turns out I didn't.
When Stuart made his comment I searched on the logfile name and voila -
there it sat in the MyDocs.
I'm sure someone on the list here can explain why it outputs but to a diff
location.
I also tried yours and Lambert's suggestion but without success.
I also removed the 'echo' comments, again without success.
Thanks for the help


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence
Sent: Wednesday, 6 November 2013 11:27 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] A2003:BAT/CMD file not outputting to log file if run
from VBA

Would that suggest that a line like:

blah blah blah >> <absolute pathname>\LogFile.txt

Jim

----- Original Message -----
From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
To: "Access Developers discussion and problem solving"
<accessd at databaseadvisors.com>
Sent: Tuesday, November 5, 2013 1:41:09 PM
Subject: Re: [AccessD] A2003:BAT/CMD file not outputting to log file if run
from VBA

Bet you a beer that it's a "current directory" problem. :)

Either, your batch file is running in a directory that won't let you append
to a file or your Logfile.txt is being written to but it is not where you
think it is.



-- 
Stuart

On 6 Nov 2013 at 2:31, Darren wrote:

> Hi guys
> 
> 
> 
> I have a CMD file that is run from VBA.
> 
> Inside this CMD file are lines like: 
> 
> 
> 
>      Echo blah blah blah >> LogFile.txt
> 
> 
> 
> All good and pretty basic - If I double click the CMD or BAT file the
> outputting to the log file via the '>>' works a treat.
> 
> If I 'run' the CMD/BAT file from VBA then the file runs but the >>
> bits seem to be ignored.
> 
> As a result the log file isn't created and (of course) there are no
> log entries.
> 
> I have tried with CMD and with BAT files
> 
> I have tried calling the BAT/CMD file a few ways from within VBA too.
> All no joy.
> 
> 
> 
> Dim strFileToRun As String
> 
> strFileToRun = Me.txtDeployFileToBuildPath
> 
> ''strFileToRun = "C:\Program Files\Microsoft SQL
> Server\90\Tools\Binn\Run.bat"
> 
> 
> 
> Dim retval
> 
> 'retval = Shell(strFileToRun, vbNormal)
> 
> 
> 
> Call fHandleFile(strFileToRun, -1)
> 
> 'Call Shell(strFileToRun, 0)
> 
> 
> 
> And so on
> 
> 
> 
> Anyone come across this before?
> 
> 
> 
> Many thanks in advance
> 
> D
> 
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list