?
Solved

code works on xp but not on vista

Posted on 2007-11-28
5
Medium Priority
?
393 Views
Last Modified: 2010-04-21
The following code (included in the program I'm attempting to upgrade) runs fine on xp, but not on Vista.

Public Sub CheckForExistingInstance()
        Try
            If System.Diagnostics.Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1 Then
                ActivatePreviousInstance(gsBWBackupTitle)

                End
            End If

        Catch
            MessageBox.Show(Err.Number, Err.Description)
           End Try
    End Sub

The error I get is - the error number = 5 and the description is "couldn't get process information from remote machine.."

any ideas?

Thanks!
0
Comment
Question by:stephaniem712
  • 2
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
mastoo earned 1500 total points
ID: 20367430
I assume the error is on this line:

System.Diagnostics.Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName)

GetProcesses takes elevated privileges you probably don't have on the vista box.  You're better off using the application framework's single instance (3.0 framework) or mutex to enforce a single instance.
0
 

Author Comment

by:stephaniem712
ID: 20396669
I found some code using the mutex object.  However, it also includes "process.getcurent process().processname".  I've read about the mutex object, but need some "basic" help with it if this is the route I should take.  Any more ideas out there?  Thanks!!
0
 
LVL 21

Expert Comment

by:mastoo
ID: 20397020
0
 

Author Closing Comment

by:stephaniem712
ID: 31411481
I found the info on the mutex object anf incorporated it in the code which appears to be working.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question