Program start problem

This is the probelm, we have a software at work wich we has the possibility to add CAD drawings.
Now we have a few different cad programs since not everyone needs to edit them and well licences are not cheap.
I basicly need something that does the following,

when our main program "opens a cad" it would not call for example AutoCAD but this little script that first checks if the user has AutoCAD, AutoCAD Mec or the simple viewer installed and then lauches that one.

So basicly,

1. Check autocad, if installed launch if not next
2. Check autocad mecanical, if installed launc if not next
3. Check VoloView, if installed launch if not exit with a MsgBox saying you have no viewer.

And on top of that the script still needs to know wich cad file the main program wanted to open.

I'm really new to VB so any help is usefull.

Cheers,

Diezel
[922 byte] By [Diezel] at [2007-11-18 20:28:28]
# 1 Re: Program start problem
You might find some registry keys that could be unique for those
Pc that have a version of autocad installed.

If you're able to find, you make an exe that pass the
Command$ (=parameter passed when called) to the autocad
found (if any).
That is:
You associate your program with the extension of autocad
files so that when somenone doubleclick one of those file,
your program should be invoked with Path\Filename as
parameter.
Your program then check the registry, and decide if shell to
which version of autocad (if any) with the received path\name
as parameter...
Cimperiali at 2007-11-9 23:07:46 >
# 2 Re: Program start problem
The problem is the program that calls on the CAD program.
The only way for it to work is that you manually set the Path to the cad program. And this has to be exactly the same on every machine. Dumb program I know.
And since we have a little over 60 workstations I'm not really fond of the idea to list maybe over 3 records of the same document in the database just so every user could have a possibility to open the document. This because I have to insert over 3000 documents as it is and if I have to manually do 3 times the work I'm not happy ;)
There is no way to change the database software so I need to solve this some other way.
And the users here, well let's put it like this, most over 45 and know nothing about computers and don't really want to know anything either.
So I need to automate this somehow.
One way would be to "alias" the cad executable in Windows but I have no idea how to do that.
Diezel at 2007-11-9 23:08:52 >
# 3 Re: Program start problem
Originally posted by Diezel
The problem is the program that calls on
the CAD program. The only way for it to
work is that you manually set the Path
to the cad program.

You sure? If Cad program is in a fodler that is
included in Environment Path, it should be
enough to shell the program, and it should be
found...
Cimperiali at 2007-11-9 23:09:47 >
# 4 Re: Program start problem
Very sure. It's a relly ****ty program. I don't think it's even planned for a company as large as this one.
The CAD program may put in something in the enviroment but the porgram used to access theese files are made in a dumb way.
As the program administrator I set where the program used to access a certain type of a file is, and it has to be located in the same folder on evry machine. Otherwise it won't open it.
You can ask yourself what the programers tought of when they made this program.
I managed to use shell and Errorhandler to jump between the tests so it seems to work in some way now.
Thanks any way.

// Diezel
Diezel at 2007-11-9 23:10:46 >
# 5 Re: Program start problem
Originally posted by Diezel
You can ask yourself what the programers tought of when
they made this program.

:p

I usually think about people who will use the software I am
developing...may be you did not offer them a cup of coffee...
;)
Cimperiali at 2007-11-9 23:11:46 >
# 6 Re: Program start problem
Actually we are not the only ones using this software. So this is a product of idiotic planing. Maybe I'll just take a year of and write up one on my own.
Well I can now get Cad and Volo viewer to start but I have a huge problem.
It does not open the file. So I need to get what ever parameter the Arttu program is giving CAD when starting it probably file location and pass it to cad when im starting it.
Any idea of how this could be done?

// Diezel
Diezel at 2007-11-9 23:12:52 >
# 7 Re: Program start problem
Some more info, the Cad caller starts Cad like this
C:\path\to\cad.exe \\server\cad\draw.dwg I need to get the \\server\ part into my script and send it to Autocad when I'm starting it...Any ideas here?
Diezel at 2007-11-9 23:13:57 >
# 8 Re: Program start problem
In XP this info is easily accessable through the registry. Look in the HKEY_CURRENT_USER\Network

registry key. There will be sub keys like F, Q, R... These are the drive letters.

In the RemotePath value, you will find the server.

Hope this helps.
sotoasty at 2007-11-9 23:14:54 >
# 9 Re: Program start problem
Actually that might be a good idea but we are still working with NT at work.
Almost 70 desktops and every one of them still running NT 4.0.
Is there really no way to read a "switch" it could just as well be
C:\path\to\program.exe d:\cads\cad.dwg
c: defines where the program starts and by giving the d:******** you define where the CAD drawing is located.

Thanks to everyone who replied.

// Diezel
Diezel at 2007-11-9 23:15:58 >
# 10 Re: Program start problem
Ok now,

I get the file into my script by

variable = Command()

So that problem is out of this world. I can finally run and get the program to do almost everything I want it to do.
I only have one very simple question anymore.

I set the file to be opened to a variable called File
So now I want to have the program write the File variable after the shell command.
Shell("c:\AutoCAD 2004\aclt.exe",1)

I need the file variable to be "printed" out after aclt.exe so that AutCAD knows wich file to open.

I think this is simple but I just can't figure out how
Diezel at 2007-11-9 23:16:56 >
# 11 Re: Program start problem
Got it,

just put the sting in a variable and then
Shell(Variable,1)

Finally...
Thanks everyone

//Diezel
Diezel at 2007-11-9 23:18:00 >
# 12 Re: Program start problem
Diezel - its really good to see someone who continues to work on their problem AND posts all the steps they are doing.

Well done for finding the solution, and special :wave: thanks :wave: for posting your process of solving the problem. More people should do what you've done.
Twodogs at 2007-11-9 23:18:59 >
# 13 Re: Program start problem
(that's why I gave this thread 5 stars)
:cool:
Cimperiali at 2007-11-9 23:20:01 >
# 14 Re: Program start problem
Since I've been using communities for knowledge for a long time I've learnt that the only way to keep forums from getting full of posts that can't help anyone is by allways informing of the whole process AND the sollution.
If you leave out the final sollution it's no use for anyone who uses the search function.
If you keep posting sollutions, one day the forum will be a very nice manual for everyone.
Ofcourse google is a great thing but there is just SO much information and finding what you need might sometimes be hard.
Thanks to all of you, and as I said, I'm not really a VB person. More like a C++ person, but scripting with VB and some small programs like this one are allways nice to make in VB.
Besides, the company I work for right now doesn't have anything else than VB 5 Pro and the VB editor in *cough* Office 97. ;)
But we do have a blast furnace...
Have a nice weekend,

Diezel
Diezel at 2007-11-9 23:21:01 >