Hi,
I've created a windows batch file and want to use it to execute a few DB2 commands. I've read the documentation and it told me that I must call the db2cmd.exe followed by db2 command I want to execute. Here is an example of a batch file: myFile.bat
@echo off
db2cmd -c -w -i db2 connect to XXXX user XXXXD using XXXX
II copy this batch file to the \SQLLIB\BIN file where the db2cmd.exe file is located, everything works as decribed but if the batch file is located in any other directory, it doesn't work. Calling the db2cmd.exe creates a DB2 command line processor window but with the directory path set to the path where it was called. eg
c:\Testdir\db2cmd.exe
....creates a DB2 CLP window with the dir set to c:\Testdir and the db2 commands will not execute unless the path is set to the SQLLIB\BIN directory. I tried adding a cd c:\...SQLLIB\BIN as the next line in my batch file but it still doesn't work.
It works if I call the batch file like this:
c:\Testdir\db2cmd.exe -c -w -i myFile.bat
...where the bat file has for example:
@echo
db2 connect to XXXX user XXXXD using XXXX
It's a work around but I'd prefer to just call the bat file and do everthing from inside. I read the DB2 UDB scripting on windows and that says that it's possible but it doesn't state if it's possible from chosen directories. Can anyone throw some light on this as I'd be interested to know how to get it to work.
I've created a windows batch file and want to use it to execute a few DB2 commands. I've read the documentation and it told me that I must call the db2cmd.exe followed by db2 command I want to execute. Here is an example of a batch file: myFile.bat
@echo off
db2cmd -c -w -i db2 connect to XXXX user XXXXD using XXXX
II copy this batch file to the \SQLLIB\BIN file where the db2cmd.exe file is located, everything works as decribed but if the batch file is located in any other directory, it doesn't work. Calling the db2cmd.exe creates a DB2 command line processor window but with the directory path set to the path where it was called. eg
c:\Testdir\db2cmd.exe
....creates a DB2 CLP window with the dir set to c:\Testdir and the db2 commands will not execute unless the path is set to the SQLLIB\BIN directory. I tried adding a cd c:\...SQLLIB\BIN as the next line in my batch file but it still doesn't work.
It works if I call the batch file like this:
c:\Testdir\db2cmd.exe -c -w -i myFile.bat
...where the bat file has for example:
@echo
db2 connect to XXXX user XXXXD using XXXX
It's a work around but I'd prefer to just call the bat file and do everthing from inside. I read the DB2 UDB scripting on windows and that says that it's possible but it doesn't state if it's possible from chosen directories. Can anyone throw some light on this as I'd be interested to know how to get it to work.