Command Line arguments not working...

G

Guest

I am trying to create VBA code that runs the 'elogdmp.exe' from inside of
Access ('elogdmp.exe' dumps the contents of the event log to a
comma-delimited text file, found on the Win2K sevrer reskit)

When I open a command prompt window and type:

C:\<sourcefolder>\elogdmp.exe PCNAME system >
C:\<sourcefolder>\PCNAME_system.txt

Everything works fine.

- C:\<sourcefolder>\elogdmp.exe: The location of the elogdmp.exe file.
- PCNAME: The PC that you want to retrieve the log from (obviously!).
- system: The event log type you want to retrieve (system, security or
application)
- > C:\<sourcefolder>\PCNAME_system.txt: The text file you want the output
dumped to.

However, in VBA, when I try:

Dim str As String
Dim var as Variant

str = "C:\<sourcefolder>\elogdmp.exe PCNAME system >
C:\<sourcefolder>\PCNAME_system.txt"

var = Shell(str)

The elogdmp.exe file runs, doesn't return any errors, but also doesn't
recognize any of the command arguments.

How do I run this command line utility from VBA?

Thanks!
 
D

Douglas J Steele

Assuming PCNAME is a variable that contains the name of the PC, try:

str = "C:\<sourcefolder>\elogdmp.exe " & PCNAME & "system >
C:\<sourcefolder>\" & PCNAME & "_system.txt"

If <sourcefolder> contains spaces, use

str = """C:\<sourcefolder>\elogdmp.exe """ & PCNAME & """system >
C:\<sourcefolder>\" & PCNAME & "_system.txt"""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top