views:

207

answers:

3

I have multiple databases that I connect to using SQL*Plus in Windows (not the command window).

I've been looking for a way to change the title of the window, so that I can distinguish one instance from another, from the task bar. Yes, I know I can change the prompt, but then I have to switch between the instances and read the prompt, until I get to the right one.

Is this even possible? And if so how?

A: 

for sqlplus.exe, as you know, you can use glogin.sql (in the sqlplus directory of your Oracle client) to run sqlplus commands at the start of your session.

you could also try the HOST command from within sqlplus to execute commands on your shell:

HOST title [my db name]

you can try to put this call into the glogin.sql (as well as your custom prompt).

edit:

for sqlplusw, i have seen here a 'solution' that suggests creating shortcuts for each server you wish to connect to, and windows will take the title of the short cut for the title of the window.

akf
I'm running the Windows version not the command line version.
Brad Bruce
erm... the Windows version IS a command-line version - in fact sqlplus has always been command-line...
Jeffrey Kemp
OK sqplusw.....
Brad Bruce
A: 

There are utilities that allow you to change the title (and other properties) of any window.

One free one is WindowWatch. Others can be found with a quick Google.

I don't have SQL*Plus installed so I don't know how well they work with it.

Dave Webb
Thanks for the suggestion. When I looked at the problem from outside the app instead of inside, things got easier.
Brad Bruce
+1  A: 
[DllImport("user32.dll", SetLastError =true, CharSet =CharSet.Auto)]
static extern IntPtr SetWindowText(IntPtr hwnd, String lpString);

Process process = new Process();
process.StartInfo.FileName = "sqlplusw";
process.Start();
process.WaitForInputIdle();
SetWindowText(process.MainWindowHandle, "PRODUCTION - BE CAREFUL!!");

I was able to cobble together a wrapper that does what I wanted. Now to make it more general purpose....

Brad Bruce