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.
| Author |
Topic |
|
mprolli
Starting Member
24 Posts |
Posted - 2004-12-16 : 10:45:56
|
| I'm trying to run either ActiveX (vbscript) or a BAT file from a Stored procedure. Is this possible? What I'm trying to do is, create a directory if it doesn't exist, and if it does exist, then delete all of the files in that directory. The BAT file runs successfully, if created as a BAT file, however, when I try to use the xp_cmdshell, it says it completes successfully, but, nothing is created or deleted. declare @cmd varchar(4000)set @cmd = ' rem testing to see if a folder exists if not exist c:\TESTFOLDER goto foldernotfound if exist c:\TESTFOLDER goto folderfound :foldernotfound MD C:\TESTFOLDER :folderFound DEL /Q C:\TESTFOLDER\*.* :end'exec master..xp_cmdshell @cmd, NO_OUTPUTThanks in advance.Let us rise up and be thankful, for if we didn't learn a lot today, at least we learned a little, and if we didn't learn a little, at least we didn't get sick, and if we got sick, at least we didn't die; so, let us all be thankful. --Buddha |
|
|
mprolli
Starting Member
24 Posts |
Posted - 2004-12-16 : 14:20:09
|
| 7 reads and no replies, either noone knows the answer(which I find very hard to believe, with all the intellegent people here) or noone wants to tell me the answer....Let us rise up and be thankful, for if we didn't learn a lot today, at least we learned a little, and if we didn't learn a little, at least we didn't get sick, and if we got sick, at least we didn't die; so, let us all be thankful. --Buddha |
 |
|
|
mprolli
Starting Member
24 Posts |
Posted - 2004-12-16 : 16:06:34
|
| and in case anyone is wondering, the reason why I'm not just calling the BAT file is because, I need to pass parameters to it.Let us rise up and be thankful, for if we didn't learn a lot today, at least we learned a little, and if we didn't learn a little, at least we didn't get sick, and if we got sick, at least we didn't die; so, let us all be thankful. --Buddha |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2004-12-16 : 16:36:59
|
| You can call this as one DOS command:if not exist c:\TESTFOLDER (MD C:\TESTFOLDER) else (DEL /Q C:\TESTFOLDER\*.*)Putting parentheses around DOS commands lets you group them together so they execute properly. |
 |
|
|
mprolli
Starting Member
24 Posts |
Posted - 2004-12-17 : 09:33:19
|
| Thanks rob...Appreciate it.Let us rise up and be thankful, for if we didn't learn a lot today, at least we learned a little, and if we didn't learn a little, at least we didn't get sick, and if we got sick, at least we didn't die; so, let us all be thankful. --Buddha |
 |
|
|
|
|
|
|
|