Batch Files and MS Access

dds110
dds110 used Ask the Experts™
on
I read somewhere that you could put a batch file in the Send to menu to compact/repair Access Databases.  I know there are other, and better, utilities to do such a thing but I'd really like to know how a batch file gets the path and directory name from the context menu.

Can anyone help me out?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Billing Engineer
Most Valuable Expert 2014
Top Expert 2009
Commented:
database file name:
The selected file is passed as %1 to the batch/application.

command line flag:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q105128
/Repair                      

Solution:
the batch file should probably read like this:
C:\program files\office\office\msaccess.exe /Repair %1

CHeers

Author

Commented:
Thank you for the response, but I think you missed the question:

>>but I'd really like to know how a batch file gets the
>>path and directory name from the context menu.

The context menu being the pop up window whenever you RIGHT click on an Icon.

Thanks

Author

Commented:
Thank you for the response, but I think you missed the question:

>>but I'd really like to know how a batch file gets the
>>path and directory name from the context menu.

The context menu being the pop up window whenever you RIGHT click on an Icon.

Thanks
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

If you're running XP, here's the link on how to add items to the Send To context menu.  
http://support.microsoft.com/default.aspx?scid=KB;en-us;310270&

Angellll is absolutely correct.

>>but I'd really like to know how a batch file gets the
>>path and directory name from the context menu.

The magic is in the %1, %2, etc parameters within the batch file.  Assuming you create the batch file as shown by Angellll, and you can get the Send To Menu updated for your item, all is well!  So I guess I'll have to say, "I think you're missing the point of Angelll's answer".  The Send To Menu will pass whatever file name/directory you right-clicked on in the %1 parameter (that's not technically correct, but I won't quibble).


Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
>how a batch file gets the path ...

That's the job Windows OS does. It "knows" the file(s) you selected, and sends the path files as arguments to the called program as defined in the "send to" folder. Those arguments can be collected by ANY program, in batch files the arguments can be collected using the %N variables. If you select 1 file, the %1 is filled. If you select 2 files, %1 and %2 are filled etc.

thanks to twalgrave for the explanations

CHeers

Author

Commented:
Apparently I missed the context of angelllls answer.  I appreciate the explanation.

(It's been a bad week.)

twalgrave - look for a post for you for the explanation.

dds

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial