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
 SQL Server Administration (2005)
 scheduled task to run batch file

Author  Topic 

mbrutscher
Starting Member

2 Posts

Posted - 2008-11-14 : 20:05:27
I am trying to set up a scheduled task in SQL 2005 to run a batch file every hour. Here is the setup. Basically I want SQL to call the batch file hourly. The batch file then calls a vbscript. The vbscript runs flawlessly if I run it locally. If I run the batch file, with basically just uses cscript to call the vbscript, it also runs flawlessly. The vbscript file just deletes .txt files that are over 2 hours old on a network drive.

Here is the query I have been running:

DECLARE @command_line varchar(255)

BEGIN
SET @command_line = 'F:\scripts\test.bat'
EXEC master..xp_cmdshell @command_line
END

The server is actually a cluster with two servers. The F: drive is actually on a SAN. The batch file, vbscript and files to be deleted are all on the network drive.

Here are the results of the query when I run it:

NULL
C:\WINDOWS\system32>cscript F:\Scripts\del_old_session.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
NULL
NULL
(6 row(s) affected)

It appears that the batch file runs, calls the vbscript

I think I have googled just about every forum I can find for a solution, while some have given me hope none so far have yielded the results I am looking for.

Thanks in advance for any suggestions.

One concern is if the server is actually a cluster that the C: drive where the cscript executable is. Not sure if that is even an issue, more of a shot in the dark ....

mbrutscher
Starting Member

2 Posts

Posted - 2008-11-19 : 16:19:32
Anyone who has viewed this post have any suggestions yet? I would even love any links you could provide.

Thanks ....
Go to Top of Page
   

- Advertisement -