Connecting Tech Pros Worldwide Forums | Help | Site Map

Using Shell

vdraceil's Avatar
Familiar Sight
 
Join Date: Jul 2007
Location: tamil nadu, INDIA
Posts: 236
#1: Mar 11 '09
Consider,
'Shell "C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" "C:\My Documents\Query.xls"'
This would open Query.xls file in MS Excel for sure,but i have typed manually excel.exe's path in the code. The problem is that i have to run my application in any other computer and i cannot be sure that every computer would have installed excel in the very same path (or not installed at all..).
So,with just knowing the name of the exe file how to find the correct installed path?
(Searching all the drives and folders for excel.exe may be an option,but it may eat up our time and slow down the application)
Anyone has got any alternative ideas?If so pls do share..
All i want to do is open any file with any exe.

Newbie
 
Join Date: Mar 2009
Posts: 1
#2: Mar 11 '09

re: Using Shell


I am not sure if this is going to help you.

You can just try to open the excel file by giving file name. If excel is installed and registered on the machine, the file will open by its own.

or you can use the Process class

Process p = new Process();
p.StartInfo.FileName = "excel";
p.StartInfo.Arguments = // Give full file name here
p.Start();
p.WaitForExit();


make sure you included System.Diagnostic namespace for Process class.
vdraceil's Avatar
Familiar Sight
 
Join Date: Jul 2007
Location: tamil nadu, INDIA
Posts: 236
#3: Mar 14 '09

re: Using Shell


I'm using vb6..I should have mentioned it..i'm sorry
is it .net code?
Reply