SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SS2008Re: SQL JOB with xp_cmdshell Security related issue


SS2008Re: SQL JOB with xp_cmdshell Security related issue

Author
Message
chauhanparixit
chauhanparixit
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 185
Hi Friends,
I have migrated SQL JOB from SQL2005 to SQL2008, as below
THe step description as below

IF EXISTS (SELECT * FROM someTable)
BEGIN
Exec master..xp_cmdshell "'c:\mypath\someExecutable.exe'"
END

this someExecutable.exe shoule create 4 image files and 1 word file. if I run this executable from Command Prompt it is working fine.

But if i run the same someExecutable.exe' through a SQL JOB, it is just creating 4 image files but not creating WORD document.

Dont understand why.. actually this job is migrated from SQL 2005 and its working fine there.

it looks like i may require some permission related thing with the executable or OFFICE.

Please provide the solution, i know it's confusing.

Thanks in advance
Parixit Chauhan
Orlando Colamatteo
Orlando Colamatteo
SSCoach
SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)SSCoach (15K reputation)

Group: General Forum Members
Points: 15037 Visits: 14396
chauhanparixit (7/3/2013)
Hi Friends,
I have migrated SQL JOB from SQL2005 to SQL2008, as below
THe step description as below

IF EXISTS (SELECT * FROM someTable)
BEGIN
Exec master..xp_cmdshell "'c:\mypath\someExecutable.exe'"
END

this someExecutable.exe shoule create 4 image files and 1 word file. if I run this executable from Command Prompt it is working fine.

But if i run the same someExecutable.exe' through a SQL JOB, it is just creating 4 image files but not creating WORD document.

Dont understand why.. actually this job is migrated from SQL 2005 and its working fine there.

it looks like i may require some permission related thing with the executable or OFFICE.

Please provide the solution, i know it's confusing.

Thanks in advance
Parixit Chauhan

1. Get rid of xp_cmdshell. You don't need it here.

Job step 1, T-SQL: write the SQL to raise error when no rows exist. In the 'on success' of the job step say 'go to next step' and in the 'on fail' say 'quit job with success'.

Job Step 2, CmdExec: run the executable. On success say 'quit job with success', and on fail say 'quit job with failure.'

As for the executable, do you receive an error when you run it through the job? I assume Word is installed correctly because you said when you run it from the command line it completes successfully. Is the SQL Server 32-bit or 64-bit and did that change from 2005 to 2008? Another thing to check is whether your executable can handle running under 64-bit in case that changed. Some of the Office objects only run under 32-bit.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
chauhanparixit
chauhanparixit
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 185
Just found the resolution of this, actually it was using Word 2003 and the com component does not have any permission for Local system so it was not creating the Word file.

THanks for your time and support
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search