WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> How to pass the filename from .bat to .exe file
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1099408082

Message started by lev on Nov 2nd, 2004 at 10:08pm

Title: How to pass the filename from .bat to .exe file
Post by lev on Nov 2nd, 2004 at 10:08pm
Hi,
How can i pass the file_name from .bat file to an exe program?
I tried the following in a batch file:

@echo off

SET TARGETDIR=C:\temp2
IF NOT "%WD_RELDIR%" == "" SET TARGETDIR=%TARGETDIR%\%WD_RELDIR%
GOTO %WD_REASON%
:FILENEW
MOVE "%WD_FILE%" "%TARGETDIR%"
call c:\project1 %WD_FILE%

GOTO QUIT

But nothing happens.

Thanks for help

Title: Re: How to pass the filename from .bat to .exe fil
Post by Gert on Nov 2nd, 2004 at 10:38pm
Hello Lev,

Is your exe called c:\project1.exe ?
If you want to run an executable inside your .bat file you should not call it. "Call" is only used when you want to start other .bat files (or subroutines).

Also, the executable will probably need the filename as its first parameter. The way you wrote it, it will receive the filename in multiple parameters if the name has spaces in it. To prevent that, you should always enclose the name in "quotes":

[code]c:\project1.exe "%WD_FILE%"
[/code]

However, I see one additional problem:
You first move the file to a different directory.... Perhaps you should first start the project1.exe, and after that move the file?

Let me know if this helps, please.

Gert

Title: Re: How to pass the filename from .bat to .exe fil
Post by lev on Nov 4th, 2004 at 8:45pm
It solves the problem ,
Thanks a lot for help!

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.