Bytes and Bites of Internet
Gaurang
First thing I would like to write is a question .... Why the hack people write their bio in 3rd person ? I am Gaurang. I work as DBA / DEV for local company in CT. When I am not working, I am either reading other blogs n news OR "researching" / "experimenting" about things that I can do at home / at work OR tinkering with some new hardware/software OR playing games on my desktop. If you ever wanted to contact me, I can be reached by meATgaurangpatel.net
Homepage: http://gaurangpatel.net
Posts by Gaurang
Creating MSI installer for Application
Mar 31st
Recently I was tasked to create MSI installer for our current application which is in development phase. While browsing project types in VS, I had known that VS has ability to create installer using Install Shield, but that was pretty much of it. I have never worked with them before. But after working with windows installation project for few days, it looks pretty straight forward process to me. I mean of course, we can customize installer anyway we want and it can get pretty complex subject, but out requirement was not so fancy (at least at this moment ) so I am overall enjoying working with it.
For this demo I have created a very simple console application in C# and I am creating installer for that app. This installer will allow user to install that app to any location, just like any other app. And this application is targeted for only 32bit machines. This console application basically runs in a loop until user quits it, with each loop it displays two random number and user is required to add them (I know its pretty basic app .. but this demo is for installer not for some fancy app ). I am actually following old MSDN walkthrough which explains step-by-step process to create MSI installer.
First, I have created a console application project “Installer Demo”. Like below.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace InstallerDemo { class Program { static void Main(string[] args) { char cont; do { Random r = new Random(); int i = r.Next(1, 10); Console.WriteLine("First Number: {0}", i); int j = r.Next(1, 10); Console.WriteLine("Second Number: {0}", j); Console.Write("Total is: "); int k = i + j; var l = Console.ReadLine(); Console.WriteLine(k == Convert.ToInt32(l) ? "True" : "False"); Console.WriteLine("Another Addition ?? Y/N"); cont = Convert.ToChar(Console.ReadLine()); } while (cont == 'Y' | cont == 'y'); Console.WriteLine("Bye"); Console.ReadLine(); } } }
Powershell … shell on steroids !!
Mar 18th
Shell is not a new thing for any older timer … or for folks working with forbidden OSes like Unix and Linux. It is primary utility used by users to interact with those systems (and in older days it was perhaps the only way of interaction). Till few days back, I was obsessed with DOS and batch files. And I tried to do most of system automation tasks using them. I even received comments from Boss, that I can do better if I use PowerShell instead of DOS. But like some old lady obsessed with her old hat or something, I was reluctant to give away old love for DOS.
But recently I went to local Access user group meeting here at CT. And there was presentation for “Introduction to PowerShell for Database Developers”. And I realized that all this time I was just ignorant to not to use PowerShell. You have whole .NET stack for you to consume in addition to support of both DOS and Unix Shell commands !! In simple words, PowerShell is really A Shell on Steroids.
And with this new “inspiration” I have decided to give PowerShell a try and use it for automation tasks in newer systems (mostly Post Windows Server 2003 R2).
Couple of days back, I created a VB Script to send email notification to users using any publically available SMTP servers like Google or Yahoo. That script was actually using built in class “CDO.Message” for configuration and sending email. This can be in done same manner by creating simple .NET console application just like below,
MailMessage message = new MailMessage(); message.To.Add("ToMail"); message.Subject = "Test Subject for Email"; message.From = new MailAddress("fromMail"); message.Body = "Message from Google SMTP"; SmtpClient smtpG = new SmtpClient("smtp.gmail.com"); smtpG.EnableSsl = true; smtpG.Port = 587; System.Net.NetworkCredential mailAuthentication = new System.Net.NetworkCredential("loginEmail", "password"); smtpG.Credentials = mailAuthentication; smtpG.Send(message); Console.WriteLine("Mail sent using Gmail"); Console.ReadLine();
Send Email in Batch File (using VB Script) without installing SMTP server
Mar 16th
In my never ending desire to use Batch files to do just about anything, I was recently needed batch file to send an email to users once task is completed with “Success” or “Failure” results. And since I was already using batch files to do number of things, I thought it wouldn’t harm if it can do one more thing …. send email to users !! Actually it is not possible to send email just from plain DOS commands so I added a bit flavor to it with use of good ‘ol VB Script. This distant cousin of batch script has always been popular among system admins, hackers and various other titles you can think of, due to its ability to access system level resources and more close ties to standard programing language VB.
I found over Google that most people suggest to use “CDO.Message” object to send email in VB Script. But there were not any “correct” script which solved my problem, it is because most of those scripts were required me to install SMPT server in my machine. But finally I was able to find a script which was doing exactly what it suppose to do (I honestly don’t remember which site was that because I had checked number of forums).
Finally working script is (with minor modification to original script),
If … Else in Batch file
Mar 9th
If you have ever used If .. Else in batch file then you know that how frustrating it is to work with it. In fact if you google this case then you will find that it is very common belief that ELSE doesn’t exits for BATCH files !!! I think it is just because very specific requirement to use this command is to write them in proper format.
Recently I had to add some “extra” feature in my backup script … an email notification via batch file for success or failure of operation. After spending many hours in forums finally I was able to figure out this mystery. Batch script will recognize If .. ELSE … only if it is written in following format,
Record steps to produce bugs with help of Problem Step Recorder in Windows 7
Mar 3rd
Few days back I was just goofing about in system I stumbled upon really interesting feature of Windows 7 it is called … “Problem Step Recorder”. I am surprised that MSFT has not given it any short ‘n sweet name but rather strange and mouthful name … But as you can guess from it’s name it does exactly what it says, it records steps which can be used to reproduce any issue by support people.
Actually when it says “record” it doesn’t actually create some video but it take snapshot of each steps use do and compiles it in a MHT file. User can also enter comments in slides to provider detailed information to support guys. Even thought it has some fundamental limitations which might render it useless for some users ( like limitation of max. 25 screenshots, but again if you can’t repro issue in 25 steps then dude I don’t think anyone can help you) but for most of mere mortals this will be really great tool to support users.
And I have “4,294,967,295” messages in my inbox !!
Feb 27th
I have more then 4 billion messages in my inbox, and without doubt I will be record holder for “the most emailed a person ever” or “person with super giant mail box” or “person who does nothing but keeps getting (and reading) emails” …..and so on …..
Don’t believe me … here is the proof … a snapshot from my mail client
And say if each message is of minimal size, 1 KB then for all of these messages my local mail box will be of approximately 4TB in size !! (think of re-downloading all messages again if my PC dies ) .. Pretty cool right ??
Template for Report … Unifying report layouts
Feb 18th
Most of the companies use some sort of unique format for their reports and this layout is kept same for all of their reports to create some sort of identity or brand. And for that developers usually use some kind of template to create default layout of report, and most of all reporting systems supports creating these kind of templates including SSRS. Actually it is very easy to create a report template which can be used for all other reports.
In this “How To”, I am creating a basic report template for report which once finalized can be used for any future use.
First step is to fire up VS2008 and create new report server project. Then add an empty report in it. Next step is to modify report the way want in our template. For sake of simplicity, I am just adding some basic fields. But in reality, we can add number of things including company logo as images.
Once it is done, all you have to do is to browse to