does anyone know how to run a command once you have opened a dos window.
I have used shell(C:\windows\cmd.exe",1) to open the dos window, but need to run a command in that window from the same button as opened the dos window
You have the Dir Function available to you in Access.
Returns a String representing the name of a file, directory, or folder that matches a specified pattern or file attribute, or the volume label of a drive.
I used dir as an example, I have a range of commands I wish to run to create txt files which will then be imported as tables into access.
I can do the rest of the process it is just sending the command to the dos session that is stumping me.
I used dir as an example, I have a range of commands I wish to run to create txt files which will then be imported as tables into access.
I can do the rest of the process it is just sending the command to the dos session that is stumping me.
There's a wealth of VBA commands to create / manipulate directories and files, including creating text files. I suggest you use these.
Otherwise try pseudocode:
Code:
dim objShell as Object
Set objShell = CreateObject("WScript.Shell")
strCommand = "cmd /c dir /s"
objShell.Run strCommand
Alternative:
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.CreateTextFile("C:\mytext.txt")
With objLogFile
.WriteLine "This is a Test"
.WriteBlankLines (2)
.WriteLine "FIN"
.Close
End With