February 3, 2010 by ashraf
As I am working with latest version of Powershell, when I tried to install latest version in XP I found that older version of powershell is available in software update for XP it is easy to find out and remove. But I really faced a big problem when I tried to install that in windows server 2003. I found all the software updates are named “Update of windows Server…” or “Security Update for windows server …” or “Hotfix for windows server 2003 …”. Its really hard to find out the right one and remove. After searching I found that I need to search for KB* to remove the older version.
Older version of powershell should be resembled any of the following
Hotfix for Windows Server 2003 (KB926139)
Hotfix for Windows Server 2003 (KB926140)
Hotfix for Windows Server 2003 (KB926141)
So find out the right one and remove it. Sometime it shows like that KB926139-v2, so don’t be confused. And after click on remove it will show you in the wizard that you are removing poweshell version 1.0 or anything else to be confirm you are really removing the right thing.
Posted in Programming | Tagged Powershell | Leave a Comment »
January 20, 2010 by ashraf
if you just need to install any software automatically using powershell you can just run the silent moder of the installer from powershell. The poweshell script to run exe or msi in silent mode is:
$command = “cmd.exe /c D:\MyInstaller.exe /s /v`”/qn”
$process = [WMICLASS]“\\PCName\ROOT\CIMV2:win32_process“
$process.Create($command)
Remember your installer should have silent mode on in it.
Posted in Programming | Tagged Powershell | Leave a Comment »
December 14, 2009 by ashraf
I have a text file and in that file list of files and folder are available to copy from a local computer to a remote computer. This is very easy to do using powershell. Example is as follows
$remotePCName = “remotePC”
$remoteRoot = “\\$remotePCName\c$”
$DestFolder=”$remoteRoot\FileCopy\dest”
$SrcFolder=”C:\FileCopy\src”
$InputFile =”C:\FilesToExport.txt”
foreach ($FileLine in Get-Content $InputFile)
{
$src = $FileLine
$dest = $src.Replace($SrcFolder, $DestFolder)
if(!(test-path -path $dest))
{
if((get-item $src).PSIsContainer)
{
new-Item $dest -type Directory -force | out-Null
Copy-Item “$src\*” $dest -recurse
“Folder $dest Missing. Creating it!”
}
else
{
new-Item $dest -type File -force | out-Null
Copy-Item $src $dest -force
“File $dest Missing. Creating it!”
}
}
else
{
if((get-item $src).PSIsContainer)
{
Copy-Item “$src\*” $dest -recurse
“Copy file done for $src”
}
else
{
Copy-Item $src $dest -force
“Copy file done for $src”
}
}
}
a file syncronizer can be created by some code modification easily.
Posted in Programming | Tagged Powershell | Leave a Comment »
Ehsan was telling me about the litte, simple and useful control. All of us already seen that control in facebook chatting window. that textboox automatically bacome bigger according to the text written in the textbox.
Here is the demo of that JQuery http://www.aclevercookie.com/demos/autogrow_textarea.html
I have tested that in asp.net TextBox it works. Here is my code in asp.net for auto growing textbox.
You should download JQuery and JQuery Auto Grow to use it.
<script type=”text/javascript” src=”jquery-1.3.2.js”></script>
<script type=”text/javascript” src=”jquery.autogrow.js”></script>
<script type=”text/javascript”>
$(document).ready(function() {
$(‘.expanding’).autogrow();
});
<style type=”text/css”>
.expanding {line-height: 18px;}
</style>
<asp:TextBox ID=”myTxt” runat=”server” CssClass=”expanding” AutoPostBack=”false” TextMode=”MultiLine”></asp:TextBox>
Posted in Programming | 3 Comments »
Recently I developed a web application which calls many services and loads a lot of data in every page with a lot of calculation in the background from the database, so the site became slower. Then I start searching Google to find out a good solution and got some real good ideas to improve my web application’s performance. Here, in this article, I am shared the tips I applied in the application to improve performance and it really works fine now.
http://www.codeproject.com/KB/aspnet/aspnetPerformance.aspx
Posted in Programming | 2 Comments »
February 26, 2009 by ashraf
Posted in Asp.Net, Javascript | 4 Comments »
February 23, 2009 by ashraf
I needed to run my web application in a fixed port of my web server due to fixed SiteURL in the web site whcih I needed to change every time from the web config.
Here are simple and easy steps tp run your web application in a fixed port of your web server.

1. Go to Solution Explorer of your project
2. Go to properties of your web site clicking F4 on your web site name.
3. Make “Use Dynamic Port” to “False” and put a “Port Number“, you website will always run in that port number.
Posted in Asp.Net | Leave a Comment »
October 30, 2008 by ashraf
Send mail is an important and common feature in asp.net. using system.net.mail namespace we can send mail. In that article my main concert is to show how shall we send mail asynchronously, as for a bulk of mail sending asynchronous mail send is very important and asp.net have that feature in it.
I had written a wiki in asp.net on with code on send asynchronous mail.
here you will get codes do send asynchronous mail http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/
Posted in C#.NET | Tagged ASP.NET | 5 Comments »
October 18, 2008 by ashraf
I was reading httpwebresponse data and get the basic data from the html data. So i need to remove all html tag, script tags, style tags from page to get original text data. So use a simple regular expression to remove tags. this regular expression was simple like that.
Regex.Replace(mainData,@”<scripts[^>]*>.*?</script>|<s*(?!/?(?:br?|i|p|u)b[^>]*>)[^>]*>”,”", RegexOptions.IgnoreCase | RegexOptions.Singleline) ;
I was working fine but i found that for some pages these are making problem specially problems are coming to remove javascript and styles from html data and data was not coming in a good format.
Finally I have got a very nice tool to do that . name of the tool is Html Agility .
this is a very nice features in html agility , it has libraires to convert html to xml, html to rss and html to text. I used html to text yo convert my httpresponse data to text.
in html agility you will find a class HTMLDocument.cs If you want to convert your webresponses then just add these codes in Load method, bacuase in load method this is reading html file from a local drive so to read webresponse use that code.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream(), OptionDefaultStreamEncoding);
Posted in C#.NET | Leave a Comment »
October 17, 2008 by ashraf
Caching is a very important concept in programming . caching is a very nice technique to speed up processing. To increase performance of application caching is a great enhance.
One of my buddy razwan has written a very nice article on asp.net caching using cache dependency on file. You can follow this article to implement that in your applicaiton to speed it up.
here is the link ASP.NET Caching with Cache Dependency on a File
Posted in C#.NET | Leave a Comment »