Passing a parameter to shell function call

A

Andy

I have a simple NT Shell script (script.cmd) which handles one parameter
passed to it.

The script echos the parameter out to a txt file.

If I call this script from the DOS window in XP it works fine. If I call it
from a MS Access module using the Shell() function call it doesn't work. The
VBA line of code looks something like Shell("c:\script.cmd fred") where fred
is the parameter being passed to the script.

Basically nothing happens at all - no error.

Can anyone advise on calling shell scripts from MS Access with a parameter?
 
D

Douglas J Steele

What you've got should work: I just ran a test of the same sort of thing,
and it worked for me.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Andy said:
I have a simple NT Shell script (script.cmd) which handles one parameter
passed to it.

The script echos the parameter out to a txt file.

If I call this script from the DOS window in XP it works fine. If I call it
from a MS Access module using the Shell() function call it doesn't work. The
VBA line of code looks something like Shell("c:\script.cmd fred") where fred
is the parameter being passed to the script.

Basically nothing happens at all - no error.

Can anyone advise on calling shell scripts from MS Access with a
parameter?
 
A

Andy

Thanks - Yes, I got it to work now but if I change the location of the script
file to anything other than the c:\ drive i.e.
Shell("c:\folder1\folder2\script.cmd fred") then it doesn't work - any ideas?
 
D

Douglas J Steele

How can you tell whether or not it's working?

Remember that if it's supposed to write data to a file, unless you fully
qualify the output file, it's going to write to the current directory, which
likely isn't the same directory as where the MDB is located.
 

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