Solved

Couldn't get process information from remote machine.

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

770 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