Category Archives: Microsoft

The Scripting Series: Unattended Install of Visual Studio 2005 SP1 on Windows 7 x64 and Vista x64

How to install Visual Studio 2005 on Windows 7 x64 the Unattended way

  1. Extract your Visual Studio installation files to c:\VS2005
  2. Download Visual Studio 2005 SP1 and place it in c:\VS2005_Resources
  3. Download Visual Studio 2005 SP1 Update for Windows Vista and place it in c:\VS2005_Resources
  4. Create a new VS2005.ini Unattended answers file by running the following from a cmd prompt
    1. C:\vs2005\setup\setup.exe /createunattend c:\VS2005.ini
    2. Select the options you want to have installed during the unattended install and complete the wizard
      1. Keep in mind that the unattended file you create will only be usable on machines that have the exact same OS and architecture (x86 or x64)
  5. Copy and paste the following into a new bat file (c:\InstallVS2005.bat):

:Variables
SET VisualStudio2005FilesPath=c:\VS2005
SET VisualStudio2005ResourcesPath=c:\VS2005_Resources</code>

echo.
echo Install Visual Studio 2005
echo -Install Prequisites
"%VisualStudio2005FilesPath%\WCU\64bitPrereq\x64\vs_bsln.exe" /Q
"%VisualStudio2005FilesPath%\WCU\DExplore\dexplore.exe" /q:a /c:"install.exe /q"

echo -Install Visual Studio 2005
"%VisualStudio2005FilesPath%\setup\setup.exe" /unattendfile "c:\VS2005.ini"

echo -Install Visual Studio 2005 SP1
"%VisualStudio2005ResourcesPath%\en_visual_Studio_2005 SP1 (VS80sp1-KB926601-X86-ENU).exe" /q

echo -Install Visual Studio 2005 SP1 for Windows Vista
"%VisualStudio2005ResourcesPath%\en_visual_studio_2005 SP1 Vista (VS80sp1-KB932232-X86-ENU).exe" /q


Once you have done all that run the c:\InstallVS2005.bat file from a cmd prompt with Administrator priviledges. Towards the end of the initial Visual Studio 2005 install windows 7 will prompt you with a warning about Visual Studio 2005 being a an application that it has trouble running. Dismiss the warning and allow the installation to continue.

Once the bat file is finished you should have a working Visual Studio 2005 installation.

Advertisements

Technique to change any IIS 6 properties programatically

  1. Create a copy of your IIS Metabase before and after you make a change
  2. Compare the copies with a tool like WinMerge
  3. Evaluate function and purpose of properties using MSDN
  4. Set the properties in your scripts using ADSUtil or one of the scripts I have pasted below
    1. For properties that function more like an array you will have to use techniques like those used in the following scripts to properly set their values

Ancillary tools that you might find useful, MetaBase Explorer

Find Website Id By Website Name.vbs

on error resume next
dim Contains
Set ArgObj = WScript.Arguments
If ArgObj.Count < 1 Then
 Wscript.echo "Please specify the name or part name to look for in the host header field!"
 Wscript.echo ""
 Wscript.echo "Example"
 Wscript.echo "  cscript EnumByHostHeader.vbs ccrowe"
else
 Contains = ucase(ArgObj.Item(0))
 dim websrv, site
 dim Found
 dim webinfo
 Found = false
 WScript.echo "Searching for " & Contains & " in the host headers"
 WScript.echo ""
 WScript.echo "Web Site Instance ID - Server Comment - Host Header"
 set websrv = getobject("IIS://Localhost/W3SVC")

 if (err <> 0) then
 else
 err.Clear
 for each site in websrv
 if (site.classname = "IIsWebServer") then
 bindings = Site.ServerBindings
 For Index = LBound(bindings) To UBound(bindings)
 Values = split(bindings(Index), ":")
 HostHeader = ucase(Values(2))
 if (instr(HostHeader, Contains) > 0) then
 Found = true
 WScript.echo site.Name
'          WScript.echo site.Name & " - " & _
'             site.ServerComment & " - " & _
'             HostHeader
 end if
 next
 end if
 next
 end if
 if (Found = false) then
 WScript.echo "The search term " & Contains & " was not found!"
 end if
end if

Import Relay IP List.vbs

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'         Script to Import a bunch of IP addresses to the ReplayIpList
'         and IPSecurity
'                             (c)vijaysk@microsoft.com
'                             blogs.msdn.com/vijaysk
'
'
' USAGE : cscript ImportRelayList.vbs <PathToRelayIP.txt> <PathToSecurityIP.txt>
' PREREQUISITE : This script needs RelayIp.txt and SecurityIp.txt in the same folder or
' the path parameters must be used on the command line to specify the locations.
' FORMAT for *Ip.txt files: Each line should be IP,MASK ex. 127.0.0.1,255.255.255.255
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim objSMTP,objRelayIpList,objCurrentList,objIP,objFSO,objTextFile,count,newIpList(),inputOption,IPTxtPath
Set objSMTP = GetObject("IIS://localhost/smtpsvc/1")
Set objRelayIpList = objSMTP.Get("RelayIpList")
'objRelayIpList is of type IIsIPSecuritySetting http://msdn.microsoft.com/en-us/library/ms525725.aspx

If Wscript.Arguments.Count <> 0 Then
 IPTxtPath = Wscript.Arguments(0)
ELSE
 IPTxtPath = "ip.txt"
End If

Wscript.Echo "============================================"
Wscript.Echo "CURRENT SETTINGS"
Wscript.Echo "================"
Wscript.Echo " "
Wscript.Echo "Computer(s) that may relay through this virtual server."
Wscript.Echo " "
' GrantByDefault returns 0 when "only the list below" is set (false) and -1 when all except the list below is set(true)
If objRelayIpList.GrantByDefault = true Then
 Wscript.Echo "All except the list below :"
 objCurrentList = objRelayIpList.IPDeny
Else
 Wscript.Echo "Only the list below :"
 objCurrentList = objRelayIpList.IPGrant
End If
count = 0
For Each objIP in objCurrentList
 Wscript.Echo objIP
 count = count + 1
Next
If count = 0 Then
 Wscript.Echo "*NIL*"
End If
Wscript.Echo "============================================"
Wscript.Echo " "
Wscript.Echo "Replacing ReplayIpList with the IP address(es) from the ip.txt file."
Wscript.Echo " "

'Hard coding the script to always use the allow option unattended installation
inputOption = "a"

Do While Not((inputOption = "a") Or (inputOption = "d") Or (inputOption = "x") )
Wscript.Echo "ENTER "
Wscript.Echo "A to add to Allow List (Only the list below)"
Wscript.Echo "D to add to Deny List (All except the list below)"
Wscript.Echo "X Exit without making changes"
Wscript.Echo " "
inputOption = lcase(trim(Wscript.StdIn.ReadLine))
Loop
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(IPTxtPath) Then
 Set objTextFile = objFSO.OpenTextFile(IPTxtPath,1)

 count = 0
 Do Until objTextFile.AtEndOfStream
 Redim Preserve newIpList(count)
 newIpList(count) = objTextFile.Readline
 count = count + 1
 Loop
 objTextFile.Close

 'For each objIP in newIpList
 '    Wscript.Echo objIP
 'Next
 Wscript.Echo " "
 Select Case inputOption
 Case "a"
 objRelayIpList.GrantByDefault = false
 objRelayIpList.IpGrant = newIpList
 Wscript.Echo "SET " & count &" address(es) to Allow List"
 Case "d"
 objRelayIpList.GrantByDefault = true
 objRelayIpList.IpDeny = newIpList
 Wscript.Echo "SET " & count &" address(es) to Deny List"
 Case "x"
 Wscript.Echo "Exiting without making changes"
 Wscript.Echo "============================================"
 Wscript.Quit
 End Select

 objSMTP.Put "RelayIpList",objRelayIpList
 objSMTP.SetInfo
 Wscript.Echo " "

 Wscript.Echo "============================================"
Else
 Wscript.Echo "Please create a file ip.txt that contains the list of IP address(es)"
 Wscript.Echo "FORMAT : Each Line should be IP,MASK "
 Wscript.Echo "EX     : 127.0.0.1,255.255.255.255"
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'         Script to Import a bunch of IP addresses to the ReplayIpList             '
'                                                                                  '
'                             (c)vijaysk@microsoft.com                             '
'                             blogs.msdn.com/vijaysk                               '
'                                                                                  '
'                                                                                  '
'         USAGE : cscript ImportRelayList.vbs                                      '
'         PREREQUISITE : This script needs ip.txt in the same folder.              '
'         Store your IP addresses in ip.txt FORMAT: Each line should be IP,MASK    '
'                                                                                  '
'                                                                                  '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Import IP Security.vbs

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'         Script to Import a bunch of IP addresses to the ReplayIpList             
'         and IPSecurity                                                           
'                             (c)vijaysk@microsoft.com                             
'                             blogs.msdn.com/vijaysk                               
'                                                                                  
'                                                                                  
' USAGE : cscript ImportRelayList.vbs <PathToRelayIP.txt> <PathToSecurityIP.txt>
' PREREQUISITE : This script needs RelayIp.txt and SecurityIp.txt in the same folder or
' the path parameters must be used on the command line to specify the locations.
' FORMAT for *Ip.txt files: Each line should be IP,MASK ex. 127.0.0.1,255.255.255.255
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim objSMTP,objIpSecurity,objCurrentList,objIP,objFSO,objTextFile,count,newIpList(),inputOption,IPTxtPath
Set objSMTP = GetObject("IIS://localhost/smtpsvc/1")
Set objIpSecurity = objSMTP.Get("IPSecurity")
'objIpSecurity is of type IIsIPSecuritySetting http://msdn.microsoft.com/en-us/library/ms525725.aspx

If Wscript.Arguments.Count <> 0 Then
 IPTxtPath = Wscript.Arguments(0)
ELSE
 IPTxtPath = "ip.txt"
End If

Wscript.Echo "============================================"
Wscript.Echo "CURRENT SETTINGS"
Wscript.Echo "================"
Wscript.Echo " "
Wscript.Echo "Computer(s) that may connect to this virtual server."
Wscript.Echo " "
' GrantByDefault returns 0 when "only the list below" is set (false) and -1 when all except the list below is set(true)
If objIpSecurity.GrantByDefault = true Then
 Wscript.Echo "All except the list below :"
 objCurrentList = objIpSecurity.IPDeny
Else
 Wscript.Echo "Only the list below :"
 objCurrentList = objIpSecurity.IPGrant
End If
count = 0
For Each objIP in objCurrentList
 Wscript.Echo objIP
 count = count + 1
Next
If count = 0 Then
 Wscript.Echo "*NIL*"
End If
Wscript.Echo "============================================"
Wscript.Echo " "
Wscript.Echo "Replacing IPSecurity with the IP address(es) from the " & IPTxtPath & " file."
Wscript.Echo " "

'Hard coding the script to always use the allow option unattended installation
inputOption = "a"

Do While Not((inputOption = "a") Or (inputOption = "d") Or (inputOption = "x") )
Wscript.Echo "ENTER "
Wscript.Echo "A to add to Allow List (Only the list below)"
Wscript.Echo "D to add to Deny List (All except the list below)"
Wscript.Echo "X Exit without making changes"
Wscript.Echo " "
inputOption = lcase(trim(Wscript.StdIn.ReadLine))
Loop
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(IPTxtPath) Then
 Set objTextFile = objFSO.OpenTextFile(IPTxtPath,1)

 count = 0
 Do Until objTextFile.AtEndOfStream
 Redim Preserve newIpList(count)
 newIpList(count) = objTextFile.Readline
 count = count + 1
 Loop
 objTextFile.Close

 'For each objIP in newIpList
 '    Wscript.Echo objIP
 'Next
 Wscript.Echo " "
 Select Case inputOption
 Case "a"
 objIpSecurity.GrantByDefault = false
 objIpSecurity.IpGrant = newIpList
 Wscript.Echo "SET " & count &" address(es) to Allow List"        
 Case "d"
 objIpSecurity.GrantByDefault = true
 objIpSecurity.IpDeny = newIpList
 Wscript.Echo "SET " & count &" address(es) to Deny List"
 Case "x"
 Wscript.Echo "Exiting without making changes"
 Wscript.Echo "============================================"
 Wscript.Quit
 End Select

 objSMTP.Put "IPSecurity",objIpSecurity
 objSMTP.SetInfo
 Wscript.Echo " "

 Wscript.Echo "============================================"
Else
 Wscript.Echo "Please create a file ip.txt that contains the list of IP address(es)"
 Wscript.Echo "FORMAT : Each Line should be IP,MASK "
 Wscript.Echo "EX     : 127.0.0.1,255.255.255.255"
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'         Script to Import a bunch of IP addresses to the ReplayIpList             '
'                                                                                  '
'                             (c)vijaysk@microsoft.com                             '
'                             blogs.msdn.com/vijaysk                               '
'                                                                                  '
'                                                                                  '
'         USAGE : cscript ImportRelayList.vbs                                      '
'         PREREQUISITE : This script needs ip.txt in the same folder.              '
'         Store your IP addresses in ip.txt FORMAT: Each line should be IP,MASK    '
'                                                                                  '
'                                                                                  '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Strange C# Syntax if You Come from the Java World

I have bumped into some strange syntax over the last couple of days and I just found that wikipedia’s page on C# covers a lot of the abnormalities that I have been trying to understand. Things like Lamda expressions ( => ), the Null Coalese operator ( ?? ), Nullable types ( int? ), and Automatic Properties (public string Name { get; private set; } ) have all shown up in our websites code base and have required me to find out what exactly they do before I could start working with them.

Wikipedia C# Article

Once you know the correct terminology msdn.com’s library is certainly the best place for getting complete information on these characteristics of the C# language.

Getting Started with ASP.Net

I have just begun working on an established codebase for an eCommerce site that uses utilizese Commerce Server 2007, BizTalk 2006, and Dynamics NAV (Navision 4.0). The site is written in C# and ASP.Net and so I have been getting up to speed on the related technologies and how to work with them and I figured I would share some ASP.Net related links that I found today.

ASP.NET Web Server Control Event Model

http://msdn.microsoft.com/en-us/library/y3bwdsh3.aspx

ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0

http://msdn.microsoft.com/en-us/library/ms178473.aspx

ASP.NET Page Life Cycle Overview

http://msdn.microsoft.com/en-us/library/ms178472.aspx

ASP.NET Session State Overview

http://msdn.microsoft.com/en-us/library/ms178581.aspx

ASP.NET State Management Overview

http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx

ASP.NET State Management Recommendations

http://msdn.microsoft.com/en-us/library/z1hkazw7.aspx

I have not been involved in web development before and many of the paradigms are new to me so I found it very helpful to familiarize myself with how an ASP.Net application actually lives and breathes.

Tagged , , , ,