[AccessD] A2000: Run from Command line

Hale, Jim Jim.Hale at FleetPride.com
Mon Dec 18 10:49:47 CST 2006


Here is an example of a function to create a cmd and batch file and execute
them from inside Access. HTH
Jim Hale

Function Batfile(strfile As String, strUser As String) As Boolean
Dim intFileno As Integer, strBatfile As String, strCmdfile As String
Dim intFileno2 As Integer, varAns As Variant, varTime As Date
 strBatfile = "C:\glrunaje.bat"
 strCmdfile = "C:\glrunaje.cmd"
On Error Resume Next
  Kill strBatfile
  Kill strCmdfile
On Error GoTo PROC_ERR
'create bat file
  intFileno = FreeFile
  Open strBatfile For Output As intFileno
  Print #intFileno, "ftp -s:" & strCmdfile
  Close #intFileno
'create cmd file
  intFileno2 = FreeFile
  Open strCmdfile For Output As intFileno2
  Print #intFileno2, "open FP825ppd"
  Print #intFileno2, "FTPUSxxx"
  Print #intFileno2, "FTP4SRP5"
  Print #intFileno2, "put " & strfile & " download/glupload." & strUser
  Print #intFileno2, "Quit"
  Close #intFileno2
  If strfile = "" Or strUser = "" Then
    MsgBox "the Upload file name or User name is incorrect. The file was not
uploaded"
    Batfile = False
  Else
    varAns = Shell(strBatfile)  'run bat file to load prn file to AS400
    Batfile = True
  End If
PROC_EXIT:

  Exit Function

PROC_ERR:
  MsgBox Err.Description
  Batfile = False
  Resume PROC_EXIT
End Function

-----Original Message-----
From: Stuart McLachlan [mailto:stuart at lexacorp.com.pg]
Sent: Sunday, December 17, 2006 10:30 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] A2000: Run from Command line


On 18 Dec 2006 at 14:32, Darren DICK wrote:

> Hi All
> 
> >From a form - I am building a string that I want to 'send' to a command
> >line
> then I want the string to 'execute' from that command line
> 
> So - Building the string is no big deal and I have done that 
> 
> Once I have built the string though - how do I then get it to execute from
a
> command line?
> 


***********************************************************************
The information transmitted is intended solely for the individual or
entity to which it is addressed and may contain confidential and/or
privileged material. Any review, retransmission, dissemination or
other use of or taking action in reliance upon this information by
persons or entities other than the intended recipient is prohibited.
If you have received this email in error please contact the sender and
delete the material from any computer. As a recipient of this email,
you are responsible for screening its contents and the contents of any
attachments for the presence of viruses. No liability is accepted for
any damages caused by any virus transmitted by this email.


More information about the AccessD mailing list