Link to home
Start Free TrialLog in
Avatar of rogerdjr
rogerdjrFlag for United States of America

asked on

Passing a variable from Excel to a batchfile

Running a batch file from excel

The code in excel is:

set arg1 %1

if [%1] equ [] set arg1=%cd:~0,1%

echo "Test" %arg1%

echo %arg1%:\ZZZ\ZIP-BAT\source-zip.txt

dir e:\ZZZ\Zip-Bak\DayBkup\hm18*.zip>%arg1%:\ZZZ\ZIP-BAT\source-zip.txt

dir %arg1%:\ZZZ\Zip-Bak\DayBkup\hm*.zip>%arg1%:\ZZZ\ZIP-BAT\dest-zip.txt

The Dos batch file content is

set arg1 %1

if [%1] equ [] set arg1=%cd:~0,1%

echo "Test" %arg1%

echo %arg1%:\ZZZ\ZIP-BAT\source-zip.txt

dir e:\ZZZ\Zip-Bak\DayBkup\hm18*.zip>%arg1%:\ZZZ\ZIP-BAT\source-zip.txt

dir %arg1%:\ZZZ\Zip-Bak\DayBkup\hm*.zip>%arg1%:\ZZZ\ZIP-BAT\dest-zip.txt


I get an error Environment variable not defined (see attached screen shot)

Need help

Thanks
Dos-Batch.JPG
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial