Not able to run an exe file

  • Hello There,

    Please help me with the below issue.

    I have an exe file which will create an excel file after processing some task on c:\xxx\yy\zzz\filename.xls

    When i run this exe from the command prompt it works fine and the file is created, however when i run the same exe through below script

    DECLARE @exePath NVARCHAR(100),@cmd NVARCHAR(300)

    SELECT @exePath = p_value FROM tbl_parameters WHERE p_id = 8

    SET @cmd = @exePath+' "'+@@SERVERNAME+'" "'+DB_NAME()+'" 1'

    exec xp_cmdshell @cmd

    it fails with the error

    'c:\xxx\yy\zzz\filename.xls' could not be found. Check the spelling of the file name, and verify that the file location is correct.

    If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.

    additional info::The sql service is running on admin privileges and has full access to C Drive.

  • Does the folder "c:\xxx\yy\zzz" exist on the server where SQL Server is running?

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • yes, it exists and the account on which sql service is running has full access to the path.

  • Does executing the below query generate any errors?

    xp_cmdshell 'dir c:\xxx\yy\zzz\filename.xls'

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Yes, I posted the error in my first mail in bold letters.

  • Did you try launching the exe under the credentials of the service account (by logging on to the server using service account / using "Run as" for the exe)

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

  • Yes, i did that and it executed well.

  • Since you are able to execute that file under the credentials of service account, permissions issue is ruled out.

    Does the folder or file has spaces in between or the length of the folders is too long? The below query should execute if that is the case.

    xp_cmdshell 'dir "c:\xxx\yyy" '

    Pradeep Adiga
    Blog: sqldbadiaries.com
    Twitter: @pradeepadiga

Viewing 8 posts - 1 through 7 (of 7 total)

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