Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run an exe by client remotely on server using vb6

I'm using code below to execute my commands in cmd. Which is actually made for running an exe on my server.

Private Sub Command1_Click()
    Dim FN As Integer
    FN = FreeFile
    'DOS COMMANDS
    ServerName = "\\mydbserv"
    ExePath = """d:\myfolder\my.exe"""
    UserName = "myserver\myuser"
    Password = "mypass"
    MyCommand = "psexec " & ServerName & " -u " & UserName & " -p " & Password & " -i " & ExePath
    'Open Bat file
    Open "C:\Mybatc.bat" For Output As #FN
        Print #FN, "cd c:\Users\myuser"
        Print #FN, MyCommand
        Print #FN, "Exit"
    Close #FN
    'Activate
    result = Shell("C:\Mybatc.bat", vbHide)
    End
End Sub

everything was fine until i seen that cmd is not getting closed when process is done. and the worse is the exe i was trying to run remotely also not stops. When i check the cpu usage it always shows "00" doesnt even starts.. It shows like working for ever but never works actually. So my question is :

  1. Why i cant run this exe file remotely? (or why it just shows like running)
  2. How can i remotely run and close when finished this exe file on server?
  3. How can i close the window and process when finished on my pc as well?
like image 455
Berker Yüceer Avatar asked Jan 18 '26 12:01

Berker Yüceer


1 Answers

How about this?

  1. install Windbg on the server.
  2. config the windbg auto attach to your exe, when your exe is ready to running. http://ask.brothersoft.com/image-file-execution-options-debugger-83827.html
  3. running your script
  4. after your exe is started, the windbg will attach to it.
  5. input 'g' in the windbg command, let your exe to running.
  6. wait until you think it should finished
  7. ctrl-break to let the process hang on
  8. input '~*kb' to windbg command, to see what's going on in every thread, to find out why they are waiting, and what they are waiting for?
like image 188
whunmr Avatar answered Jan 21 '26 08:01

whunmr