Solved

Couldn't get process information from remote machine.

Posted on 2006-07-23
4
980 Views
Last Modified: 2008-02-26
Hi,

I have a button on my Win form "Export to Excel". This button:
a. Will first check if the file "Mydata.xls" is already open. This is done using the processes in Task Manager.
b. If file already open, prompt user to close file.
c. Export the grid data to MyData.xls file
d. Open this file in Excel.

I tested my app with administrator login and I also created comp1 user as normal user and found that it works ok.

But at my clients end, with administrator login, it works ok but with normal user it gives error: Couldn't get process information from remote machine.

But with the same normal user, they can open the Excel application which means that they have sufficient rights to access Excel app. Then why do we get error when opening the file with regular user.

My feeling is that the problem should be in (a) or (d). What is the solution?

Regards,
Vilas

0
Comment
Question by:vj_mi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Shakti109
ID: 17164627

Wthout seeing the code, from what you describe, it looks like possibly in your code you are trying to get the running processes on a remote machine instead of the local system.

Everyone has rights to the local machine to list processes, so the only thing i can think of is that in your function to list them you have a remote target. I know I do things like this when I am testing my functions/apps before I distribute them.

Can you post the snippet of code that is looking for the processes?

0
 
LVL 6

Accepted Solution

by:
manch earned 500 total points
ID: 17165475

What i think that ur normal user is not having rights of fetching the processing informations (from taskbar).

like u have written that u r checking ur File Open condition (Excel file is opened or not) from processes in Task Manager
probably ur normal user is not having writes of checking all the processes of the task bar.

if u will give ur code that will be much helpful for us to find.

0
 

Author Comment

by:vj_mi
ID: 17166256
Hi,

Below is the code posted. Please note one more thing. This piece of code is copied from Module A into Module B. Same code is working in Module A. Then why not for Module B?

Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
        Dim strFileName As String = "DBUpdate_History.xls"

        Try
            strFileName = "C:\" & strFileName

      'Check if file is already open
            If CheckOpenFile(strFileName) = False Then
                Exit Try
            End If

            ExportTo(New ExportXlsProvider(strFileName))     'ExportXlsProvider is third party grid


            Try
                Dim process As New System.Diagnostics.Process
                process.StartInfo.FileName = strFileName
                process.StartInfo.Verb = "Open"
                process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
                process.Start()
            Catch
                MessageBox.Show(Me, "Cannot find an application on your system suitable for openning the file with exported data.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

        Catch objExc As Exception
            Me.Cursor = Cursors.Default
            MessageBox.Show("Error while opening file for export!", MSG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Finally
        End Try

    End Sub


 Private Sub ExportTo(ByVal provider As IExportProvider)
        Dim currentCursor As Cursor = Cursor.Current
        Cursor.Current = Cursors.WaitCursor

        Dim link As BaseExportLink = SG_ViewDBUpdateHistory.CreateExportLink(provider)      'Third party grid
        link.ExportTo(True)

        Cursor.Current = currentCursor
    End Sub



    Public Function CheckOpenFile(ByVal strFileName As String) As Boolean
        'Read all process from Windows task manager
        Dim proc As Process
        Dim intIndex As Integer

        Try

            For Each proc In Process.GetProcesses

                If proc.ProcessName.ToUpper.IndexOf("EXCEL") > -1 Then
                    'This indicates Excel app is running

                    intIndex = strFileName.LastIndexOf("\")
                    strFileName = strFileName.Substring(intIndex + 1)

                    If proc.MainWindowTitle.IndexOf(strFileName) > -1 Then
                        'This indicates our Generic Excel Excel file is open
                        MessageBox.Show(strFileName & " sheet is already open. First close the open file!", MSG_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error)
                        Return False
                    End If
                End If
            Next

            Return True

        Catch ex As Exception
            Return False
            MessageBox.Show("An error occurred while checking if file is open!", MODULENAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        Finally

        End Try

    End Function




    Public Function GetRecentFolderPath() As String
        Dim regVersion As RegistryKey
        Dim keyValue As String
        Dim Result As String

        Try

            keyValue = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"
            regVersion = Registry.CurrentUser.OpenSubKey(keyValue, False)

            If (Not regVersion Is Nothing) Then
                Result = zVarToStr(regVersion.GetValue("Personal", 0))
                regVersion.Close()
            End If

            Return Result

        Catch objExc As Exception
            MessageBox.Show("An error occurred while reading path to save the file!", MODULENAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        Finally
        End Try

    End Function
0
 

Author Comment

by:vj_mi
ID: 17272373
Hi,

I further found that the processes can be read. Excel file is also created. But when we try to access Excel app to open the exported file, it gives error. But the same logged-in user we can open Excel file from outside the app. What surprises me is:
a. The code is copied from my module A into Module B. It works well in module A.

b. With the same logged in user, client can open Excel app and any excel files.

Some more info: Client is using Windows 2003 server and XP client.

I also found that the error is in:
 Dim process As New System.Diagnostics.Process
                process.StartInfo.FileName = strFileName
                process.StartInfo.Verb = "Open"
                process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
                process.Start()


Regards,
MI
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with preventing selection from a combobox 11 41
Need syntax help building hyperlink 2 41
ModalPopup  question 22 39
Filtering a datagrid view 8 34
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

726 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