﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by Haidong Ji / Article Discussions / Article Discussions by Author  / Using VBScript to Automate Tasks / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 04:12:15 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Great code.. so great and I am trying to use it!  How would I run this against multiple locations (servers) without having to create a completely different job? Right now my "totally stolen" code looks like this:Hello,Sorry to bother you.. but I am trying to use some code you posted long ago in 2008.  It worked great but I am trying to remove files from 2 different locations (servers).  I was hoping you can help me..Right now my code looks like this..Option Expliciton error resume next	Dim oFSO	Dim sDirectoryPath	Dim oFolder	Dim oFileCollection	Dim oFile	Dim iDaysOld'Customize values to clear Reports'Question is here.. how do I loop around to grab a second location?	iDaysOld = 90	Set oFSO = CreateObject("Scripting.FileSystemObject")	sDirectoryPath = "\\LIBERTY\Tailsheets"	set oFolder = oFSO.GetFolder(sDirectoryPath)	set oFileCollection = oFolder.Files'Walk through each file in this folder collection. 'If it is older than 3 months (90) days, then delete it.	For each oFile in oFileCollection		If oFile.DateLastModified &amp;lt; (Date() - iDaysOld) Then			oFile.Delete(True)		End If	Next'Clean up	Set oFSO = Nothing	Set oFolder = Nothing	Set oFileCollection = Nothing	Set oFile = NothingAny ideas?Thanks,Marvin</description><pubDate>Sat, 10 Jul 2010 14:13:24 GMT</pubDate><dc:creator>m_rios75</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>It makes more sense to me to use a DATEDIFF vb function instead of assuming it will add days to the returned date.  This also allows you to be explicit about which date part you want; days, minutes, weeks and so on...  For you Unix / Linux nerds, you may notice I am using bzip2 (a win32 port) which compresses the files much better (and free) than any PKZip variant.I did a little script similar to yours (I was amazed about how similar it was) about six months ago, here's what is looks like:Option ExplicitConst strBackupExt = ".bak.bz2"Const strDir = "C:\Powerclean\Backups"Dim fsoDim vFolder as VariantDim vFile as VariantSet fso = CreateObject("Scripting.FileSystemObject")Set vFolder = fso.GetFolder(strDir)For each vFile in vFolder.Files    If Right(vFile.Name, 8) = strBackupExt Then        If DATEDIFF(d, vFile.DateLastModified, Now) &amp;gt; 30 Then            vFile.Delete(True)        End If    End IfNext vFile</description><pubDate>Tue, 29 Jul 2008 14:48:49 GMT</pubDate><dc:creator>lrhyrne</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Could someone send me the link please(or post it again)...this sounds exactly what I have been looking for (and banging my head against the wall trying to figure out others) and from all the comments I'm reading I am anxiously anticipating being able to simply add this to a SQL job step!!MANY thanks!!</description><pubDate>Thu, 10 Apr 2008 15:28:04 GMT</pubDate><dc:creator>ImyaHuckleberry</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Good stuff Truckin! Thanks for sharing.For the record, I am not religious on any particular technology or scripting languages. Whatever suits the needs and get the job done, and easy to read and maintain, more power to you, I am all for it. Be it JavaScript, VBScript, WMI, PowerShell, Perl, whatnot. I think they all have their places. I am totally digging Perl at the moment.I originally wrote this article maybe 5 years ago. It is actually surprising, and rewarding at the same time, that so many people find it useful.Happy scripting everybody!</description><pubDate>Tue, 11 Mar 2008 15:33:45 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>I don't wish to denigrate vbscript in any way, I probably should use it more, the results are certainly easier to read than some of the stuff I do.  For the record, I had to schedule a job to delete old files and a quick look up in the operating system help and I did this:Forfiles -p D:\backup /m *.*  /d -21 /c "cmd /C del @Path"I titled my scheduled job RemoveOldBackups  so I still have some reasonable idea of what this line does. (I just used 21 days to match the example provided.)</description><pubDate>Tue, 11 Mar 2008 14:57:50 GMT</pubDate><dc:creator>Truckin</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Now... THAT I absolutely agree with!  And for the very same reasons!</description><pubDate>Tue, 11 Mar 2008 08:58:40 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>[quote][b]Jeff Moden (3/11/2008)[/b][hr]I say again... Just like SQL allows itself to take any form... or Java... or... I've seen some absolutely gorgeous VBS both formatting wise and code wise.  I've also seen my fair of VBS where the "S" stands for a 4 letter word ;)[/quote]Oh, I've seen some "pretty" VBScript, too (manually-formatted and all).  But that doesn't improve its structure.  If you want to compare it to SQL - it's like starting from a SQL data model where every column is a varchar(max)...I suppose I've seen it tortured more than is natural.  I see it a bit like you do with CLR in SQL - should be restricted to very specific items (read - very FEW items).</description><pubDate>Tue, 11 Mar 2008 08:36:33 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>I say again... Just like SQL allows itself to take any form... or Java... or... I've seen some absolutely gorgeous VBS both formatting wise and code wise.  I've also seen my fair of VBS where the "S" stands for a 4 letter word ;)</description><pubDate>Tue, 11 Mar 2008 07:57:40 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>[quote][b]Jeff Moden (3/10/2008)[/b][hr]Heh.... Just like SQL allows itself to take any form... or Java... or...[/quote]Touche.  I worded that poorly.  It's not so much that you can write poor code in VBScript (you can do that anywhere as you pointed out) - it's just that it's almost impossible to build something WELL in it.My perception is that that VBScript doesn't really allow you to build stuff the right way, because it's starts from the untyped, don't really need to declare or set anything.  It's Humpty Dumpty: it starts out with no structure, and you can't seem to force any decent amount of structure into it.</description><pubDate>Tue, 11 Mar 2008 07:18:58 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Heh.... Just like SQL allows itself to take any form... or Java... or...</description><pubDate>Mon, 10 Mar 2008 21:53:46 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Nice article...but - I can't help but ask - why use VBScript when you can use an actual full-featured language?  You know - something with actual types, error-handling, etc...?I mean - in the old days where putting together a full fledged VB6 was a PITA, okay, I could see it.  But simple console apps are just as simple to put together, and are oh so very much cleaner to put together....All right fine - I like VBScript too....But it's almost invariably garbage code because it allows itself to have no form whatsoever....</description><pubDate>Mon, 10 Mar 2008 19:30:06 GMT</pubDate><dc:creator>Matt Miller (#4)</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Thanks Timothy... That's why I normally don't use VBS scripts... I can do almost everything with T-SQL. :)</description><pubDate>Mon, 10 Mar 2008 18:59:53 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Thanks Jeff.  None of those are issues in my situations, but they make perfect sense for reasons someone might need to use this.</description><pubDate>Mon, 10 Mar 2008 18:00:41 GMT</pubDate><dc:creator>timothyawiseman</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Haidong,Thanks for posting this article.  I've never done any scripting or programming other than SQL.  I had a task in my assigned "To Do" list at work that required automating some backup and log deletes.  I've been putting it off because I didn't know how to do it other than write some SQL with xpcmdshell and I still wasn't sure exactly how to accomplish it.  This article popped up in my email and now it's done!  Thank you for knocking something of my tasklist and helping me get over the fear of vbscript!</description><pubDate>Mon, 10 Mar 2008 16:04:26 GMT</pubDate><dc:creator>sqlhack</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>It does the same thing, as far as I can tell.</description><pubDate>Mon, 10 Mar 2008 11:24:52 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>How does the script for deleting old files differ from the Deleting old files in the Maintenance plan?thanks</description><pubDate>Mon, 10 Mar 2008 11:10:32 GMT</pubDate><dc:creator>Andrew Collins</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Heh... I can explain that... since it's a "script", it may not be subject to the normal "code release" steps within a company, it's callable from DTS or SSIS, it's available on every Windows machine, and it's free...</description><pubDate>Sun, 09 Mar 2008 08:44:22 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Haidong Ji,  This is an excellent article and I appreciate the information.    I do have one question though, I have worked with a variety of technologies, but I have not yet used VBS.  Why would you want to implement it this way instead of making an actual application or writing it in sql with use of xp command shell?</description><pubDate>Sun, 09 Mar 2008 01:43:05 GMT</pubDate><dc:creator>timothyawiseman</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Great point!Thanks a lot Jeff for the compliment :)</description><pubDate>Fri, 07 Mar 2008 21:26:37 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Outstanding primer on VBS and the FSO... well done.I don't know if I missed it in the article, but for anyone that hasn't used it before, you should have said something to the effect that you can write the code using any text editor, mention that the files can be saved like any text file, and which extensions the operating system expects for VBS files (.vbs or .scr??? Not sure on .scr because I always use .VBS).  It would also be handy to empasize a bit that the scripts can be called from any .bat file.Again, outstanding job and good documented examples.</description><pubDate>Fri, 07 Mar 2008 21:00:17 GMT</pubDate><dc:creator>Jeff Moden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Delete files in a folder that are certain days old script is worth keeping in personal briefcase.  Thanks for a good article.</description><pubDate>Fri, 07 Mar 2008 08:57:20 GMT</pubDate><dc:creator>SanjayAttray</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>You can put it in a Sql Server Agent job. Create a new job, go to steps, and pick ActiveX script from the dropdown.</description><pubDate>Fri, 07 Mar 2008 08:19:17 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Pretty cool neat VBSI am playing with them alreadyI suppose SSIS/Batch can work equally well for the same thing</description><pubDate>Fri, 07 Mar 2008 08:17:30 GMT</pubDate><dc:creator>Jerry Hung</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>I need this funcionality, but I have not done VBScript with SQL Server before.Where do you put this code? Do I bring up SQL Mgmt Studio and then what?Can you point me to a resource?Thanks. CW</description><pubDate>Fri, 07 Mar 2008 08:12:13 GMT</pubDate><dc:creator>Charlie Whitcraft-242308</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;The following questions are for script#2.&lt;/P&gt;&lt;P&gt;1) When the FTP script is run, what does the '-s' represent, send a single file?&lt;/P&gt;&lt;P&gt;2) Is there a way to make the DOS screen freeze when the FTP script is being run?  I've tried 'pause', 'prompt', 'echo', etc. but nothing seems to work.&lt;/P&gt;&lt;P&gt;3) How can a logfile be created when the FTP script is run?  I've used the Chr to put the ascii '&amp;gt;&amp;gt;' characters in but a logfile is not created.&lt;/P&gt;&lt;P&gt;Thanx!     Warren&lt;/P&gt;&lt;P&gt;           &lt;/P&gt;</description><pubDate>Fri, 22 Sep 2006 05:23:00 GMT</pubDate><dc:creator>Warren Ball</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Very cool pl! Thanks for sharing.</description><pubDate>Mon, 10 Apr 2006 19:53:00 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Forfiles&lt;/STRONG&gt;&lt;/EM&gt; is a little known command that is great for iterating over a number of files that meet a condition, it's available in both 2000, XP and 2003 but there are different versions out there depending on servicepack version.  &lt;/P&gt;&lt;P&gt;For example, I use it in a backup script to remove local backups when they have been moved to network drive:&lt;/P&gt;&lt;P&gt;&lt;FONT color=#115511&gt;' Delete cab files older than 3 days in local folder&lt;/FONT&gt;oWshShell.Run &lt;FONT color=#1111bb&gt;"FORFILES /p ""C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup"" /m *.cab /d -3 /c ""cmd /c del @file"""&lt;/FONT&gt; , 0, True&lt;/P&gt;&lt;P&gt;For all command line options run &lt;STRONG&gt;&lt;EM&gt;FORFILES /?&lt;/EM&gt; &lt;/STRONG&gt;on the command prompt.&lt;/P&gt;</description><pubDate>Mon, 10 Apr 2006 06:06:00 GMT</pubDate><dc:creator>pl-272086</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Wow, I never thought that my little article generated so many great feedbacks! I learned so much from you all!!!Sorry for the late reply to all you guys. I've been busy with other things and have neglected checking back the forum from time to time.Thanks again.</description><pubDate>Sat, 15 Oct 2005 21:37:00 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;I just want to say thank you for posting this article.  It was real easy to read, understand and modify for my own use.  There are a lot of coders out there that can write really good code, but it takes another skill to write code as you have done that is easy to read and adapt.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;</description><pubDate>Mon, 11 Jul 2005 08:53:00 GMT</pubDate><dc:creator>Ben Dizenhouse</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;Is this in a .BAT or .SCR file?&lt;/P&gt;</description><pubDate>Thu, 02 Jun 2005 15:02:00 GMT</pubDate><dc:creator>Michael Shorkey</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;I almost forgot, in response to Archie's comment above about no error checking, you could use the Exec method instead of run. That way you could parse the std.out string for error verbiage and take appropriate action (Email, Net Send, etc...). An excellent site for command refernce for VBScript, including WSH and ADO is DevGuru.com.&lt;/P&gt;&lt;P&gt;Happy Scripting!&lt;img src='images/emotions/cool.gif' height='20' width='20' border='0' title='Cool' align='absmiddle'&gt;&lt;/P&gt;</description><pubDate>Sat, 09 Apr 2005 11:00:00 GMT</pubDate><dc:creator>Narizz28</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;In the FTP script, don't forget to delete the FTP answer file when done with it (clean up the temp files) and unistantiate the objects to prevent possible memory leaks.&lt;/P&gt;&lt;P&gt;Happy Scripting! &lt;img src='images/emotions/cool.gif' height='20' width='20' border='0' title='Cool' align='absmiddle'&gt;&lt;/P&gt;</description><pubDate>Sat, 09 Apr 2005 10:48:00 GMT</pubDate><dc:creator>Narizz28</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;Great article.My collection of VBScipt and batch files has grown over the years as I automate the many tasks that I am responsible for. I've tried designing full-blown applications to handle redundant tasks, but find that when company procedures or standards change frequently, it's easier to edit a VBS or BAT file than recompile an app. (of course I'm mostly a SQL developer, not an app developer)&lt;/P&gt;&lt;P&gt;The following code from a VBS file that will "Get Latest" version of scripts from a SourceSafe Project folder. (Of course, it might be a little easier to use a batch file for this, but this can be slightly modified to prompt the user for input.)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Option Explicit&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;'Gets the latest version of files in a SourceSafe project folder.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Dim sSourcePath, sTargetPath, sUsername, sPassword&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;'EDIT THESE VARIABLES:'You can optionally use the "InputBox" function to prompt for these.sSourcePath = "$/Database/Product/Release800" 'from SourceSafesTargetPath = "C:\SourceSafe\GetLatest" 'File System pathsUserName = "steve" 'for SourceSafesPassword = "password"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Call GetLatest( sSourcePath, sTargetPath, sUserName, sPassword )MsgBox( "'Get Latest' completed!", vbOKOnly+vbInformation, "Get Latest" )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;'--------------------------------------------------------Sub GetLatest( sSourcePathSS, sTargetPathFs, sUser, sPwd )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; Dim sCmd, sSSExePathFs, sSSIniPathFs, sSSLogin, sComspec Dim oShell 'Command shell Set oShell = CreateObject("WScript.Shell") Dim fso 'File System Object set fso = CreateObject("Scripting.FileSystemObject")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; sTargetPathFs = CreateDir( sTargetPathFs )  'Create login switch: sSSLogin = " -Y" &amp;amp; sUser &amp;amp; "," &amp;amp; sPwd &amp;amp; " "&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; 'Variables that will likely not change often: sComspec = "%COMSPEC% /c " sSSIniPathFs = "&lt;/FONT&gt;&lt;A href="file://server2/ProductABC/Test/VSS"&gt;&lt;FONT face="Courier New"&gt;\\server2\ProductABC\Test\VSS&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;" sSSExePathFs = "&lt;/FONT&gt;&lt;A href="file://server2/ProductABC/Test/VSS/WIN32/"&gt;&lt;FONT face="Courier New"&gt;\\server2\ProductABC\Test\VSS\WIN32\&lt;/FONT&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; ' ------------------------------ ' rem Command Line access to SourceSafe: ' set ssdir=%ggssinifile% ' ss cp "%ggssfold%" -Y%ggssuser%,%ggsspass% ' ss get * -gtul%ggTarget% -Y%ggssuser%,%ggsspass% "-o&amp;amp;SSGetLatest.out" ' ------------------------------  'Use command line to set SourceSafe INI file: sCmd = sComspec &amp;amp; "set SSDIR=" &amp;amp; sSSIniPathFs Call oShell.Run( sCmd, 1, true )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; 'Use command line to set the desired SourceSafe Project folder: sCmd = sComspec &amp;amp; sSSExePathFs &amp;amp; "ss cp """ &amp;amp; sSourcePathSS &amp;amp; """" &amp;amp; sSSLogin Call oShell.Run( sCmd, 1, true )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; 'Build and run the 'Get Latest' command: sCmd = sComspec &amp;amp; sSSExePathFs &amp;amp; "ss get * -gtul"  sCmd = sCmd &amp;amp; fso.GetFolder( sTargetPathFs ).ShortPath  sCmd = sCmd &amp;amp; sSSLogin &amp;amp; " ""-o&amp;amp;SSGetLatest.out""" Call oShell.Run( sCmd, 1, true )&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; Set oShell = Nothing Set fso = Nothing&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;'--------------------------------------------------------Function CreateDir( sPath )'Creates a folder if one doesn't exist. Dim fso 'File System Object set fso = CreateObject("Scripting.FileSystemObject")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt; if Not fso.FolderExists( sPath ) then  'Be sure parent exists, before creating child:  Call CreateDir( fso.GetParentFolderName( sPath ) )  fso.CreateFolder( sPath ) end if  set fso = Nothing CreateDir = sPathEnd Function&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 08 Apr 2005 22:40:00 GMT</pubDate><dc:creator>sql8081</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;Well... I continue feeling that implementing a shell/awk in the unix/linux is better and more powerfull, but sometimes anybody require work in WindowsX, your code is great, easy and elegant.&lt;/P&gt;&lt;P&gt;Tks&lt;/P&gt;&lt;P&gt;Pepe&lt;/P&gt;</description><pubDate>Fri, 08 Apr 2005 10:34:00 GMT</pubDate><dc:creator>antonio bonilla</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;Forgot to mention - liked the script for deleting files - i shall use that &lt;/P&gt;&lt;P&gt;Thanks for the code.&lt;/P&gt;</description><pubDate>Fri, 08 Apr 2005 03:25:00 GMT</pubDate><dc:creator>Archie Ogden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>&lt;P&gt;Not great for FTP as no error checking done - same could be achieved with a .cmd file using less code with error checking. E.G&lt;/P&gt;&lt;P&gt;rem %1 is file to be xferred %2 is suffix eg xfr %3 host name %4 is username %5 is passwordcd c:\xfrrem IF EXISTS THEN DELETE THE PREVIOUS FILESdir c:\xfr\%1.%2 &amp;gt;nul &amp;amp;&amp;amp; del c:\xfr\%1.%2dir c:\ftpcmd\%1.ftp &amp;gt;nul &amp;amp;&amp;amp; del c:\ftpcmd\%1.ftpecho open %3 &amp;gt;c:\ftpcmd\%1.ftpecho %4&amp;gt;&amp;gt;c:\ftpcmd\%1.ftpecho %5&amp;gt;&amp;gt;c:\ftpcmd\%1.ftpecho get %1.%2 &amp;gt;&amp;gt;c:\ftpcmd\%1.ftpecho bye&amp;gt;&amp;gt;c:\ftpcmd\%1.ftpftp -s:c:\ftpcmd\%1.ftp &amp;gt;c:\scripts_logs\%1FTP.logcd c:\scriptsfindstr /c:"226 Transfer complete" C:\scripts_logs\%1FTP.logif %ERRORLEVEL% GTR 0 goto FAIL exit 0:FAILrem - send a mail message or whatever you wantexit 1&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description><pubDate>Fri, 08 Apr 2005 03:22:00 GMT</pubDate><dc:creator>Archie Ogden</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Very helpful, thanks for sharing</description><pubDate>Thu, 07 Apr 2005 22:47:00 GMT</pubDate><dc:creator>dougsx1</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Thanks Calvin for your compliment. I appreciate it. I am glad you find the article helpful. </description><pubDate>Wed, 05 Nov 2003 19:29:00 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item><item><title>RE: Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>nice, consice code.  Great way to delete old files; didn't realize it was that easy, you did my homework assignment for me. :)I've created a sproc that ftp's a file, but it's a bastardized version of your code.  Good stuff. </description><pubDate>Wed, 05 Nov 2003 00:34:00 GMT</pubDate><dc:creator>Calvin Lawson</dc:creator></item><item><title>Using VBScript to Automate Tasks</title><link>http://www.sqlservercentral.com/Forums/Topic17809-102-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF=http://www.sqlservercentral.com/columnists/hji/usingvbscripttoautomatetasks.asp&gt;http://www.sqlservercentral.com/columnists/hji/usingvbscripttoautomatetasks.asp&lt;/A&gt;</description><pubDate>Fri, 31 Oct 2003 00:00:00 GMT</pubDate><dc:creator>Haidong Ji</dc:creator></item></channel></rss>