Permanently set DB2CLP environment variable

I have a problem with DB2CLP environment variable, on Windows 7 64, IBM_client64_V97 (to be connected with DB2).

Every time when i try to DB2 in Windows command prompt window, I receive this error:

DB21061E Command line environment not initialized.

and per this document using just this step:

2. at the prompt enter these commands:
db2cmd -i -w db2clpsetcp
echo %DB2CLP%
I fix that error, and "db2" command opens Command Line Processor for DB2 Client. But it lasts only until windows CMD is open. As soon as I close it and reopen, I have to repeat process.

My question (being absolute novice to DB2) is:

How should I make that change permanent and
How this happened at the first place as I installed and setup everything according to the manual (including adding local user to DB2USERS and DB2ADMINS) groups?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
Hi Nenad,

When you installed the DB2 client, it should have installed a functional window to the command line processor.  Check here:

  Start / All Programs / IBM DB2 / DB2copy1/ Command Line Processor

Note that DB2copy1 is the default location for the first db2 instance.  The name may be different if you selected the non-default name.

You can copy/paste a shortcut to the CLP on your desktop.

Good Luck!
KPaxAuthor Commented:
Yes I have that (it's installed, and it's working OK) but I thought that should be able to type in windows CDM something like "DB2 ..some command..." but  I got the error I described,
Kent OlsenDBACommented:
That's because the normal DOS (or Windows) prompt doesn't automatically run the setup script that enables the DB2 commands.  When the setup runs, it puts the DB2 items first in the PATH variable.  That could conflict with other tools that also want to be first on the search list.

If you've got both the DOS (Windows) and DB2 command line prompts on your desktop, right click them and select Properties.  You'll notice that the system (DOS) prompt runs cmd.exe.  

The DB2 prompt runs DB2CMD.exe from the DB2 libraries.  The DB2 script then runs DB2SETCP.BAT and finally DB2.EXE.  (All of the DB2 executables should be in C:\Program Files\IBM\SQLLIB\BIN.)

So there are differences in the two prompts.  For you purposes, try running DB2SETCP.BAT from the normal DOS prompt.  That may be sufficient for your needs.

For my purposes I always have the DOS and DB2 prompts on my desktop and just select the one that I need.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.