Saturday, July 9, 2011

How To Create An Unattended Windows XP Disk


unattended xpAn unattended XP disk is a customized installation disk that allows you to perform a Windows installation with minimal effort (once the disk is created). All of the effort takes place in creating the unattended disk, but it is well worth it. With an unattended XP disk, you can preselect all of the options you wish to use for the installation.
When you proceed with an unattended installation, you do still have to manually select the drive where you wish to install Windows (during the blue screen portion of the setup). However, once you’ve done that and started the installation you can walk away, grab a cup of coffee, eat some french toast, brush your teeth, check the weather, and by the time you get back you’ll see your new Windows XP desktop.
To create an unattended disk, you will of course need a Windows XP installation disk. You will also need to download nLite. nLite is a free program that allows you to create customized XP installation disks. Customizations you can perform include the integration of service packs, Windows updates, addition of drivers, preselection of installation options, preselection of components to install, and even more.
As a first step to unattended windows setup reference, you will need to get the latest Windows XP updates for your installation disk. Which updates you will need depends on how old your installation disk is. If you have a very old disk, you may need to download service pack 3 in addition to the updates that have taken place since the release of service pack 3. In the installation instructions below, you will learn how to find out whether or not Service Pack 3 is included on your installation disk.




Launch nLite, select your language, and click Next. Click the browse button to navigate to your the location of your installation CD. You will then be prompted for a location on the hard disk to store the files for processing. Select where you want to store the files and wait for the files to be copied.
create unattended windows xp
Once the files have completed copying, nLite will detect what version of Windows XP is on the installation CD. If it says the installation has Service Pack 3, then you will not need to download the service pack. Otherwise you can download the service pack here. Proceed to the next step.
Since this is the first time you’ve run nLite, you will not have any presets. Just click Nextto advance to the Task Selection page. On the task selection page, select Hotfixes, Add-ons, and Update Packs, Unattended, and Bootable ISO. If you had to download Service Pack 3 because you have an older version, select Service Pack as well.
unattended windows setup reference
If you are feeling adventurous, you can also include Drivers, select Components for removal, select Options, and Tweaks as well. These are more advanced options that will not be discussed in this particular How-To. Click the Next button to proceed.
If you need to integrate Service Pack 3, you will advance to the Service Pack page. Select the location of where you downloaded Service Pack 3. Once you’re done, click Nextto advance to Hotfixes, Add-ons, and Update Packs.
Click the Insert button (in nLite, not on your keyboard) and navigate to the location of the update pack. Click Next to proceed to the Unattended settings. In order to avoid any interaction with the installation (other than selecting/formatting the hard drive in the blue screens), you will need to update the following:
  • General Tab: Set Unattended Mode to Hide Pages
  • General Tab: Enter your Product Key
  • Users Tab: Password for the Administrator login (or check Blank password)
  • User Tab: Add a new User and set the password (or check Blank password)
  • User Tab: Set the Autologon to the new user you just added
  • Owner and Network ID Tab: Computer Name
  • Owner and Network ID Tab: Workgroup
  • Owner and Network ID Tab: Full Name
  • Owner and Network ID Tab: Organization
  • Regional Tab: Timezone


Once you’ve updated those settings, and any others you would like to update, click Next. Continue when prompted if you would like to start the process. When the process is complete, click Next to proceed to the Bootable ISO section.
Under Mode, select whether you want to Create an Image or perform a Direct Burn to a CD. Direct Burn is probably the easier choice, because nLite will write it directly to disk. When you’ve made your selection click Make ISO. If you decide to burn to an image, use your favorite image burning software to write it to a disk.
nlite -unattended installation
That’s all there is to it! Just take the disk, pop it into the target machine, boot it up, select where you want to install/format, and then go take a little walk. Upon your return, your machine will have a fresh installation of Windows XP running on it!
If this post is really helps give your feedback on coments.

Monday, July 4, 2011

Password-Protect an Excel Spreadsheet


Adds a password (%reTG54w) to a Microsoft Excel spreadsheet.
PowerShell
$comments = @' 
Script name: Set-ExcelPassword.ps1 
Created on: Friday, June 29, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
Password-Protect an Excel Spreadsheet? 
'@ 
#----------------------------------------------------- 
function Release-Ref ($ref) { 
([System.Runtime.InteropServices.Marshal]::ReleaseComObject( 
[System.__ComObject]$ref-gt 0) 
[System.GC]::Collect() 
[System.GC]::WaitForPendingFinalizers()  
} 
#----------------------------------------------------- 
$xlNormal = -4143 
  
$xl = new-object -comobject excel.application 
$xl.Visible = $True 
$xl.DisplayAlerts = $False 
  
$wb = $xl.Workbooks.Add() 
 
$ws = $wb.Worksheets.Item(1) 
$ws.Cells.Item(1, 1).Value() = get-date 
 
$a = $wb.SaveAs("C:\Scripts\Test.xls",$xlNormal,"%reTG54w"$a = $xl.Quit() 
  
$a = Release-Ref($ws$a = Release-Ref($wb$a = Release-Ref($xl
Verified on the following platforms
 
Windows Server 2008 R2No
Windows Server 2008No
Windows Server 2003No
Windows 7No
Windows VistaNo
Windows XPNo
Windows 2000No
This script is tested on these platforms by the author. It is likely to work on other platforms as well. If you try it and find that it works on another platform, please add a note to the script discussion to let others know.

Deletes every other row in a Microsoft Excel worksheet.


Deletes every other row in a Microsoft Excel worksheet.
PowerShell
$comments = @' 
Script name: Delete-EveryOtherRow.ps1 
Created on: Sunday, September 02, 2007 
Author: Kent Finkle 
Purpose: How can I use Windows Powershell to 
delete every other row on an Excel worksheet? 
#http://support.microsoft.com/kb/213610/en-us 
'@ 
#----------------------------------------------------- 
function Release-Ref ($ref) { 
([System.Runtime.InteropServices.Marshal]::ReleaseComObject( 
[System.__ComObject]$ref-gt 0) 
[System.GC]::Collect() 
[System.GC]::WaitForPendingFinalizers()  
} 
#----------------------------------------------------- 
$xl = new-object -comobject excel.application 
$xl.Visible = $True 
$wb = $xl.Workbooks.Add()  
$ws = $wb.Worksheets.Item("Sheet1")  
$2d = new-object 'object[,]' 20,1  
# Fill an array so we can put the numbers into Excel all at once. 
for ($i=0; $i -le 19; $i++) { 
    $2d[$i,0] = $i + 1 
} 
$r = $ws.Range("A1:A20")  
# Put the array into the sheet so we have something to work with. 
$r.Value() = $2d  
$y = $false               
# Change this to $True if you want to 
# delete rows 1, 3, 5, and so on. 
$i = 1 
$r = $ws.UsedRange 
$cnt = $r.rows.Count 
# Loop once for every row in the selection. 
for ($x=1; $x -le $cnt$x++) { 
    if ($y -eq $true) { 
        # ...delete an entire row of cells. 
        $a = $r.Cells.Item($i).EntireRow.Delete() 
    } 
    Else { 
        # ...increment $i by one so we can cycle through range. 
        $i++ 
    } 
    # If ($y is true, make it false; if $y is false, make it true.) 
    $y = -not($y) 
} 
$a = Release-Ref($r$a = Release-Ref($ws$a = Release-Ref($wb$a = Release-Ref($xl
Verified on the following platforms
 
Windows Server 2008 R2No
Windows Server 2008No
Windows Server 2003No
Windows 7No
Windows VistaNo
Windows XPNo
Windows 2000No
This script is tested on these platforms by the author. It is likely to work on other platforms as well. If you try it and find that it works on another platform, please add a note to the script discussion to let others know.

Import a Large Text File


Imports a text file into Excel even if the number of lines in that file exceeds Excel's total number of rows limitation.



Visual Basic
'       This script was written for folks trying to import a text file into  
'       Excel 2003 that exceed the row limitations.  
'       This version works on Windows XP and has not been tested on any other OS.  
 
Const ForReading = 1  
Const ForAppending = 2  
 
Set objDialog = CreateObject("UserAccounts.CommonDialog")  
 
objDialog.Filter = "All Files|*.*"  
objDialog.InitialDir = "C:\"  
intResult = objDialog.ShowOpen  
   
If intResult = 0 Then  
    Wscript.Quit  
Else  
    BreakFile =  objDialog.FileName  
End If  
 
Set objFSO = CreateObject("Scripting.FileSystemObject")  
Set objFile = objFSO.OpenTextFile(BreakFile, ForReading)  
 
FiletoSplit = objFSO.GetFileName(BreakFile)  
FolderDest = Mid(objFSO.GetAbsolutePathName(BreakFile),1, _ 
    Len(objFSO.GetAbsolutePathName(BreakFile))-(Len(FiletoSplit)))  
FileSplitName = objFSO.GetBaseName(BreakFile)  
 
 
 
dtmStart = Now()  
strContents = objFile.ReadAll  
FileNum = 1  
fname =  FolderDest & FileSplitName & "Split_" & FileNum & ".txt"  
Set objFile1 = objFSO.OpenTextFile(fname, ForAppending, True)  
 
 
 
CountLines = 0  
arrLines = Split(strContents, vbCrLf)  
 
If ubound(arrLines) < 64500 Then  
        msgbox "This file will fit into Excel already.  No split is necessary.",48,"SplitFile"  
        Wscript.Quit  
End If  
 
        HeaderText = arrLines(0)  
                For i = 0 to ubound(arrlines)                    
                        strLine = arrLines(i) & vbCrLf                   
                        objFile1.Write strLine                   
                        If  (Countlines) < 64500  Then                           
                                countlines = countlines + 1                      
                        ElseIf Countlines >= 64500 Then  
                                objFile1.Close  
                                Countlines = 0                           
                                FileNum = FileNum + 1  
                                fname = FolderDest & FileSplitName & "Split_" & FileNum & ".txt"  
                                Set objFile1 = objFSO.OpenTextFile(fname, ForAppending, True)  
                                objFile1.Write HeaderText & vbCrLf                               
                        End If           
        Next  
            
objFile.Close  
dtmEnd = Now()  
If MsgBox("There were " & FileNum & " files created." & vbcrlf & _  
        "The files were put into this folder:  " & FolderDest & _  
        vbCrLf & "The script took " & DateDiff("s", dtmStart, dtmEnd) & " seconds " & _  
        "to break the " &  FiletoSplit & " file." & vbcrlf & vbcrLF & _  
        "Click OK to open destination folder or CANCEL to quit.",  _  
        1,"SplitFile") = vbOK Then  
        Set objShell = CreateObject("Shell.Application")  
        strPath = FolderDest  
 
        objShell.Explore strPath  
End If 
 
Verified on the following platforms
Windows Server 2008 R2No
Windows Server 2008No
Windows Server 2003No
Windows 7No
Windows VistaNo
Windows XPNo
Windows 2000No


This script is tested on these platforms by the author. It is likely to work on other platforms as well. If you try it and find that it works on another platform, please add a note to the script discussion to let others know.