Problem with PSEXEC when calling a remote DOS Bat file.

  • I'm not an expert in batch scripting. I'm trying to do robocopy of two .sls files on a remote server using .bat files. I'm calling the .bat files remotely using PSEXEC utility. When I call the batch file using PSEXEC it is failing to check the IF condition in the batch file but if I execute the same batch file on local, it is executing as expected.

    Below I copied code and output, can someone correct me if I'm doing wrong anywhere?

    Batch script. (this is a test script)

    ---------------------

    @ECHO OFF

    :Start1

    REM Echo ***************************

    Echo * Copying FNPRD1.SLS file *

    REM Echo ***************************

    FOR %%G IN (D:\Incoming\ABCSRVR\FNPRD1.SLS) DO (

    IF EXIST FNPRD1.SLS (

    echo File %%G Found

    ) ELSE (

    ECHO File %%G Not Found

    SLEEP 1

    GOTO :Start1

    )

    )

    REM Echo ***************************

    Echo * Copying FNPRD2.SLS file *

    REM Echo ***************************

    :Start2

    FOR %%G IN (D:\Incoming\ABCSRVR\FNPRD2.SL1) DO (

    IF EXIST FNPRD2.SL1 (

    echo File %%G Found

    ) ELSE (

    ECHO File %%G Not Found

    SLEEP 1

    GOTO :Start2

    )

    )

    PSEXEC output (When i call the batch file remotely).

    ------------------------------------------------------

    C:\Documents and Settings\ABC>PSEXEC \\BEL-APPRS01 d:\incoming\ABCSRVR\test2.bat

    PsExec v1.94 - Execute processes remotely

    Copyright (C) 2001-2008 Mark Russinovich

    Sysinternals - http://www.sysinternals.com

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Not Found

    ^C

    * Copying FNPRD1.SLS file *

    Local output (when I call the batch file in the local folder)

    -------------------------------------------------------

    D:\Incoming\ABCSRVR>test2

    * Copying FNPRD1.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD1.SLS Found

    * Copying FNPRD2.SLS file *

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    File D:\Incoming\ABCSRVR\FNPRD2.SL1 Not Found

    ^CTerminate batch job (Y/N)? y

    Quick reply highly appreciated...

    thanks

    Jay.

  • While there might be someone here who can answer your question, this is probably not the best site for your question as we are pretty much about SQL Server here.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • 99% likely because the other machine does not have a file/folder D:\... whatever it was ...

    Atlantis Interactive - SQL Server Tools
    My blog[/url]
    Why I wrote a sql query analyzer clone

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply