Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Oct 9, 2021

Windows 10 window border change

Problem

Losing title bar when multiple windows overlap, finding drag position becomes harder.

Solution

>Windows > Settings > Colors
Select "Title bars and windows borders".

Windows Activation Issue

If Windows is not activated you can not change color settings.
We can enable window borders by regedit commands.

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM" /v "ColorPrevalence" /t REG_DWORD /d "1" /f

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM" /v "AccentColor" /t REG_DWORD /d "7439985" /f

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM" /v "AccentColorInactive" /t REG_DWORD /d "13882323" /f

Apr 4, 2020

Failed to install Intel HAXM

When installing Android SDK Platform-Tools on Windows you may see following error:

Running Intel® HAXM installer Failed to install Intel HAXM. 
For details, please check the installation log: HAXM installation failed. To install HAXM follow the instructions found at:
https://software.intel.com/android/articles/installation-instructions-for-intel-hardware-accelerated-execution-manager-windows
This computer does not support Intel Virtualization Technology (VT-x)
or it is being exclusively used by Hyper-V.
HAXM cannot be installed. Please ensure Hyper-V is disabled in Windows Features,
or refer to the Intel HAXM documentation for more information.
I will list 3 different options.

1. Program and Features

Be sure Hyper-V not marked. If installed uncheck it.

2. Command line (CMD)

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
or
bcdedit /set hypervisorlaunchtype off

3. Device Guard and Credential Guard hardware readiness tool

Download tool, unzip and open powershell window.

First change execution policy.
PS C:\temp\dgreadiness_v3.6> set-executionpolicy remotesigned 
Execution Policy Change The execution policy helps protect you from scripts that you do not trust.
Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic at https:/go.microsoft.com/fwlink/?LinkID=135170.
Do you want to change the execution policy? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a
Run command.
PS C:\temp\dgreadiness_v3.6> .\DG_Readiness_Tool_v3.6.ps1 -Disable 
Do you want to run software from this untrusted publisher?
File C:\temp\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1 is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"): a
You will see success messages.
Disabling Hyper-V and IOMMU
Disabling Hyper-V and IOMMU successful
Please reboot the machine, for settings to be applied.
After reboot continue to install HAXM.

Jul 23, 2019

Nvidia GPU driver errors

After Windows10 update Nvidia GPU driver corrupted. You can find driver downloads in Nvidia website (http://www.nvidia.com/Download/index.aspx)

Setup may not continue for some reasons. 2 errors described below.

Error1: Windows cannot verify the digital signature for this file

Disable enforced driver signing Run command line and type
shutdown /f /t 0 /r
Press "F8" and continue.
Click ‘Troubleshoot’.
Click ‘Advanced Options
Click ‘Windows Startup Settings
Click Restart.

After restart select ‘Disable driver signature enforcement‘ from the list by hitting F7. Then continue to install driver after Win10 booted.

Note: The shutdown command does not work in a RDP/Termial Session, otherwise error “The parameter is incorrect.(87)” occurs.

Error2: The graphic driver could not find compatible graphics hardware || Nvidia installer not compatible with this version of windows

Exit setup.

Go to Device Manager > Display Adapters > Select device from tree > Right click and select Properties
Go to Device tab > Select Hardware Ids from Property list
Copy first line (PCI\VEN_10DE&DEV_1BE0&SUBSYS_75071558&REV_A1) and quit

Go to Display.Driver folder which extracted from driver setup.

Open nvami.inf

Find NVIDIA Devices line: [NVIDIA_Devices.NTamd64.10.0...14310]

You will see many lines like below:
%NVIDIA_DEV.0DCE.204C.1043% = Section002, PCI\VEN_10DE&DEV_0DCE&SUBSYS_204C1043

Copy first line until PCI word: %NVIDIA_DEV.0DCE.204C.1043% = Section002,

Paste it to new line above copied line (under NVUDUA_Devices line) and then past hardwareId copied from Device Manager

%NVIDIA_DEV.0DCE.204C.1043% = Section002, PCI\VEN_10DE&DEV_1BE0&SUBSYS_75071558&REV_A1

Do same thing for the line [NVIDIA_Devices.NTamd64.10.0]

You will paste 2 newlines in total to nvami.inf file.

Save inf file to original location and run setup again.

Update

As of 23rd July something changed on Windows 10 and Nvidia setup. Check updates below.
1. If you can't reach Advanced Startup menu then lock your computer. While pressing shift key press power icon on screen and select Restart.

2. Changing inf file may not work on latest driver package. You may get following error:
Package install status code: Exception {0x800f024b - The hash for the file is not present in the specified catalog file. The file is likely corrupt or the victim of tampering.}.
3. Update Windows 10 to the latest version.
Check your version by typing winver to Windows search box to see version. Your version may be older than driver supports.

Install driver from inf file.

Press "Let me pick from a list..." option.
 Find your device in list.

Press "Have Disk" button and find inf file.

Dec 4, 2018

Using git (VS 2017 edition) with VSCode

Make sure the folder contains git.exe is in PATH in Windows.

For Visual Studio Community Edition git.exe is in:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\cmd

Add project to local git

cd "folder path to your repo"
git init
git add . # add everything
git commit -m "initial commit" 

Use source control tab in VS Code

If you don't see GIT in source control tab you can update your git.exe location.

  1. Go to settings in VSCode and search for "git path".
  2. Click "Edit in settings.json"
  3. Add path to user settings

"git.path": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\Git\\cmd\\git.exe"

Add to remote repository

C:\repo>git config credential.helper store

C:\repo>git push https://gitlab.com/username/repo.git --all
git: 'remote-https' is not a git command. See 'git --help'.
git-remote-https command is not reachable
C:\repo>git-remote-https
'git-remote-https' is not recognized as an internal or external command,
operable program or batch file.
Add git-remote-https.exe folder path to PATH.
C:\repo>SET PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin
Now it is reachable.
C:\repo> git-remote-https                                                                                                      
error: remote-curl: usage: git remote-curl  []
C:\repo>git push https://gitlab.com/username/repo.git
git: 'credential-cache' is not a git command. See 'git --help'.
Username for 'https://gitlab.com': username
Password for 'https://username@gitlab.com':
git: 'credential-cache' is not a git command. See 'git --help'.
Counting objects: 2653, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2324/2324), done.
Writing objects: 100% (2653/2653), 23.62 MiB | 170.00 KiB/s, done.
Total 2653 (delta 670), reused 0 (delta 0)
remote: Resolving deltas: 100% (670/670), done.
To https://gitlab.com/username/repo.git
 * [new branch]      master -> master
Error: 'credential-cache' is not a git command

For msysgit versions 1.8.1 and above
git config --global credential.helper wincred
Versions older than 1.8.1
git config --global credential.helper winstore
Git config file:
[credential]
 helper = winstore
Related errors:
Git http-push is not a git-command
Adding "..\mingw32\bin" folder also solves it.

VSCode commit

Now you should be able to commit and push to remote repository in VSCode. After any change go to source control tab and press "Stage Changes" button. Fill the message and press Commit (check icon) button.

Nov 26, 2018

Cordova build errors and fixes

Creating a new cordova project

This is where we start to create a new project.
cordova create hello com.example.hello HelloWorld
Adding Android platform.
C:\hello>cordova platform add android
Using cordova-fetch for cordova-android@~7.1.1
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.example.hello
        Name: hello
        Activity: MainActivity
        Android target: android-27
Android project created with cordova-android@7.1.2
Android Studio project detected
Android Studio project detected
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
Installing "cordova-plugin-whitelist" for android

Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving android@~7.1.2 into config.xml file ...

Run the following command to build the project for all platforms

cordova build

Build Errors

ERROR1:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
Fix
Go to Start->Control Panel->System->Advanced(tab)->Environment Variables->System
Variables->New:
Variable name: _JAVA_OPTIONS   
Variable value: -Xmx512M

Variable name: Path  
Variable value: ;C:\Program Files\Java\jre6\bin;F:\JDK\bin;  
Change this to your appropriate path.
Restart computer!
ERROR2:
File C:\Users\oktay\.android\repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 26.0.2 in C:\Program Files (x86)\Android\android-sdk\licenses

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Build-Tools 26.0.2].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
Fix
Create license file in %ANDROID_HOME%
mkdir "%ANDROID_HOME%\licenses"
echo |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"
ERROR3:
Warning: License for package Android SDK Build-Tools 26.0.2 not accepted.
Fix
Manually accept the license.
C:\Program Files (x86)\Android\android-sdk\tools\bin>sdkmanager --update && yes | sdkmanager --licenses
ERROR4:
Checking the license for package Android SDK Build-Tools 26.0.2 in C:\Program Files (x86)\Android\android-sdk\licenses
License for package Android SDK Build-Tools 26.0.2 accepted.
Preparing "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)".
Warning: Failed to read or create install properties file.

The SDK directory (C:\Program Files (x86)\Android\android-sdk) is not writeable,
  please update the directory permissions.
Fix
Give Full permission to Everyone for sdk folder ( C:\Program Files (x86)\Android\android-sdk)

Giving full permission to "ALL APPLICATION PACKAGES" and "TrustedInstaller" didn't solve my problem.
Checking the license for package Android SDK Build-Tools 26.0.2 in C:\Program Files (x86)\Android\android-sdk\licenses
License for package Android SDK Build-Tools 26.0.2 accepted.
Preparing "Install Android SDK Build-Tools 26.0.2 (revision: 26.0.2)".
...
BUILD SUCCESSFUL in 2m 55s
46 actionable tasks: 46 executed
Built the following apk(s):
        C:\hello\platforms\android\app\build\outputs\apk\debug\app-debug.apk

Build project and Emulate in Andorid

cordova build
cordova emulate android
APPENDIX: A WARNING
C:\Program Files (x86)\Android\android-sdk\tools\bin>sdkmanager
Picked up _JAVA_OPTIONS: -Xmx512M
Warning: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[a-zA-Z0-9_-]+' for type 'idType'.
Warning: cvc-type.3.1.3: The value '' of element 'id' is not valid.
Warning: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[a-zA-Z0-9_-]+' for type 'idType'.
Warning: cvc-type.3.1.3: The value '' of element 'id' is not valid.
Warning: File C:\Users\oktay\.android\repositories.cfg could not be loaded.
[=======================================] 100% Computing updates...
Error resolved by creating an empty repositories.cfg file.

Cordova installation info is here

Nov 12, 2018

Install MySQL Docker (Windows)

I assume Docker already installed and running.

Pull mysql container

You can specify version (5.7). If version is not given it will download latest version.
C:\>docker pull mysql/mysql-server:5.7
5.7: Pulling from mysql/mysql-server
e64f6e679e1a: Already exists
478c78606b7e: Pull complete
81ab104e859d: Pull complete
d3565df0a804: Pull complete
Digest: sha256:79d65bf4360056b0709b4a1c4996f7ef8265ae6ca67462a8570ac1fa0855758b
Status: Downloaded newer image for mysql/mysql-server:5.7
Check docker image
C:\>docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
mysql/mysql-server         5.7                 76ac6291d3cf        2 weeks ago         234MB
Run mysql instance
docker run --name mysql1 -e MYSQL_USER=root -e MYSQL_PASSWORD=root -e MYSQL_DATABASE=homedb -p 3306:3306 -d mysql/mysql-server:5.7 
Check docker processes
C:\>docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS                             PORTS                 NAMES
44f6c176bb23        mysql/mysql-server:5.7   "/entrypoint.sh mysq…"   14 seconds ago      Up 13 seconds (health: starting)   3306/tcp, 33060/tcp   mysql1

Connect MySQL on docker

docker exec -it mysql1 mysql -uroot -p
If you did not provide a password in docker run command then system will generate a password. To change password and give some permissions:
C:\>docker logs mysql1 2>&1 | FindStr GENERATED
[Entrypoint] GENERATED ROOT PASSWORD: yBiG5ynmyvVurAw93HDok3buGhi

docker exec -it mysql1 mysql -uroot -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

CREATE USER 'root'@'%' IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;

SHOW GRANTS FOR 'root'@'%';

Connect MySQL on client

C:\Program Files\MySQL\MySQL Workbench 8.0 CE>mysql -h localhost -P 3306 -u root -p
mysql> select @@hostname;
+--------------+
| @@hostname   |
+--------------+
| 44f6c176bb23 |
+--------------+
1 row in set (0.00 sec)

Jul 6, 2018

Anonymous level security token - Windows Server

During a software installation if setup fails and shows similar logs like below then it is related with Windows Component system.

MSI (c) (48:B0) SOFTWARE RESTRICTION POLICY: Verifying package --> '...\NC.x64.msi' against software restriction policy 
MSI (c) (48:B0)  Note: 1: 2262 2: DigitalSignature 3: -2147287038  
MSI (c) (48:B0)  SOFTWARE RESTRICTION POLICY: ...\NC.x64.msi is not digitally signed 
MSI (c) (48:B0) SOFTWARE RESTRICTION POLICY: ...\NC.x64.msi is permitted to run at the 'unrestricted' authorization level.
The software which I tried to install had prerequisites (Dotnet Framework 3.5 etc).
After error, I tried to install Dotnet 3.5 manually from "Server Manager" by clicking "Add roles and features" link. But it failed and showed error below:

Anonymous level security token
To solve I followed these steps:

  1. Click Start > Run, type dcomcnfg.exe
  2. Click OK if you see the UAC warning
  3. Go to Component Services> Computers in the tree
  4. Right click My Computer > select Properties.
  5. Click Default Properties tab
  6. Select Connect in the Default Authentication Level list 
  7. Select Identify in the Default Impersonation Level list
  8. Click OK, and confirm the selection
  9. Close Component Services console




Feb 5, 2018

Python code to exe (Windows)

PyInstaller helps you convert your python code to executable software package.

Our test environment: Windows 7, Python 3.6

Create your python code file (hello.py)
print("Hello World!")
Download PyInstaller via pip
pip install pyinstaller
Run PyInstaller with python code file parameter on console
"C:\Program Files\Python36\Scripts\pyinstaller.exe" hello.py
You will see some commands on the screen. A few seconds later it will finish building. Build time is dependent your code (referenced packages).

Check dist folder for distribution copy of your application (hello.exe)

Size of the folder for hello.py is around 11mb.

I tried also py file with reference of cv2 library. Build time is around 30seconds and folder size becomes 157mb.

Oct 19, 2017

How to free up disk space on Windows

If you have a small disk size and have to open free space frequently on Windows then this post is for you.

You deleted some files, emptied recycle bin, moved some files to another drive but still you need free space. Because Windows is living, getting updates, creating cache files also you install new applications. First we will give a chance to Windows for disk cleanup then we will try to find more files to delete.

  1. Windows Cleanup

  2. Right click to C:\ drive and select Properties. You will see Disk Cleanup  button in General tab.
     

    This will give you some space. You can see many unnecessary items here like temporary files, Windows Update files etc. If you are not happy with that space then continue.

  3. Find more files

  4. WinDirStat is a utility that shows size statistics about your files and folders in your drive. With this tool you can see which folders and files have the most size. I love this tool because its graphical interface shows file types in colors, sizes as blocks. You can select a big block and see which file it is.  For example I ordered folders and files by size. In my computer the Installer folder is very huge. It occupies nearly 30% size in Windows folder. When you explore in Installer folder you will see many setup and patch files. We can't know which file is used by the system or necessary by looking their names. File names are like "1a88ba.msp".

  5. Analyze Installer folder

  6. You shouldn't delete files from Installer folder because uninstall process will search for installation files in this folder. Alternatively you can backup this folder content in somewhere else or zip the folder. This may also can create workload because you need to put right file again to start uninstall process.

    Patch Cleaner is an application that searchs Installer folder for unnecesarry files -namely orphaned files. 

    You can see necessary files with their explanation.
     

    Orphaned file list shows files that are not connected to any application.



    You can move orphaned files to another drive like a USB disk by pressing Move button.

  7. Continue to investigate files with WinDirStat

Dec 15, 2015

HTML5 Webcam Case: Create a self-signed certificate

Thanks to HTML5 which gives us the opportunity to use native HTML for some features. Without Flash or Silverlight we can use webcam. The new getUserMedia() function is used for capturing and video tag for displaying webcam content. 

Target

Assume that we have a web client in a kiosk and we want to run our webpage by opening a Chrome window. Creating a shortcut is easy part but you'll see Chrome asks for permission to enable webcam each time. This is a problem because someone has to allow webcam after a restart for example.

Solution

Running your website in HTTPS environment can solve this. Then Chrome will remember your preference for that page. If you allow webcam then each time it will gives permission automatically.

Self-signed Certificate

If you don't have an authorized certificate for the HTTPS then you can create a self-signed certificate in IIS. 

You can enter big numbers for validity days like 1000 (which is 3+years) but for some security reasons Chrome will give warnings for that. In our case use smaller numbers like 365days.
Now you can see the certificate in IIS > Server Certificates section.
In IIS go to your Website > Bindings and select your certificate in HTTPS type.

Now your server is ready for HTTPS call and client can see your page's url in "https://your-server-name/..." format.

But still not finished. Chrome will say it the certificate is not verified. This is a self-signed certificate and we need to add it to Trusted Certificates in client side. See the next post