Get process full path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I want to check if in this computer have outlook a programe.
If yes -->
System.Diagnostics.Process.Start ("OUTLOOK.EXE");

How to check if no??
if no --> some msg...
How can I check it?
How to get OUTLOOK.EXE path and ask:
File.Exists(path)

I'm using vs.net 2003
Thank's,
Yael.
 
Yael,

Are you trying to get the path to Outlook so that you can just open it,
or do you want to actually do something with it once you open it? Either
way, I think you should use automation to create a new instance of the
Application class for Outlook, and then work from there.
 
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft
\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", false);
string path = (string)key.GetValue("Path");

HTH :)


Yael je napisao/la:
 
Thank's It's working to me when I'm running this on my local driver, but if I
run this OutlookChecker.exe (my c# project) on the server I get this error
Error:
An unhandled exception of type 'System.Security.SecurityException' occurred
in OutlookChecker.exe
================= Start Code =================
private void isOutlook()
{
Microsoft.Win32.RegistryKey key =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\microsoft\\windows\\currentversion\\app paths\\OUTLOOK.EXE");

string path = (string)key.GetValue("Path");
if( path != null)
System.Diagnostics.Process.Start("OUTLOOK.EXE");
else
MessageBox.Show("There is no Outlook in this computer!","System
Error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
================= End Code =================

I tryed to run only this line, this is running good, seams like RegistryKey
problem??
MessageBox.Show("There is no Outlook in this computer");


Additional information: Request failed.
 
Yael,

When you run it on the server, are you keeping the program on a share
and then running it from there? If so, the runtime prevents the registry
key class from running, as anything not on the local machine by default is
considered potentially harmful.

Because of this, you would have to go to the .NET Administration utility
in Administrative Tools and set the code policy for the application so that
the app has the rights you need to run on the local machine.
 
Back
Top