Powershell Sqlcmd popup in c#

761 Views Asked by At

I have a PSHost object executing a Powershell script myscript.ps1 and that .ps1 script is executing sqlcmd.exe to get what it needs done. Is there a way to keep it from popping up empty sqlcmd dos prompts (as it seems to do)?

2

There are 2 best solutions below

0
On

instead of calling sqlcmd.exe why not just call the Invoke-SQLCmd cmdlet that comes when you install SSMS?

0
On

For example: http://blog.sapien.com/index.php/2006/12/26/more-fun-with-scheduled-powershell

You're going to have to wrap sqlcmd.exe in something else as PowerShell isn't able to AFAIK.

From a scripting perspective, this does change for powershell.exe in v2, but I'm not sure that is available in SDK for custom hosts.