troubleshooting Question

xp_cmdshell : Starting an unattended script

Avatar of blueskybooking
blueskybookingFlag for Canada asked on
Windows 2000Microsoft SQL ServerMicrosoft SQL Server 2008
7 Comments1 Solution1376 ViewsLast Modified:
I have a script that I wish to start using xp_cmdshell.  I would like it to start the script, leave it running and return the user back to the application.  However, it always waits until the script is completed, which is not what I would like.

I'm having trouble getting it to run in SQL Server.  I'm not even sure it's possible.

I've tried start, cmd and %comspec%, all to no avail.  It appears to work fine locally on the machine itself when logged in with RDP.
DECLARE @chrExecute nvarchar (4000)
  DECLARE @intReturnCode int

  SET @chrExecute = 'start /I '
  SET @chrExecute = @chrExecute + 'C:\WINDOWS\SYSTEM32\cscript C:\Maintenance.vbs '

--  PRINT @chrExecute
  EXECUTE @intReturnCode = master..xp_cmdshell @chrExecute, NO_OUTPUT
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros