code works on xp but not on vista

Posted on 2007-11-28
Medium Priority
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()
            If System.Diagnostics.Process.GetProcessesByName(Process.GetCurrentProcess.ProcessName).Length > 1 Then

            End If

            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?

Question by:stephaniem712
  • 2
  • 2
LVL 21

Accepted Solution

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


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.

Author Comment

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!!
LVL 21

Expert Comment

ID: 20397020

Author Closing Comment

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

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

624 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