Error executing xp_cmdshell in 32 bit env

  • Hi,

    I am trying to execute 32 bit dtexec from 64-bit ssms.

    Give below is the command that i am trying to execute

    exec master..xp_cmdshell '\\<RemoteServername>"\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe"' / f"\\RemoteServername\C$\\Package3.dtsx"'

    I am getting the following error

    '\\CR2DEVSQL01\D$\Program' is not recognized as an internal or external command,

    Please help

    Thanks

    Jayaprabha

  • jayaprabhalnt (12/18/2015)


    Hi,

    I am trying to execute 32 bit dtexec from 64-bit ssms.

    Give below is the command that i am trying to execute

    exec master..xp_cmdshell '\\<RemoteServername>"\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe"' / f"\\RemoteServername\C$\\Package3.dtsx"'

    I am getting the following error

    '\\CR2DEVSQL01\D$\Program' is not recognized as an internal or external command,

    Please help

    Thanks

    Jayaprabha

    Quick question, does the SQL Server Service account have the permissions to access the share?

    😎

  • jayaprabhalnt (12/18/2015)


    Hi,

    I am trying to execute 32 bit dtexec from 64-bit ssms.

    Give below is the command that i am trying to execute

    exec master..xp_cmdshell '\\<RemoteServername>"\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe"' / f"\\RemoteServername\C$\\Package3.dtsx"'

    I am getting the following error

    '\\CR2DEVSQL01\D$\Program' is not recognized as an internal or external command,

    Please help

    Thanks

    Jayaprabha

    Do you see how the command prompt is seeing the command end after the word "Program"? I think you need to check your quotes. Enclose the whole path/filename of the executable in double quotes. I think this is what you're looking for:

    exec master..xp_cmdshell '"\\RemoteServername\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe" / f"\\RemoteServername\C$\\Package3.dtsx"';

    What Eirikur said about permissions also applies. If the permissions aren't there on the remote server, you won't be able to execute the command.

  • Only users with sysadmin rights can use xp_cmdshell exclusively others will get some or the other error.

  • johnwalker10 (12/20/2015)


    Only users with sysadmin rights can use xp_cmdshell exclusively others will get some or the other error.

    That's correct, but the error shown above is not the error they'll get, so I think it's safe to assume that the login has permission to run it.

    You can also be granted permission to execute that stored procedure. I don't do it, but it can be done. I'd much rather create a procedure that does the work necessary and grant the non-sysadmin user privs to execute the procedure.

  • Yes, I have the sysadmin permission.

    I had also tried using the below command. But is is giving the same error.

    exec master..xp_cmdshell '"\\RemoteServername\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe" / f"\\RemoteServername\C$\\Package3.dtsx"';

    I guess it is something to do with the quotes. I had tries different combination of quotes,u still no working.

    Please help.

    Thanks

    Jayaprabha

  • jayaprabhalnt (12/21/2015)


    Yes, I have the sysadmin permission.

    I had also tried using the below command. But is is giving the same error.

    exec master..xp_cmdshell '"\\RemoteServername\D$\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\dtexec.exe" / f"\\RemoteServername\C$\\Package3.dtsx"';

    I guess it is something to do with the quotes. I had tries different combination of quotes,u still no working.

    Please help.

    Thanks

    Jayaprabha

    You are trying to execute the program on a remote server, this is not going to work in this manner via xp_cmdshell, suggest you either use a local install of DTSEXEC or look into PsExec or WMI for the task.

    😎

  • I am getting the same error in the local server also.

    I guess I am missing a quote somewhere.

    please help.

    Thanks

    jayaprabha

  • jayaprabhalnt (12/21/2015)


    I am getting the same error in the local server also.

    I guess I am missing a quote somewhere.

    please help.

    Thanks

    jayaprabha

    The problem is that xp_cmdshell can only take one double quoted parameter.

    😎

    Further, executing the program via file share is not going to work!

  • Eirikur Eiriksson (12/21/2015)


    jayaprabhalnt (12/21/2015)


    I am getting the same error in the local server also.

    I guess I am missing a quote somewhere.

    please help.

    Thanks

    jayaprabha

    The problem is that xp_cmdshell can only take one double quoted parameter.

    😎

    Further, executing the program via file share is not going to work!

    edit: Eirikur is correct, dtexec will not run from a share, I was mistaken.

  • mistaken post removed

  • patrickmcginnis59 10839 (12/22/2015)


    Eirikur Eiriksson (12/21/2015)


    jayaprabhalnt (12/21/2015)


    I am getting the same error in the local server also.

    I guess I am missing a quote somewhere.

    please help.

    Thanks

    jayaprabha

    The problem is that xp_cmdshell can only take one double quoted parameter.

    😎

    Further, executing the program via file share is not going to work!

    I executed a dot.net program (filename.exe) from a share from xp_cmdshell, so it could be site specific (how active directory is configured) on whether you can do that or not.

    Executing a program that has no install dependencies is beside the point, if the program relies on any application extensions, shared libraries, registry values etc. the execution will fail without either a local instance or remote execution via the likes of PS or PsExec.

    😎

  • Eirikur Eiriksson (12/22/2015)


    patrickmcginnis59 10839 (12/22/2015)


    Eirikur Eiriksson (12/21/2015)


    jayaprabhalnt (12/21/2015)


    I am getting the same error in the local server also.

    I guess I am missing a quote somewhere.

    please help.

    Thanks

    jayaprabha

    The problem is that xp_cmdshell can only take one double quoted parameter.

    😎

    Further, executing the program via file share is not going to work!

    I executed a dot.net program (filename.exe) from a share from xp_cmdshell, so it could be site specific (how active directory is configured) on whether you can do that or not.

    Executing a program that has no install dependencies is beside the point, if the program relies on any application extensions, shared libraries, registry values etc. the execution will fail without either a local instance or remote execution via the likes of PS or PsExec.

    😎

    both of my environments have dot.net so that's a very good point I wasn't considering!

  • Got it. It is working now.

    Thanks

    Jayaprabha

  • jayaprabhalnt (12/22/2015)


    Got it. It is working now.

    Thanks

    Jayaprabha

    Good stuff, care to share the solution?

    😎

Viewing 15 posts - 1 through 15 (of 16 total)

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