Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 WSCript.Shell Run Command - Problems with quotes!

Author  Topic 

Jarhead104
Starting Member

10 Posts

Posted - 2010-04-23 : 12:26:02
Hey!

Im trying to execute the following commands:

DECLARE @obj int
EXEC sp_oacreate 'WScript.Shell', @obj OUT
EXEC sp_oamethod @obj,'RUN("C:\scripts\SendMailOnTicket.vbs "8" "8" "8" "8" "8" "8" "8" "8" "8" "8" "8" "8"", 0)
EXEC sp_oadestroy @obj
RETURN

The problem here is that the RUN command needs the following syntax:
RUN("<command_here",0)
Now, when I try to execute a command with paramters (and I also have to write the parameters in quotes because they WILL contain spaces) the command above is actually:
RUN("C:\scripts\SendMailOnTicket.vbs "
because the RUN statement thinks the command ends with the first quote of the first parameter.

How can I prevent this?

Thank you!
Best Regards
jarhead104
   

- Advertisement -