Archive

Archive for the ‘Windows 10’ Category

PowerShell: Change Port and URL quickly and accurately in multiple configuration files

05 September 2018 Leave a comment

PowerShell: Birden çok yapılandırma dosyasında Port ve URL’u hızlı ve doğru değiştirin

PowerShell_ISE

TR: Eğer bir çok uluslu bir şirkette altyapı yönetiyorsanız, bir küçük dosyayı tek tek düzenlemeniz gerekebilir. çünkü şirketin bir çok ülkeye hizmet veren bir web sayfası olacaktır. web sayfasının küçük ayar dosyası olacaktır. Bu dosyaları tek tek açıp düzenlemeye gerek yok. tüm ayarlamaları yapan bir script ile her ayarı hızlı ve doğru bir şekilde yapabilirsiniz.

EN: If you are managing the infrastructure in a multinational corporation, you may need to edit a small file one by one. because the company will have a web page that serves many countries. web page will be the small setting file. There is no need to open these files individually. With a script that makes all the adjustments you can make every setting quickly and accurately.

2018-09-05_16-47-18

TR: Her ülke için ayrı ayrı olan ayar dosyamız aşağıdaki gibi olsun. Aşağıdaki dosyadan 20 tane olduğunu düşünelim.

EN: We have our setup file for each country as follows. Let’s say you have 20 of the files below.

 

Config file name is “configAdapter”

 

AR.FALLBACK=testpage.amazonaws.com

AR.FALLBACK_PORT=15610

AR.HOST=testpage.amazonaws.com

AR.PORT=15610

AR.GS_HOST=testpage.amazonaws.com

AR.GS_PORT=15610

AR.GS_FALLBACK_HOST=testpage.amazonaws.com

AR.GS_FALLBACK_PORT=15610

AR.GS_DATABASEMATCH=TRADE_AR

AR.STAT_HOST=testpage.amazonaws.com

AR.STAT_PORT=15610

AR.STAT_TIMEZONE=America/New_York

AR.DATABASEMATCH=TRADE_AR

AR.QUERY_TERMS_OPERATOR=AND

AR.GLOBAL_SORT=Relevance

AR.GUIDED_SORT=AutnRank+Relevance+GS_KEYWORDS:alphabetical

AR.CAT_WRK_INSIGHTS=0

AR.GLOBAL_SORT_ORDER=before

AR.IDOL_VERSION=11

AR.CAT_WRK_CAMPAIGN=0

AR.MINSCORE=0

AR.QMS=false

AR.QMS_HOST=testpage.amazonaws.com

AR.QMS_PORT=15610

AR.QMS_PROMOTIONS_COUNT=3

 

 

TR: Biz sadece URL’i portları test sisteminden canlı sisteme çevirmek istiyoruz.

Aşağıdaki gibi ülke kodlarımız olsun. Bu ülke kodlarını US.txt olarak kaydedelim.

 

EN: We only want to convert the URL from the test system to the live system.

Get our country codes as follows. I record these country codes as US.txt.

 

US.txt

ar

br

ca

cl

co

ib

pe

us

ut

 

TR: Eğer benim gibi kıtaları ayrı ayrı yapılandırmanız gerekiyor ise aşağıdaki gibi ikinci bir ülke kodu dosyası oluşturup kaydedebilirsiniz.

EN: If you need to configure the continents separately like me, you can create and save a second country code file as follows.

 

PA.txt

au

cn

hk

in

id

jp

kz

kr

my

nz

ph

sg

tw

th

vn

 

# Script starting here

# Find the zone

$path = “C:\web_root\sites\”

 

#GAME URLs

$UrlOldGame = “testpage.amazonaws.com”

$UrlNewGame = “mysite.amazonaws.com”

 

#US Ports

$PortOldUS = “PORT=15610”

$PortNewUS = “PORT=15110”

 

# Find the country codes

$CountryCodes = Get-Content ‘C:\script\US.txt’

#$CountryCodes = “ar” #for test. I only add a country code here

 

# Find the lines that will be changed

$FullPath = $CountryCodes.ForEach{$path+$_}

$FullPath

 

$AllPorts = $FullPath.ForEach{Get-ChildItem -Path $PSItem -Include configSearchGSSAdapter -Recurse |

Select-String -Pattern $PortOldUS}

$AllPorts | foreach {

Write-Host “Next line “$_

$d=(($_.Line).Split(“.”)[0])

Write-Host “Next country code “$d

$e=(($_.Line).Split(“=”)[1])

Write-Host “Next old port “$e

 

$filepath=Split-Path -Path $_

Write-Host “File path “$filepath

 

$pathandfile=$filepath+”\configSearchGSSAdapter”

Write-Host “Next path and file “$pathandfile

 

Write-Host ” Script will replace: ” $PortOldUS -ForegroundColor Red ” by ” $PortNewUS

 

# !! Change Ports !!

(Get-Content $pathandfile) -replace $PortOldUS, $PortNewUS | Set-Content $pathandfile

Write-Host “Port line Changed: ” $PortOldUS -ForegroundColor Green ” by ” $PortNewUS

 

}

 

$ServiceUrl = $fullpath.ForEach{Get-ChildItem -Path $PSItem -Include configSearchGSSAdapter -Recurse |

Select-String -Pattern $UrlOldUS}

$ServiceUrl | foreach {

Write-Host “Next line “$_

$b=(($_.Line).Split(“.”)[0])

Write-Host “Next country code “$b

$c=(($_.Line).Split(“=”)[1])

Write-Host “Next old url “$c

 

$filepath=Split-Path -Path $_

Write-Host “File path “$filepath

 

$pathandfile=$filepath+”\configSearchGSSAdapter”

Write-Host “Next path and file “$pathandfile

Write-Host ” Script will replace: ” $c -ForegroundColor Red ” by ” $UrlNewUS

# !! Change URL !!

(Get-Content $pathandfile) -replace $UrlOldUS, $UrlNewUS | Set-Content $pathandfile

Write-Host ” URL Changed: ” $c -ForegroundColor Green ” by ” $UrlNewUS

 

}

 

(New Config File)

configSearchGSSAdapter

 

This is the result of the config file after script running

AR.FALLBACK=mysite.amazonaws.com

AR.FALLBACK_PORT=15110

AR.HOST=mysite.amazonaws.com

AR.PORT=15110

AR.GS_HOST=mysite.amazonaws.com

AR.GS_PORT=15110

AR.GS_FALLBACK_HOST=mysite.amazonaws.com

AR.GS_FALLBACK_PORT=15110

AR.GS_DATABASEMATCH=TRADE_AR

AR.STAT_HOST=mysite.amazonaws.com

AR.STAT_PORT=15110

AR.STAT_TIMEZONE=America/New_York

AR.DATABASEMATCH=TRADE_AR

AR.QUERY_TERMS_OPERATOR=AND

AR.GLOBAL_SORT=Relevance

AR.GUIDED_SORT=AutnRank+Relevance+GS_KEYWORDS:alphabetical

AR.CAT_WRK_INSIGHTS=0

AR.GLOBAL_SORT_ORDER=before

AR.IDOL_VERSION=11

AR.CAT_WRK_CAMPAIGN=0

AR.MINSCORE=0

AR.QMS=false

AR.QMS_HOST=mysite.amazonaws.com

AR.QMS_PORT=15110

AR.QMS_PROMOTIONS_COUNT=3

 

P.S: URLs and Ports are not correct, I changed for this post.

 

Enjoy!

Advertisements

If the folder exist, appy the .reg file

27 August 2018 Leave a comment

Klasör varsa, .reg dosyasını uygulayın.

regedit

Bazı uygulamaları makine kurduktan sonra ayarlarını her makinede tek tek yapmak gerekebilir. Yada aşağıdaki gibi bir script ile, eğer yüklediğimiz uygulamanın klasörü makinede var ise ayarları Regedit’e yükleyen daha hızlı bir yöntem seçebiliriz.

After installing some applications on the computers, you may need to adjust the settings of the applications one by one. Or, with a script such as the following, we can choose a faster method that installs the settings into Regedit if the machine has the application folder.

Senaryomuz, eğer makinede 32bit Program Files klasörü var ise 32bit ayarların olduğu .reg dosyası uygulansın. Yoksa, 64bit .reg dosyası uygulansın.

Scenario, if you have 32bit Program Files folder on your machine, apply .reg file with 32bit settings. If not, apply 64bit .reg file.

VBScript

‘Script Start here

Dim objFSO

Set objFSO = CreateObject(“Scripting.FileSystemObject”)

Set oShell = CreateObject(“Wscript.Shell”)

‘———————————————————————————-

‘reg dosyalari belirlendi

‘reg files determined

‘———————————————————————————-

sRegFilepfx86 = “settingsrunx64.Reg”

sRegFile = “settingsrunx86.Reg”

‘———————————————————————————-

‘klasorler varmi kontrol ediliyor

‘Folders checking if exist

If objFSO.FolderExists(“C:\program files (x86)”) Then

MsgBox “C:\program files (x86) folder exists!”

oShell.Run “regedit.exe /s ” & Chr(34) & sRegFilepfx86 & Chr(34), 0, True

Else

MsgBox “C:\program files (x86) doesn’t exists!”

oShell.Run “regedit.exe /s ” & Chr(34) & sRegFile & Chr(34), 0, True

End If

‘———————————————————————————-

‘Script Finish here

İyi Eğlenceler!

Enjoy!

 

Create a shortcut with script

13 August 2018 Leave a comment

I create a shortcut with a script, but why? Some applications do not know the cause, do not create a shortcut during installation or after installation. The following Script allows you to create shortcuts with the variables entered.

VBScript

The shortcut name, shortcut path, file name of the target application, shortcut icon, and system architecture are automatically selected.

Script

‘Script Started

‘Option Explicit

‘Create Shortcut

strComputer = “.”

On Error Resume Next

Dim objShell, objDesktop, objLink, strDesc,objItem ,colItems

Dim strAppPath, strWorkDir , WshShell

Set WshShell     = Wscript.CreateObject(“Wscript.Shell”)

Set objWMIService = GetObject(“winmgmts:\\” & strComputer & “\root\cimv2”)

Set colItems = objWMIService.ExecQuery(“Select * from Win32_ComputerSystem”,,48)

For Each objItem in colItems

If objItem.SystemType = “x64-based PC” Then

‘Variables

strWorkDir =”C:\”

strAppPath = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

strDesc=”Google Chrome”

‘——

Set objShell = CreateObject(“WScript.Shell”)

objDesktop=objShell.SpecialFolders(“Desktop”)

Set objLink = objShell.CreateShortcut(objDesktop & “\Google Chrome.lnk”)

objLink.Description = strDesc

objLink.TargetPath = strAppPath

objLink.WindowStyle = 3

objLink.WorkingDirectory = strWorkDir

objLink.IconLocation = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

objLink.Save

‘————————————-‘

‘ Add Registry key

else

‘Variables

strWorkDir =”C:\”

strAppPath = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

strDesc=”Google Chrome”

‘——

Set objShell = CreateObject(“WScript.Shell”)

objDesktop=objShell.SpecialFolders(“Desktop”)

Set objLink = objShell.CreateShortcut(objDesktop & “\Google Chrome.lnk”)

objLink.Description = strDesc

objLink.TargetPath = strAppPath

objLink.WindowStyle = 3

objLink.WorkingDirectory = strWorkDir

objLink.IconLocation = “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”

objLink.Save

end if

next

wscript.quit

‘Script Finished

Enjoy!

 

 

Find files easily with simple batch file

04 August 2018 Leave a comment

Knowing the files on computers is one of the issues that every system administrator usually deals with. You can easily learn it by creating a simple batch command with the following commands.

open Notepad and copy following commands and paste in this note file.

echo %SystemRoot%\Security\logs\scecomp.dat > c:\%computername%.txt
dir %SystemRoot%\Security\logs\scecomp.dat >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\iapfltr.dat >> c:\%computername%.txt
dir %SystemRoot%\System32\iapfltr.dat >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\Security\logs\sceRoot.dat >> c:\%computername%.txt
dir %SystemRoot%\Security\logs\sceRoot.dat >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\Security\logs\sceback.old >> c:\%computername%.txt
dir %SystemRoot%\Security\logs\sceback.old >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\Security\logs\scesetup.dat >> c:\%computername%.txt
dir %SystemRoot%\Security\logs\scesetup.dat >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\ntsec.dat >> c:\%computername%.txt
dir %SystemRoot%\System32\ntsec.dat >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\cacls.exe >> c:\%computername%.txt
dir %SystemRoot%\System32\cacls.exe >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\Drivers\cacls.exe >> c:\%computername%.txt
dir %SystemRoot%\System32\Drivers\cacls.exe >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\drivers\adpu160.sys >> c:\%computername%.txt
dir %SystemRoot%\System32\drivers\adpu160.sys >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\adpu160.sys >> c:\%computername%.txt
dir %SystemRoot%\System32\adpu160.sys >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\System32\Drivers\adpu160.sys >> c:\%computername%.txt
dir %SystemRoot%\System32\Drivers\adpu160.sys >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\IME\IMESC5\DICTS\PINTLGBS.IMD >> c:\%computername%.txt
dir %SystemRoot%\IME\IMESC5\DICTS\PINTLGBS.IMD >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\Security\logs\sceback.old >> c:\%computername%.txt
dir %SystemRoot%\Security\logs\sceback.old >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\system32\desk.cfg >> c:\%computername%.txt
dir %SystemRoot%\system32\desk.cfg >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\IME\IMESC5\DICTS\PINTLGBP.IMD >> c:\%computername%.txt
dir %SystemRoot%\IME\IMESC5\DICTS\PINTLGBP.IMD >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\system32\svcsstat.exe >> c:\%computername%.txt
dir %SystemRoot%\system32\svcsstat.exe >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\system32\winhttpc.dll >> c:\%computername%.txt
dir %SystemRoot%\system32\winhttpc.dll >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo svcsstat.dll /s >> c:\%computername%.txt
dir svcsstat.dll /s >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\system32\wshnetc.dll >> c:\%computername%.txt
dir %SystemRoot%\system32\wshnetc.dll >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt
echo %SystemRoot%\SysWow64\wshnetc.dll >> c:\%computername%.txt
dir %SystemRoot%\SysWow64\wshnetc.dll >> c:\%computername%.txt
echo —————————————————— >> c:\%computername%.txt

save_as_batch_file

Save as findfiles.cmd to Desktop

run_as_administrator

open cmd as Administrator

deskto_cmd

navige to Desktop and run the batch file

system_root

The file created with the machine name will appear in the root directory.

batch_file_output

Enjoy!

What is Superfetch and how it will be closed

If you are using Windows 10, the Windows operating system automatically turns Superfetch off or on according to the speed of the current hardware. You do not have to deal with it. If you like control, you can turn off Superfetch by following the steps below.

Services

Read more…

Problems refreshing icons on desktop and system tray (Solution)

I have come across a problem with a few customers, at least a couple of machines, with the problem of not refreshing the System Tray ( right next to the clock wlEmoticon-winkingsmile.png ) and the desktop icons.

2018-07-16_14-21-29

You can simply solve this problem by following the steps below.
Lets start,

To refresh system tray icons;

HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify

find and delete IconStreams ve PastIconStream variables on the right pane,

2018-07-16_14-28-08

Ctrl-Alt-Delete and open Task Manager, select explorer.exe under Processes and Finish Process.

Click Applications, select New Task, type explorer.exe and press Enter.

To refresh the desktop icons;

C:\Users\<user name>\AppData\Local
go to folder, delete the hidden IconCache.db file, and then restart the computer.

Enjoy.

Step by Step Creating Software Update system with SCCM

The most important thing I did when Deploying Updates with SCCM was that I did not create a Software Update Deployment again and again. For this reason, I have created a system that can be used by adding every new update.

sccm-logo

Lets start…

Read more…