TomGee.us

Tag: Script

Backup PC via Batch Script

by Tom Gee on Apr.25, 2010, under Scripts

I made a few small alterations to the script found [http://www.speedguide.net/read_articles.php?id=1547] and use it on a regular basis to backup my Windows 7 PC.

The source code is as follows, where F:\Backup is the location on my external drive where I want my files to be copied to:

@echo off
:: variables
set drive=F:\Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /y
echo Starting Backup – %date% %time% >> %drive%\backup.log
echo ### Backing up Documents…
echo   Documents >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Documents” “%drive%\Documents”
echo ### Backing up Pictures…
echo   Pictures >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Pictures” “%drive%\Pictures”
echo ### Backing up Desktop…
echo   Desktop >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Desktop” “%drive%\Desktop”
echo ### Backing up Downloads…
echo   Downloads >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Pictures” “%drive%\Downloads”
echo ### Backing up Favorites…
echo   Favorites >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Favorites” “%drive%\Favorites”
echo ### Backing up Music…
echo   Music >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Music” “%drive%\Music”
echo ### Backing up Videos…
echo   Videos >> %drive%\backup.log
%backupcmd% “%USERPROFILE%\Videos” “%drive%\Videos”
echo Backup Complete!
echo Backup Complete – %date% %time% >> %drive%\backup.log
Click [this link] to download the above batch script and enjoy!

1 Comment :, , , , more...

Sequentially run all VB Script (.vbs) files in a directory

by Tom Gee on Apr.06, 2010, under C#, Uncategorized

Create a new C# Console Application in Visual Studio and compile the code.  Copy the compiled .exe file to the directory containing the .vbs scripts you want to run in sequence.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
/*————————————————————————–
* Developer: Tom Gee
* Date: April 6, 2010
* Description: This .exe file will run every .VBS file in the same directory
*              as the .exe, but will wait for the current .VBS script to end
*              before beginning the next.
————————————————————————–*/
namespace RunAllVBSinDirectory
{
class Program
{
static void Main(string[] args)
{
try
{
string[] scripts = Directory.GetFiles(Directory.GetCurrentDirectory(), “*.vbs”);
int i = 0;
foreach (string script in scripts)
{
i++;
Console.WriteLine(“Running: ” + script);
using (Process exeProcess = Process.Start(script))
{
exeProcess.WaitForExit();
exeProcess.Close();
exeProcess.Dispose();
}
}
Console.WriteLine(“Ran all ” + i + ” script files in current directory (” + Directory.GetCurrentDirectory() + “)“);
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(“ERROR! ” + ex.Message + Environment.NewLine + “Inner Exception: ” + ex.InnerException + Environment.NewLine + “Stack Trace: ” + ex.StackTrace);
Console.ReadLine();
}
}
}
}
Leave a Comment :, , , , , , , , , , , , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!