none
Run exe file from domain controller RRS feed

  • Question

  • Hi,

    I'm writing a Windows Form app that needs to be deployed on our Domain Controller.  The app monitors all clusters within the domain by running an executable file on each cluster.  The cluster app is another Windows Form app that  resides in each cluster; the DC is supposed to execute the cluster app remotely.  I've created  cluster checkboxes for selection; then clicking the "Start Monitor" button,  cluster apps should execute in the selected clusters.  This domain does not have Internet access, so it's "off-the-grid".  The DC has Windows Server 2012 R2 operating system.  The clusters vary:  Windows 7 Enterprise, Windows 7 Professional, and Windows 10 Professional.

    There are over 100 clusters connected to this DC.  What the separate cluster app does is upload some local performance metrics to a database located in the DC. 

    Problem:  I used PSEXE from SysInternals but it doesn't launch the cluster app Windows Form.  Without it actually running as an app, it doesn't upload their metrics to the DC.  Remotely calling a command using PSEXEC simply runs it without launching the cluster app Windows form.  However, in Resource Monitor, the process is shown as running.  Although it's running when viewed in the Resource Monitor, it doesn't upload their status to the SQL Server database in the DC.  In fact, it doesn't do anything at all.  So confusing.

    My PSEXEC script is as follows:

                If DirectCast(ctrl, CheckBox).Checked = True Then
                            System.Threading.Thread.Sleep(100)
                            index = DirectCast(ctrl, CheckBox).Tag
                            Dim p As New ProcessStartInfo
                            p.FileName = "cmd.exe"
    
                            If Mainform.RbtnName.Checked Then p.Arguments = "/c psexec -accepteula \\" & computer_name(index) & ".insect.bug -i -d -realtime " & creds & " C:\Cluster\Client_monitor.exe"
                            If Mainform.RbtnIp.Checked Then p.Arguments = "/c psexec -accepteula \\" & IP(index) & " -i -d -realtime " & creds & " C:\Cluster\Client_monitor.exe"
    
                            ' Use a hidden window
                            p.WindowStyle = ProcessWindowStyle.Hidden
    
                            ' Start the process
                            Dim myprocess As New Process
                            myprocess = Process.Start(p)
                            Mainform.Status.Text = p.Arguments
                            Mainform.Refresh()
                        End If

    Is there a better way to run an executable file from the Domain Controller that would actually launch the Windows Form app in each selected cluster?  The above runs the process but the Windows Form is not running.

    Appreciate any help.


    Marilyn Gambone



    • Edited by deskcheck1 Tuesday, November 26, 2019 1:42 PM
    Tuesday, November 26, 2019 1:36 PM

Answers

  • Hi,

    I didn't change my basic codes above.  What I found is that I should point the location of the executable file (in this case Client_Monitor.exe) to a folder under the User name whose account is used to log in to the cluster.  So instead of "C:\cluster\Client_Monitor.exe", I changed it to "C:\Users\username\Desktop\Client_Monitor.exe"

    Another thing, I need to ensure that the Windows Time services is in sync with the Domain Controller.  Otherwise, Kerberos doesn't seem to log in the user account.

    With these two adjustments, the code runs.  Caution:  do not expect the actual Windows Form app to display.  SysInternal commands run as background processes.  What matters to me is that the app posts and updates the backend database.


    Marilyn Gambone

    • Marked as answer by deskcheck1 Tuesday, December 3, 2019 9:43 PM
    Tuesday, December 3, 2019 9:43 PM

All replies

  • After much research on this topic, I found that although it's possible to execute a process or command line on a remote machine, Windows does not allow you to view the form for security reasons.  I've tried using PSEXEC, Powershell, SSH and they all run the process in "silent" mode.  With PSEXEC, although it has an -i switch, the Windows Form still won't show.  The problem with these three options (PsExec, Powershell, SSH) is that although the process seems to run as shown in Resource Monitor, they don't interact with the backend SQL Server database.  So this was no use to me.  I could live with the form not showing, but I need for the executable file to actually perform what it does, upload data to the database.

    Then I came across using WMI from here.  Using the sample codes in there and another one here, I was able to run my executable on our remote computers. WMI doesn't show the form, either.  But it interacts with our backend database.

    There aren't many solutions available.  But this seems to work for me so far.


    Marilyn Gambone


    • Marked as answer by deskcheck1 Wednesday, November 27, 2019 3:26 PM
    • Edited by deskcheck1 Wednesday, November 27, 2019 3:33 PM
    • Unmarked as answer by deskcheck1 Friday, November 29, 2019 3:54 PM
    Wednesday, November 27, 2019 3:25 PM
  • I thought I laid this issue to rest but it's not working again.  It only worked when I first run the command.  But subsequent calls, wasn't doing anything.

    So, I went back to using PsExec from SysInternals.  It seems like PsExec can only run executables in Console Applications but NOT executables for Windows Forms applications.  Given this, what other options do I have to execute a Windows Form executable on a remote computer?

    Any help would be greatly appreciated.


    Marilyn Gambone

    Friday, November 29, 2019 3:58 PM
  • Hello,

    since I have no relevant experience, I may not be able to solve this problem. After looking up the information, I found that someone asked a similar question that "Execute exe on remote machine".

    https://stackoverflow.com/questions/25782308/execute-exe-on-remote-machine

    I hope this is helpful to you.

    Best Regards,

    Julie


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, December 3, 2019 6:42 AM
    Moderator
  • Hi,

    I didn't change my basic codes above.  What I found is that I should point the location of the executable file (in this case Client_Monitor.exe) to a folder under the User name whose account is used to log in to the cluster.  So instead of "C:\cluster\Client_Monitor.exe", I changed it to "C:\Users\username\Desktop\Client_Monitor.exe"

    Another thing, I need to ensure that the Windows Time services is in sync with the Domain Controller.  Otherwise, Kerberos doesn't seem to log in the user account.

    With these two adjustments, the code runs.  Caution:  do not expect the actual Windows Form app to display.  SysInternal commands run as background processes.  What matters to me is that the app posts and updates the backend database.


    Marilyn Gambone

    • Marked as answer by deskcheck1 Tuesday, December 3, 2019 9:43 PM
    Tuesday, December 3, 2019 9:43 PM