vb.netvisual-studio-2010batch-filepsexec

Run interactive batch in Visual Studio post build events


I have a program written in vb.net. After I build, I want to launch an interactive batch file that executes a psexec command remotely. How can I do that? this is my post build event:

call "$(ProjectDir)ExecOnGw.bat"

And this is my batch that if it runs in a normal command prompt, execution is ok.

c:\Sysinternal\psexec.exe \\gateway "C:\Remotepath\mybatch.bat" -u mydomain\myuser -p ******
pause

This batch calls another batch on a remote machine that does something, then if I want to exit, I have to press a "q" and "Enter". In a normal command prompt, it works fine. But in a Visual Studio post build event it goes down. Help me!


Solution

  • I've done this before using the start command. I created a simple pause.bat file to demonstrate:

        @echo off
        pause Press Any Key
        exit
    

    If I put this in the post build event, I see a console that just closes.

    call pause.bat
    

    If I use this instead, I get a second console window that takes my input before closing.

    start "My Process" /D c:\batch /WAIT pause.bat