Using .bat file to open file in diff location [Solved/Closed]

trueparadox - Apr 14, 2009 at 12:13 PM - Latest reply:  Nahid
- Dec 10, 2010 at 08:32 AM
Hello,

I'm working on developing a menu for a USB flash drive.

I have .bat file that opens a spreadsheet with a program that is installed on the flash drive.
The code looks something like this:

Start /d \Folder1\folder2\folderofprogram Name of program.exe "Name of file.ods"

This code works well but the problem is I need to have the file in the same directory as the program.
Is there a way to make the .bat file open the file from a different directory on the USB flash drive?


I think this is a simple problem but was not able to find any information about it.

Thanks for any help!
See more 

3 replies

Best answer
3
Thank you
Use UNC path name. so something like this: \\computername\folder\filename or \\mypc\c:\windows\testfile.exe

Hope this helps.

Thank you, Neomagus 3

Something to say? Add comment

CCM has helped 1871 users this month

But how do open file which is save in "Program File"
1
Thank you
It depends on where the bat-file itself resides on what program you try to start etc. For instance, to get the drive letter of the batch file path you could use SET DRIVE=%~d0 in your batch file. On the command line (cmd.exe) have a look at "help for", this might help you with this. Or have a look at http://www.robvanderwoude.com/batchhowto.php .

I know it will take some time to master this... I'm sorry I can't come up with a ready-to-use solution.