xp_cmdshell Issue

  • Hi all

    I must be really tired. I have a script I am trying to execute :

    Exec maser..xp_cmdshell '\\Directory Name\BatchFile.bat'

    Because the Directory name contains spaces, the command fails.

    I have tried double quotes, multiple single quotes etc...

    Any ideas will be appreciated..

    Michael.

  • Hi,

    Try this,

    Exec matser..xp_cmdshell '"\\Directory Name\BatchFile.bat"'

    Let us know if this works for you.

     

    Regards,

    Jagga

  • if you are using SQL 2005, why not try using a CLR assembly with EXTERNAL_ACCESS

    but the one by JG should work. matser -> master


    Everything you can imagine is real.

  • Your format is wrong, the command could be:

    master..xp_cmdshell '\\Server\Share Folder\Something.bat' -

    ('\\...' is a server path)

    or

    master..xp_cmdshell 'C:\Local Folder\Something.bat'

  • Something else to try:

    master..xp_cmdshell 'C:\"Local Folder"\Something.bat'

Viewing 5 posts - 1 through 4 (of 4 total)

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