Showing posts with label Windows XP. Show all posts
Showing posts with label Windows XP. Show all posts

11 November 2016

Start SAFE MODE if Windows 7,8,10 didn't start

Boot from any boot USB and open command prompt
If this SCCM USB flash memory when you will see password windows request type F8 to open command line

After the command system prompt, enter the command for the safe mode option you want. Enter the information exactly.

Enable Safe Mode - Type:
bcdedit /set {default} safeboot minimal and press Enter.

Enable Safe Mode with Networking - Type:
bcdedit /set {default} safeboot network and press Enter.

Enable Safe Mode with Command Prompt - Type:
bcdedit /set {default} safeboot minimal and press Enter:
bcdedit /set {default} safebootalternateshell yes and press Enter.

The computer responds with the operation completed successfully when you have entered the command correctly.

Notice: This changing is permanent so for EXIT from safemode
Type the following command to exit Safe Mode:
bcdedit /deletevalue {default} safeboot and press Enter.


If Windows can start when you restart computer hold “Shift” key and after we can see start up option for troubleshooting (on Windows XP same as Windows 7 this is F8 when computer started).

20 September 2016

Non admin network user can start command line as administrator

Issue: non admin network user can start command line as administrator without UAC window. (Command line have name as "Administrator: C:\Windows\System32\cmd.exe") In result real administrator can't start admin tools as every time from cmd. For temporally use we can start any tools with "runas /user:Admin cmd" or use non secure vbs script for start it.
------------------ Option explicit
Dim oShell
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
'WScript.Echo "WScript.ScriptFullName", WScript.ScriptFullName
'WScript.Echo "oFS.GetParentFolderName(WScript.ScriptFullName)", oFS.GetParentFolderName(WScript.ScriptFullName)
set oShell= Wscript.CreateObject("WScript.Shell")
'Replace the path with the program you wish to run c:\program files...
oShell.Run "RunAs /noprofile /user:Administrator ""C:\Windows\System32\cmd.exe"""
WScript.Sleep 200
'Replace the string --> yourpassword~ with the
'password used on your system. Include the tilde "~"
oShell.Sendkeys "Pa$$vv0rd~"
WScript.Sleep 200
oShell.Sendkeys "cd /d "
oShell.Sendkeys oFS.GetParentFolderName(WScript.ScriptFullName)
oShell.Sendkeys "~"
oShell.Sendkeys "cmd~"
'oShell.Sendkeys "F:\Deployment\Access\runas.bat~"
Wscript.Quit
------------------
Issue admin rights was resolved by checked registry UAC part for domain users (or Group Policy on server or local users)
List UAC settings below


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
FilterAdministratorToken User Account Control: Admin Approval Mode for the built-in Administrator account 0 (Default) = Disabled
1 = Enabled
EnableUIADesktopToggle User Account Control: Allow UIAccess applications to prompt for elevation without using the secure desktop 0 (Default) = Disabled
1 = Enabled
ConsentPromptBehaviorAdmin User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode 0 = Elevate without prompting
1 = Prompt for credentials on the secure desktop
2 = Prompt for consent on the secure desktop
3 = Prompt for credentials
4 = Prompt for consent
5 (Default) = Prompt for consent for non-Windows binaries
ConsentPromptBehaviorUser User Account Control: Behavior of the elevation prompt for standard users 0 = Automatically deny elevation requests
1 = Prompt for credentials on the secure desktop
3 (Default) = Prompt for credentials
EnableInstallerDetection User Account Control: Detect application installations and prompt for elevation 1 = Enabled (default for home)
0 = Disabled (default for enterprise)
ValidateAdminCodeSignatures User Account Control: Only elevate executables that are signed and validated 0 (Default) = Disabled
1 = Enabled
EnableSecureUIAPaths User Account Control: Only elevate UIAccess applications that are installed in secure locations 0 = Disabled
1 (Default) = Enabled
EnableLUA User Account Control: Run all administrators in Admin Approval Mode 0 = Disabled
1 (Default) = Enabled
PromptOnSecureDesktop User Account Control: Switch to the secure desktop when prompting for elevation 0 = Disabled
1 (Default) = Enabled
EnableVirtualization User Account Control: Virtualize file and registry write failures to per-user locations 0 = Disabled
1 (Default) = Enabled

10 July 2016

Migration notes

For memorize:

  If program didn't work in generaly after migration from x86 to x64 Windows:
    1. Check ini files for program and see path "c:/Progra~/your_program.exe" try change to Path="c:/Program Files (x86)/your_program.exe" or %ProgramFiles(x86)%/your_program.exe
    2. Check start folder path. If need change "c:/Program Files/your_program.exe" to "c:/Program Files (x86)/your_program.exe"
    3. If you know realy what program need access to program try make link  - "mklink /J "C:\Program Files\your_program" "C:\Program Files (x86)\your_program"
    4. Check firewall settings and if need create rule  - "netsh advfirewall firewall add rule name="your_program(x64)" dir=in action=allow program="C:\Program Files\your_program\tt.exe" enable=yes"
    5. If you use SQL, Access database check ODBC manager for both version x86 "C:\Windows\System32\odbcad32.exe" and x64 "C:\Windows\Syswow64\odbcad32.exe". If need install drivers for x86 use special key passive "AccessDatabaseEngine.exe /passive". Be carefully: noticed trouble Office x86 and Access Engine.
    6. If your Access database not good working  - check version x86 or x64 your installed Microsoft Office by office_program->File->Help


If you have another metods - share it.

8 July 2016

Windows XP -> Windows 7 refresh script (part 3 - report)

  Last 3 part of migration package  - reporting. This script same use report from post "Windows XP software script". Program checked txt files by old data in report folder and created xlsx report*.

* - Format xlsx file:
1 column  - ID (%your_name%)
2 column  - old hostname (from Windows XP)
3 column  - new hostname (from Windows 7)
4 column  - old MAC (from Windows XP)
5 column  - new MAC (from Windows 7)
6 column  - audit Data (Windows XP)
7 column  - refresh Data (Windows 7)

#$audit = 1  ############## Do we need AUDIT ???
$drive = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition).ToString()
$location = $drive[0]+":\Backup\DC30"
$DC_Report = Get-ChildItem $location | select BaseName, FullName, CreationTime
$report_dat = @()
for ($i = 0; $i -ne $DC_Report.Count; $i++)
    {
    $MainFile = new-object System.IO.StreamReader($location+"\"+$DC_Report.BaseName[$i]+".txt")
    $t = 0
    try {
        while (($line = $MainFile.ReadLine()) -ne $null)
            {
            $report_data = New-Object System.Object
            switch ($t)
                {
                0 {$tem = $line;$t++}
                4   {
                    $report_data | Add-Member -MemberType NoteProperty -name "ID" -Value $DC_Report[$i].BaseName.Substring(3).Split("_")[1]
                    $report_data | Add-Member -MemberType NoteProperty -name "Status" -Value $DC_Report[$i].BaseName.Substring(3).Split("_")[0]
                    $report_data | Add-Member -MemberType NoteProperty -name "Hostname" -Value "$tem"
                    $report_data | Add-Member -MemberType NoteProperty -name "Mac" -Value $line.Substring(0,17)
                    $report_data | Add-Member -MemberType NoteProperty -name "Data" -Value $DC_Report.CreationTime[$i].ToString("dd-MMM")
                    $t++
                    $report_dat += $report_data
                    }
                default {$t++}
                }
            }
        }
    finally { $MainFile.Close() }
#for mac '^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$'
}

#Get-ChildItem E:\Backup\DC\sn_new_9.txt | % { $_.CreationTime = '5/25/2016 15:10:23' }#change creation time
# Create the Excel Object
$xl = New-Object -comobject Excel.Application

# Make it visible
$xl.Visible = $true

# Add a workbook
$xl.Workbooks.Add()

# Move to the first row/column
$xl.ActiveSheet.Range("A1").Activate()

# Create the column headers
$xl.Rows.Item(1).Font.Bold = $True
$xl.ActiveCell.Value2 = "ID"
$xl.ActiveCell.Offset(0, 1).Value2 = "old hostname"
$xl.ActiveCell.Offset(0, 2).Value2 = "new hostname"
$xl.ActiveCell.Offset(0, 3).Value2 = "old MAC"
$xl.ActiveCell.Offset(0, 4).Value2 = "new MAC"
$xl.ActiveCell.Offset(0, 5).Value2 = "audit Data"
$xl.ActiveCell.Offset(0, 6).Value2 = "refresh Data"

# Move to the next row
$xl.ActiveCell.Offset(1, 0).Activate()

$rr = $report_dat | Where-Object {($_.status -eq 'old')}
for ($i = 0; $i -ne $rr.Count; $i++) {
    $old_data = $rr | Where-Object {($_.status -eq 'old') -and ($_.ID -eq $rr.id[$i])} | Sort-Object 'id' | select 'Hostname', 'Mac', 'Data'
    $new_data = $report_dat | Where-Object {($_.status -eq 'new') -and ($_.ID -eq $rr.id[$i])} | Sort-Object 'id' | select 'Hostname', 'Mac', 'Data'
    if (($new_data -eq $empty) -and ($audit -eq $false)) {Write-Host  $old_data.Hostname " -> " $new_data.Hostname " and " $old_data.Mac " -> " $new_data.Mac $i} else {
    $xl.ActiveCell.Value2 = $rr.id[$i]
    $xl.ActiveCell.Offset(0, 1).Value2 = $old_data.Hostname
    $xl.ActiveCell.Offset(0, 2).Value2 = $new_data.Hostname
    $xl.ActiveCell.Offset(0, 3).Value2 = $old_data.Mac
    $xl.ActiveCell.Offset(0, 4).Value2 = $new_data.Mac
    $xl.ActiveCell.Offset(0, 5).Value2 = $old_data.Data
    $xl.ActiveCell.Offset(0, 6).Value2 = $new_data.Data
    Write-Host $_.ID ","$old_data.Hostname","$new_data.Hostname","$old_data.Mac","$new_data.Mac
    $xl.ActiveCell.Offset(1, 0).Activate()
    }
}
$xl.Cells.EntireColumn.AutoFit()
$xl.activeworkbook.saveas("\\127.0.0.1\c$\Compucom\installed_computers_from_DC30.xlsx")

 #Write-Host("C:\Users\$env:UserName\Documents\results_$strUser.xls")

# Close Excel
$xl.Workbooks.Close()

$xl.Quit()

7 July 2016

Windows XP -> Windows 7 refresh script (part 2 - check programs)

  Second part of migration script that use report from previous post "Windows XP software script".  Once we choose old computer report program checked txt Windows XP report file with special csv file (ProgramList.csv) that have old Windows XP program name, new Windows 7 program name same as installed program name*. After removed from main report Windows 7 program, Windows updates, office updates, drivers, hotfix etc. and created final list software (soft_list.txt) on %HOMEDRIVE%\Install folder what we need more install on this pc. At the end requested copy install folder on computer and started install it.

* - Installed folder have path: ---%hard_drive%\Install Pkg\%name_program_folder_for_install%\Completed --- and have install.bat that started installation program.

* - Format csv file data (sample):
1 column  - Windows XP old program name (7-Zip 9.20)
2 column  - special for manual install
3 column  - name program folder for install (IgorPavlov_7-Zip_9.20_x64)
4 column  - installed program on Windows 7 (7-Zip 9.20 (x64 edition))

function findinarr ($array, $value, $columnIn, $columnOut) {

for ($n=0; $n -lt $array.count; $n++)
    {
    if ($array[$n][$columnIn] -eq $value) { Return $array[$n][$columnOut] }
    }
}

function findinobj ($array, $value, $columnIn, $columnOut) {

for ($n=0; $n -lt $array.count; $n++)
    {
    if ($array[$n].$columnIn -eq $value) { Return $array[$n].$columnOut }
    }
}

function GetSoftware ($request) {
$hive="HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall"
    if (Test-Path $hive){
    $param = Get-ChildItem $hive
    foreach ($p in $param){
        foreach ($key in $p.getValue("DisplayName")){
            if ($key -eq $request) {Return $request}
            }
        }
    }
}

function CheckBat ()
{
$alert = $false
if ((Get-Item "$programm_path\soft_list.txt").length -gt 0kb)
    {
$Copy_to_local = Read-Host "Do you want copy install folder to local computer?"
if ($Copy_to_local -eq "y")
    {
    cls
    Write-Host "Check install.bat file in programm folders"
    Write-Host "----------------------------------------"
    $SoftFile = new-object System.IO.StreamReader($programm_path+"\soft_list.txt")
    try
        {
        while (($soft_line = $SoftFile.ReadLine()) -ne $null)
            {
            if ($soft_line -ne "")
                {
                $install_folder = "$env:drive\Install Pkg\$soft_line"
                $bat_file = "$install_folder\Completed\install.bat"
                if (Test-Path -path $bat_file)
                    {
                    if ($soft_line -eq "Oracle_Client10gR2_10.2.0.5.0_x86_v2")
                        {
                        if (Test-Path -path "$env:SystemDrive\Completed") { Write-Host $soft_line "copied" }
                        else { Robocopy.exe "$install_folder\Completed" "$env:SystemDrive\Completed" * /e /eta }
                        }
                    Robocopy.exe $install_folder $programm_path\$soft_line * /e /eta
                    if (Test-Path -path $programm_path\$soft_line) { Write-Host $soft_line "copied" -foregroundcolor "Green" }
                    else { Write-Host $soft_line "copying" }
                    }
                else
                    {
                    Write-Host $soft_line -foregroundcolor "RED"
                    $alert = $true
                    }
                }
            }
        }
    finally { $SoftFile.Close() }
    }
}
Return $alert
}

$ValueFromPipeline=$true
$ValueFromPipelineByPropertyName=$true
$ComputerName = $env:computername
$win7app1 = New-Object System.Collections.ArrayList

$UninstallRegKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"

foreach($Computer in $ComputerName)
    {
    Write-Output "Computer: $Computer"
    if(Test-Connection -ComputerName $Computer -Count 1 -ea 0)
        {
        # Get the architecture 32/64 bit
        if ((Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -ea 0).OSArchitecture -eq '64-bit')
            {
                # If 64 bit check both 32 and 64 bit locations in the registry
                $RegistryViews = @('Registry32','Registry64')
            } else {
                # Otherwise only 32 bit
                $RegistryViews = @('Registry32')
            }

            foreach ( $RegistryView in $RegistryViews )
            {
                # Get the reg key(s) where add/remove program information is stored.
                $HKLM = [microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computer,$RegistryView)
                $UninstallRef = $HKLM.OpenSubKey($UninstallRegKey)
                $Applications = $UninstallRef.GetSubKeyNames()

                # Now we have the registry locations, call the function which will enumerate
                # all the applications on this PC
            foreach ($App in $Applications)
                {          
                $AppRegistryKey = $UninstallRegKey + "\\" + $App
                $AppDetails = $HKLM.OpenSubKey($AppRegistryKey)
                $AppGUID = $App
                $AppDisplayName = $($AppDetails.GetValue("DisplayName"))
                $AppVersion = $($AppDetails.GetValue("DisplayVersion"))
                $AppPublisher = $($AppDetails.GetValue("Publisher"))
                $AppInstalledDate = $($AppDetails.GetValue("InstallDate"))
                $AppUninstall = $($AppDetails.GetValue("UninstallString"))
                if(!$AppDisplayName) { continue }
                $OutputObj = New-Object -TypeName PSobject
                $OutputObj | Add-Member -MemberType NoteProperty -Name ComputerName -Value $Computer.ToUpper()
                $OutputObj | Add-Member -MemberType NoteProperty -Name Name -Value $AppDisplayName
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppVersion -Value $AppVersion
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppVendor -Value $AppPublisher
                $OutputObj | Add-Member -MemberType NoteProperty -Name InstalledDate -Value $AppInstalledDate
                $OutputObj | Add-Member -MemberType NoteProperty -Name UninstallKey -Value $AppUninstall
                $OutputObj | Add-Member -MemberType NoteProperty -Name AppGUID -Value $AppGUID
                if ($RegistryView -eq 'Registry32')
                    {
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Arch -Value '32'
                    } else {
                    $OutputObj | Add-Member -MemberType NoteProperty -Name Arch -Value '64'
                    }
                $win7app1.Add($OutputObj) > $null                       
                }
            }
        }
    }

$programm_path = "$env:HOMEDRIVE\Install"
$item_to_del = "$programm_path\soft_list.txt"
if (!(Test-Path -path $programm_path)) { New-Item -Path "$env:HOMEDRIVE\" -ItemType directory -Name Install }
if (Test-Path -path $item_to_del) { remove-item -path $programm_path\soft_list.txt -force }
new-item -path $programm_path -name soft_list.txt -type "file"
cls

$dr = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition).ToString()
$drive = $dr

$MainFile = new-object System.IO.StreamReader($drive+"\ProgramList.csv")
$ProgrammsForCompare = New-Object System.Collections.ArrayList
try {
    while (($line = $MainFile.ReadLine()) -ne $null) { $ProgrammsForCompare.Add($line.Split(",")) > $null }
    }
finally { $MainFile.Close() }

$Backup_txt = get-childitem "$drive\Backup_list" | ForEach-Object {$_ -Replace "software_list_", ""}| ForEach-Object {$_ -Replace ".txt", ""}
for ($i = 0; $i -ne $Backup_txt.Count; $i++) { Write-Host $i "-"$Backup_txt[$i] }
do
    {
    $Customer = Read-Host "Choose customer name"
    cls
    Write-Host "Report for"$Backup_txt[$Customer]
    Write-Host "----------------------------------------"
    $PathForXPList = $drive+"\Backup_list\software_list_"+$Backup_txt[$Customer]+".txt"
    }
until (($Customer -ne "") -and ($Backup_txt.Count -gt $Customer) -and (0 -le $Customer) -and ($Customer -match '[0-9]'))

$fileXPList = new-object System.IO.StreamReader($PathForXPList)
$XPList = New-Object System.Collections.ArrayList
try {
    while (($line = $fileXPList.ReadLine()) -ne $null)
        {
        $line = $line.Substring(1,$line.Substring(1).IndexOf("`""))
        $XPList.Add($line) > $null
        }
    }
finally { $fileXPList.Close() }

$XPConvertedList = New-Object System.Collections.ArrayList
$FromXPdidntFound = New-Object System.Collections.ArrayList
$w = New-Object System.Collections.ArrayList

foreach ($Result in $XPList)
    {
    $resultArr1 = findinarr $ProgrammsForCompare $Result 0 2
    if ($resultArr1 -eq "Manual Install")
        {
        $w.Add("Manual Install--" + $Result + "--`n`r") > $null
        Add-Content "$programm_path\soft_list.txt" "Manual Install--$Result--`n`r"
        }
    if ($resultArr1 -eq "") { $FromXPdidntFound }
    $XPConvertedList.Add($resultArr1) > $null
    }

$FromXPdidntFound = $FromXPdidntFound | Sort-Object -Unique
$FromXPdidntFound = $FromXPdidntFound -notlike "Update for*"
$FromXPdidntFound = $FromXPdidntFound -notlike "Security Update*"
$FromXPdidntFound = $FromXPdidntFound -notlike "Hotfix for*"
#$FromXPdidntFound = $FromXPdidntFound -notlike "===*"
$FromXPdidntFound = $FromXPdidntFound -ne "List of softwares "
$FromXPdidntFound = $FromXPdidntFound -notlike "Windows Genuine*"
$FromXPdidntFound = $FromXPdidntFound -notlike "Windows XP Service*"

$XPConvertedList = $XPConvertedList -ne "Driver"
$XPConvertedList = $XPConvertedList -ne "Unsupported"
$XPConvertedList = $XPConvertedList -ne "No longer required"
$XPConvertedList = $XPConvertedList -notlike "Built*"
$XPConvertedList = $XPConvertedList -ne ""

$XPConvertedList = $XPConvertedList | Sort-Object -Unique
$listtxt = New-Object System.Collections.ArrayList
for ($n=0; $n -lt $XPConvertedList.count; $n++)
    {
    $value = $XPConvertedList[$n]
    $tmpy = findinarr $ProgrammsForCompare $value 2 3
    if (($tmpy -eq "") -and ($value -ne "==="))
        {
        if ($value -ne "Manual Install")
            {
            Add-Content "$programm_path\soft_list.txt" "$value`n`r"
            $w.Add($value + "`n`r") > $null
            }
        } else {
        $installed = findinobj $win7App1 $tmpy name name
        if ($installed -ne $empty)
            { Write-Host "******installed****** $installed" -foregroundcolor "Green" }
        else
            {
            if ($tmpy -eq "===") {$value = $empty}
            else
                {
                if ($tmpy -eq "Cisco WebEx Meeting Center for Internet Explorer")
                    {
                    $listtxt.Add("Cisco WebEx Meeting Center for Chrome`n`r") > $null
                    Add-Content "$programm_path\soft_list.txt" "Cisco_WebEx Meeting Center for Chrome_29.13.10.10170_x86`n`r"
                    }
                Add-Content "$programm_path\soft_list.txt" "$value`n`r"
                $listtxt.Add("$tmpy`n`r") > $null
                }
            }
        }
    }
   
Write-Host "----------------------------------------"
Write-Host "Need to Install - " -foregroundcolor "Red"
Write-Host $w
Write-Host "$listtxt"

checkbat