Recently I wrote a console application that generates SQL code to populate a database with sample data. I wanted it to be as generic as possible, but it still relies on a Source database to get sample data from. The application is configurable in that it lets you specify which Database is the source database, as well which tables to get the data out of. I did not want this application to depend on any stored procedures; it needs to be self contained, which is why I'm hard-coding the table definition sql query. So I call the console app via a batch file. The batch file calls the exe file, outputting the text to a file: 01: @ECHO OFF 02: bin\debug\SqlGenerator.exe > "C:\run.sql" 03: ECHO done. Here is the main method in the console app: 01: class Program { 02: static void Main( string [] args) { 03: Console.WriteLine(Database.GenerateSQL()); 04: } 05: } Here is the relevant excerpt from the App.config file: 01: < a
Recently I needed to create a simple way to backup alot of website's log files. The directory structure is such: C:\DemoSites\ | |----\Demo1 | | | |-----\Logs | |----\Demo2 | | | |-----\Logs | |----\Demo3 | | | |-----\Logs | |----\Demo4 | | | |-----\Logs | ... etc ... So I need to backup the log files inside each "Logs" directory, in a loop... Here is the batch file that takes care of it: 01: @ECHO OFF 02: 03: :: Get Today's Date in YYYYMMDD Format... 04: for /F "tokens=2-4 delims=/ " %%a in ( 'date/t' ) do (set datevar=%%c%%a%%b) 05: 06: :: For each subdirectory of C:\DemoSites, Zip all log files in their Logs directories... 07: for /D %%d in (C:\DemoSites\*) do ( 08: if exist %%d\Logs ( 09: for /F "tokens=5 delims= " %%k in ( 'dir %%d\..\.' ) do ( 10: if exist %%d\..\%%k\Logs\*.* ( 11: if not exist