Solved

Couldn't get process information from remote machine.

Posted on 2006-07-23
4
971 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
  • 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

11 Experts available now in Live!

Get 1:1 Help Now