Solved

code works on xp but not on vista

Posted on 2007-11-28
5
372 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
5 Comments
 
LVL 21

Accepted Solution

by:
mastoo earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now