Solved

code works on xp but not on vista

Posted on 2007-11-28
5
374 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

772 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