Category Archives: Windows

Get Monitor Size programmatically

Hello everyone,

today I want to show you how you can use C# to get the physical size of a monitor in inches. This can be helpful if you need to know the physical size of a monitor and you do not know where it is located or if you want to get a list of average monitor sizes in your company.

All you need to do to make this work is the below code snippet:

using System;
using System.Management;

namespace GetScreenSize
{
    class Program
    {
        static void Main(string[] args)
        {
            //Get monitor data
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(@"\root\wmi", @"SELECT * FROM WmiMonitorBasicDisplayParams");

            //Calculate and output size for each monitor
            foreach (ManagementObject managementObject in searcher.Get())
            {
                //Calculate monitor size
                double width = (byte)managementObject["MaxHorizontalImageSize"] / 2.54;
                double height = (byte)managementObject["MaxVerticalImageSize"] / 2.54;
                double diagonal = Math.Sqrt(width * width + height * height);

                //Output monitor size
                Console.WriteLine("Monitor Size: {0:F1}\"", diagonal);
            }

            Console.ReadLine();
        }
    }
}

If you have multiple monitors connected to your computer the above code will output the size of each monitor.

Important: You need to add a reference to System.Management to make the above code work.

Well, that´s it. Now you are able to get the physical size of your monitor without having to measure it.
I hope you liked my post and I hope to see you again next time 🙂

As always you can download my code from here.

Sources:

http://www.c-sharpcorner.com/forums/get-the-monitor-size

https://richardspowershellblog.wordpress.com/2011/06/15/rootwmimonitor-information/

http://stackoverflow.com/questions/4314630/managementobject-class-not-showing-up-in-system-management-namespace

Tagged ,

Connect to Wireless Display dongle

Hello everyone,

today I want to show you a little project I have been working on 🙂

The project:

My father was searching for a way to watch videos and pictures on his big TV screen. (To watch YouTube Videos or show family pictures to his friends, etc.) Since his TV is not the newest one and I wanted to keep it as simple as possible for him I came up with this idea:

Use a tablet PC as the core component and a Wireless display dongle to mirror the tablet PCs screen. This way the tablet PC is both: The computer and the remote control.

Here is the hardware I used:

TrekStor SurfTab wintron 7.0 as the tablet PC.

wintron_7
VicTsing 2,4 G HDMI Miracast Dongle as the Wireless display dongle.

victsing_miracast_dongle

How I did it:

As you may know many tablet PCs have a “Windows Key” which, in my opinion, is not very useful in its default state. It opens the Windows Start Menu like every normal Windows Key on a standard keyboard but how often do you need this on a tablet? (It makes more sense on tablet PCs which have a hardware keyboard because you can use keyboard shortcuts but most of the cheap tablet PCs do not have a hardware keyboard.) So I thought: Why not reuse it for an other purpose? So I used AutoHotkey to remap the Windows Key to a custom script I wrote. (I got this idea after reading this post on stackoverflow. The user jaredbaszler published a great AutoHotkey script to connect to a specific Wireless display dongle which inspired me to write my own AutoHotkey script for this project.)

wintron_7_win_key
And here is the script which will connect our tablet PC to our Wireless display dongle: (Please keep in mind that this script will only work as expected if you have only 1 Wireless display dongle up and running. If you have multiple Wireless display dongles please have a look at jaredbaszler´s script here.)

LWin::
Send #k ; Sends Windows button + K to open the Action Center Connect window
Sleep, 3000 ; Wait some time so the wireless display dongle can be found
Send {Enter} ; Send ENTER key to connect to wireless display dongle (works when only 1 is found)
Send {Esc} ; Send ESC key to close the Action Center Connect window
Return

This is what the script does:

Every time the user touches the Windows Key it will do the following:

  1. First it will press WIN+K which will open the Action Center Connect window
  2. Then it will wait for 3 seconds so that the wireless display dongle can be found (You can adjust this value as you please but I needed to wait more than 2 seconds for my wireless display dongle to show up)
  3. After the wait it will press ENTER which will automatically choose the first wireless display dongle in the list and trigger the connect function (If no wireless display dongles can be found your Default Browser will open the “Help” link)
  4. The last thing the script does is to press the ESC key to close the Action Center

Please keep in mind that this will always result in connecting to the Wireless display dongle which shows up first in the Connect window. If you are already connected to a Wireless display dongle touching the Windows Key again will result in a disconnect. (I copied the explanation from my answer from stackoverflow to save some time.)

Automate the script:

The last thing we need to do is to run the script every time the user logs on. I did it by configuring a new Task in the Task Scheduler.

wintron_7_task_0
Choose a name for your Task.

wintron_7_task_1
Now choose a Trigger. (I chose to run the Task at user log on.)

wintron_7_task_2

Now simply choose the ActionStart a program” and set the path to your script.

wintron_7_task_3

Next have a look at the Conditions. You will want to uncheckStart the task only if the computer is on AC power.“. Most of the time your tablet PC will not be connected to your power supply when you use it.

wintron_7_task_4

The Settings tab will allow you to define the behavior of your Task.

wintron_7_task_5

Click on OK and you are ready to go.

Tip: If you do not want to install AutoHotkey on your tablet PC you can convert your scripts to executable files by following this guide here.

Well, that´s it. I hope you liked my post and I hope to see you next time 🙂

Sources:

http://stackoverflow.com/questions/35601005/autoconnect-to-ms-wireless-display-on-windows-10

https://autohotkey.com/docs/commands/Send.htm

http://www.computerhope.com/tips/tip209.htm

 

Tagged ,

Windows 10 – Create new Local User Account

Hello everyone,

welcome to my first post of the year 2016. I hope you had a happy Christmas and a happy new years eve 🙂

Today I´m going to show you how you can simply create a new local user account in Windows 10 if you need one. You may ask yourself why I am writing a post about something as simple as that but let me tell you: Microsoft changed the way to create local users in Windows 10 and therefore this task is not as simple as it was in Windows 7 anymore.

Posts like this one from How-To Geek explain pretty good how creating users works now in Windows 10. In my opinion this is too much hassle for a simple requirement like this. Please Microsoft implement something like a simple “Add Button” for local user accounts.

Ok. Although the process of creating a new local user account got more difficult on the GUI than it used to be you will be happy to hear that it still takes only seconds on the command line. Here is what you need to do to create a new local user:

Run cmd as Administrator.

net user <Username> <Password> /add

Well, that´s it. You have successfully created a new local user account 🙂

Deleting a user account is just as simple:

net user <Username> /del

As you can see the good old command line is always there to help 🙂

I hope my post was useful for you and I hope to see you again next time 🙂

Sources:

http://www.howtogeek.com/226540/how-to-create-a-new-local-user-account-in-windows-10/

http://www.groovypost.com/howto/create-local-account-windows-10/

http://thejackol.com/2004/08/03/create-a-local-windows-user-account-cnet/

http://www.wikihow.com/Add-and-Delete-Users-Accounts-With-Command-Prompt-in-Windows

Tagged ,

Export and Import WLAN Profiles

Hello everyone, today I want to show you how you can transfer your WLAN Profile data to another computer. Here is the story behind this post: A few days ago my brother bought a new laptop and asked my if I know a comfortable way to teach his new laptop all necessary information it needed to automatically connect to his WLAN networks like his old laptop did since he did not want to connect to all needed WLAN networks again and enter all the passwords again. So, he basically asked me to configure his new laptop so that it would automatically connect to his WLAN networks at home, at his friends or at work like his old one did. Well, thanks to Google and some great posts mentioned in the Sources below I was able to do this and I will show you how you can do it.

Ok. Let´s begin 🙂

The first thing you need to do is to run cmd as Administrator.

Next run the following command to get a list of all WLAN network profiles saved on your computer:

netsh wlan show profiles

Next run the following command to export a specific WLAN network profile:

netsh wlan export profile "YourSSID" key=clear folder="C:\Users\You\Desktop"

The above command will create an XML file like this:

<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
<name>YourSSID</name>
<SSIDConfig>
<SSID>
<hex>596f757253534944</hex>
<name>YourSSID</name>
</SSID>
<nonBroadcast>false</nonBroadcast>
</SSIDConfig>
<connectionType>ESS</connectionType>
<connectionMode>auto</connectionMode>
<MSM>
<security>
<authEncryption>
<authentication>WPA2PSK</authentication>
<encryption>AES</encryption>
<useOneX>false</useOneX>
</authEncryption>
<sharedKey>
<keyType>passPhrase</keyType>
<protected>false</protected>
<keyMaterial>YourPassword</keyMaterial>
</sharedKey>
</security>
</MSM>
</WLANProfile>

Now transfer the above file to the computer (I´ll call it computer B) where you want to import the WLAN profile data.

Now run cmd as Administrator on computer B.

To import the WLAN profile run the following command: (The command will import the data for all users. If you want only your current user to get the data replace “user=all” with “user=current”)

netsh wlan add profile filename="C:\Users\You\Desktop\Wi-Fi-YourSSID.xml" user=all

Well, that´s it. Computer B has now all the necessary information about the WLAN network to connect to it.

I hope you liked my today´s post and I hope to see you again next time 🙂

Sources:

http://www.7tutorials.com/how-delete-forget-wireless-network-profiles-windows-81

http://winaero.com/blog/how-to-backup-your-wireless-network-profiles-in-windows-8-1-and-windows-8/

Tagged ,

Raspberry Pi 2 – Windows 10 IOT Installation

Hello everyone, today I came across a great post on reddit which explains how to install Windows 10 IOT on your Raspberry Pi 2 in the most simple way I have seen so far. And I will show you how you can install the current Windows 10 IOT Build so you can lay your hands on this new topic as soon as possible 🙂

To download the new Windows 10 IOT you first need a Microsoft Account. Then click on this link to sign up on Microsoft Connect.

After you have successfully signed up for Microsoft Connect download the file “Windows_IoT_Core_RPI2_BUILD.zip“.

Now if you don´t have the Windows 10 Insider Preview Operating System installed on your computer or on a virtual machine, don´t worry: You don´t need it. The only thing yo need is a 7zip file called “DISM10074.7z” which you can download from here. (You can find the original post where this file comes from in this reddit thread here.)

Important: Don´t forget to unblock the “DISM10074.7z” file before you unzip it.

windows10iot_DISM10074_unblock

Next unzip the above zip files. In “Windows_IoT_Core_RPI2_BUILD” you will find the file “Flash.ffu“. Place this file into the “DISM10074” directory you extracted from the second zip file.

windows10iot_DISM10074

Next run PowerShell as Administrator and use the command “cd” to change into your “DISM10074” directory.

Now insert your Micro SD Card (at least 8GB) and start diskpart with the below command.

diskpart

Now find out the Disk number of your Micro SD card by using the below command:

list disk

Write down the Disk number of your Micro SD Card and exit diskpart.

exit

Now for the last step. Run the below command to write the Windows 10 IOT image to your Micro SD card:

Important: Replace the X of PhysicalDriveX with the number of your Disk before you run the below command.

.\dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\\.\PhysicalDriveX /SkipPlatformCheck

Wait for the command to complete. If it says “The operation completed successfully” everything went as expected.

Now you can close the PowerShell window and safely remove your Micro SD card and you are ready to use Windows 10 IOT.

Insert your Micro SD card into your Raspberry Pi 2 and plug in all necessary cables. Please keep in mind that the first boot will take some time so please be patient and don´t turn off your Raspberry Pi 2.

Well, that´s it. You can now start to explore Windows 10 IOT. Have fun!

I hope my post was interesting for you and I hope to see you again next time 🙂

Sources:

http://www.reddit.com/r/raspberry_pi/comments/34cad5/windows_10_iot_core_raspberry_pi_2_preview_live/

https://ms-iot.github.io/content/win10/SetupRPI.htm

https://www.raspberrypi.org/forums/viewtopic.php?f=56&t=98395

http://www.engadget.com/2015/04/30/windows-10-preview-raspberry-pi-2/

https://mariofraiss.wordpress.com/2015/05/02/setup-your-rasperry-pi-with-windows-10-iot-in-a-hyper-v-or-physical-environment/

Tagged ,

Windows God Mode

Hello everyone, today I want to show you something neat you can use to simplify Administration of your Windows Systems. This neat little trick is called “God Mode”. Well, it does not provide you with the powers of a god but it delivers you a useful toolbox with almost all settings you need to efficiently administrate your Windows System. This is especially useful on Windows 8 and Windows 8.1 Systems if you are like me and struggle with the new interface.

Ok, here are the steps to create your own God Mode Shortcut:

First you need to create a new folder.

godmode_new_folder

Next think of a good name for your God Mode Shortcut and append the following string:

.{ED7BA470-8E54-465E-825C-99712043E01C}

For example I called my God Mode Shortcut “AllSettings”:

AllSettings.{ED7BA470-8E54-465E-825C-99712043E01C}

godmode_naming

When you hit enter you will notice that the folder icon will change immediately into the Control Panel icon:

godmode_icon

Double click on it to open the Settings window:

godmode_settings

Well, that´s it. You now have a neat little toolbox with a lot of useful settings set up in less than 1 minute. Pretty cool, right?

I hope my post was useful for you and I hope to see you again next time 🙂

Sources:

http://www.tomshardware.com/news/GodMode-Windows-7-How-to,9345.html

Tagged

Windows Server – Setup Mail Server for Development environment

Hi everyone. Today I want to show you how you can set up a simple Mail Server for your development environments.

To set up a simple Mail Server you need to do the following:

  • Setup Windows Server 2008R2 and give it a name you can easily remember (I chose smtp.intranet.com as name for my server)
  • Download Visendo SMTP Extender from here.

Installation of SMTP Server feature

Install the Windows Feature SMTP Server.

mail_server_install_feature_smtp

Now open IIS 6 Manager.

mail_server_iis6

Now select [SMTP Virtual Server #1] and click on Properties.

Now go to the Access tab and click on Relay…

Now make sure to enable the setting All except the list below and make sure to check the checkbox at the end of the window and click OK.

mail_server_iis6_access

Now go to the Delivery tab and click on Advanced…

The name of your server (the name of mine is smtp.intranet.com) will be entered in the Fully-qualified domain name text box. If not make sure to enter it and click on OK.

mail_server_iis6_delivery

Now open up Services and make sure the Startup Type of the service Simple Mail Transfer Protocol is set to Automatic.

mail_server_smtp_service_automatic

Installation of Visendo SMTP Extender

The Installation is pretty simple. Simply download the Installer mentioned above and run the Setup Wizard.

After the installation has finished open up the Visendo Configuration Wizard.

mail_server_visendo_accounts

Now create a new account.

mail_server_visendo_new_account

After you have created your accounts go to Settings and click on Start.

mail_server_visendo_start

Now go to Services and make sure that the Startup type of the service Visendo SMTP Extender is set to Automatic.

mail_server_visendo_service_automatic

Configuration of Windows Firewall

To make sure that your Mail Server will work as expected you need to allow POP3.

Create a new Inbound Rule in Advanced Settings of Windows Firewall.

Choose Port and click on Next.

mail_server_firewall_inbound_port

Now choose TCP and enter 110 in the Specific local ports text box.

mail_server_firewall_inbound_tcp_110

Now choose Allow the connections.

mail_server_firewall_inbound_allow

In the last step I checked Domain, Private and Public.

mail_server_firewall_inbound_profile

Client Setup

On your client machine start Microsoft Outlook.

mail_server_client_wizard_start

Now choose Yes and click on Next.

mail_server_client_wizard_yes

Now choose Internet E-mail and click on Next.

mail_server_client_wizard_internet

Now choose Manually configure server settings or additional server types and click on Next.

mail_server_client_wizard_manually

Now enter your account information like shown in the below screenshot and click on Next.

mail_server_client_wizard_account_settings

Now Microsoft Outlook will check if it is able to connect to your Mail Server and send an test E-mail.

mail_server_client_wizard_test_account_settings

If all tests are successful your configuration is finished and you are ready to go.

mail_server_client_wizard_finished

That´s it. Your Mail server and your client are now ready to use.

Sources:

http://jebass.blogspot.co.at/2009/02/making-pop3-smtp-server-work-with.html

http://www.visendo.com/VisendoDownloads.aspx?id=42

Tagged

BranchCache – Hosted Cache Mode File Server Tutorial

Hi everyone. Today I will show you how you can use BranchCache in Hosted Cache Mode to reduce your WAN traffic and to improve your users experience.

You need the following things:

  • Hosted Cache Server: Windows Server 2012 Standard (Windows Server 2008R2 Enterprise will work too but an Enterprise license is much more expensive)
  • Content Server: Windows Server 2008R2 Standard
  • Clients: Windows 7 Enterprise or higher or Windows 8 Enterprise or higher
  • WAN Emulator: WANem (more information about WANem here)

Test Setup

The below picture shows how I set up my test machines:

branchcache_test_setup

Additionally I configured Static Routes for my FileServer and my Client machines. The Static Route of the FileServer forces it to send traffic always over the WANEM machine to the Client machines. The Static Route for the Client machines forces them to send traffic always over the WANEM machine to the FileServer.

This way you can emulate how file downloads will behave over WAN links.

branchcache_test_setup_wan_route

This is what you need to do to make it work:

On the FileServer:

  • Run cmd as Administrator and run the following command:
route –p add <Client Machine IP> mask 255.255.255.255 <WANEM IP>

Important: You need to add a Static Route for every Client machine.

On the Client Machines (on all clients):

  • Run cmd as Administrator and run the following command:
route –p add <FileServer IP> mask 255.255.255.255 <WANEM IP>

On the WANEM machine:

  • All you need to do here is to make sure that packets will be forwarded.

Hosted Cache Server Setup

To setup your Hosted Cache Server you need to do the following:

Run PowerShell as Administrator and enter the following commands:

Install-WindowsFeature BranchCache -IncludeManagementTools
Enable-BCHostedServer -RegisterSCP

That´s all you need to do to make BranchCache work for your Windows 8 Clients.

For Windows 7 Clients there are some additional steps:

If you run cmd as Administrator and run the following command:

netsh branchcache show status all

branchcache_certificate_warning

You will receive a warning that you need a certificate to make BranchCache work for Windows 7 Clients. You can create a certificate for your Hosted Cache Server by following this instructions:

The first step is to install IIS on your Hosted Cache Server and click on Server Certificates.

branchcache_hc_certificate_start

Now click on Create Self-Signed Certificate…

branchcache_hc_self_signed_certificate

Choose a friendly name like “BranchCache” and click on OK.

branchcache_hc_create_certificate

Run mmc as Administrator and add the Snapin Certificates. Choose Computer account and click Next.

branchcache_hc_mmc_certificate

Now choose Local computer and click on Finish.

branchcache_hc_mmc_certificate_local_computer

Now open the Export Wizard.

branchcache_hc_mmc_export_certificate

Choose No, do not export the private key.

branchcache_hc_mmc_export_certificate_key

Next choose DER encoded binary X.509 (.CER).

branchcache_hc_mmc_export_certificate_DER

Now double click your certificate and go to Details. Copy the Thumbprint value and remove all whitespaces.

branchcache_certificate_thumbprint

Now run cmd as Administrator and run the following command:

netsh http add sslcert ipport=0.0.0.0:443 certhash=<Thumbprint value> APPID={d673f5ee-a714-454d-8de2-492e4c1bd8f8}

branchcache_certificate_added_success

If your run cmd as Administrator again and run the following command again, you will no longer receive the warning mentioned above:

netsh branchcache show status all

That´s it. You have successfully configured your Hosted Cache Server for Windows 7 and Windows 8 Clients.

Content Server Setup

The first thing you need to do is to install the feature BranchCache for network files on your FileServer.

branchcache_fileserver_install_feature

The next step is to create a GPO for your FileServer:

branchcache_fileserver_gpo_lanman

All you need to do is choose Allow hash publication for all shared folder.

branchcache_fileserver_gpo_hash_publication

The last step is to enable BranchCache on your Share:

Access your Shares Properties and go to Advanced. Now check Enable BranchCache and click on OK. Done.

branchcache_fileserver_share_enable_branchcache

That´s all you need to do to enable BranchCache on your FileServer.

Windows 8 Client Setup

To setup your Windows 8 Clients to use BranchCache you need to do the following:

Run PowerShell as Administrator and enter the following command:

Enable-BCHostedClient -ServerNames <Hosted Cache Server Name>

That´s it. Your Client is now ready.

Windows 7 Client Setup

To configure your Windows 7 Clients create a new GPO and enable the following BranchCache settings:

  • Turn on BranchCache
  • Set BranchCache Hosted Cache mode

branchcache_win7_gpo_turn_on_branchcache

Now enter the FQDN of your Hosted Cache Server.

branchcache_win7_gpo_hosted_cache_config

The next step is to configure your Clients Windows Firewall. Enable the following Inbound Rules:

  • BranchCache Content Retrieval (HTTP-In)
  • BranchCache Peer Discovery (WSD-In)

branchcache_win7_gpo_firewall

Now import the Hosted Cache Servers certificate which you exported earlier.

branchcache_win7_gpo_import_certificate

branchcache_win7_gpo_certificate

Import your certificate to Trusted Root Certification Authorities.

branchcache_win7_gpo_import_certificate_trusted

Additional step:

You can set a network latency value. If your network latency exceeds this value your client will get the data from your Hosted Cache Server instead of the Content Server. If you set a value of 0ms your Hosted Cache Server will be contacted always. (The default network latency value is 80ms).

Important: Please keep in mind that your clients will also get their data directly from your Content Servers if your files are smaller than 64KB.

branchcache_win7_gpo_network_latency

That´s it your client is now ready.

WANEM Setup

Access your WANEM machine via http://<WANEM IP>/WANem and setup a bandwidth limit and delay for your test.

branchcache_wanem_settings

Well, that´s it. You successfully configured BranchCache in Hosted Cache mode. Pretty simple, isn´t it?

I hope my post was interesting and useful for you.

You can read more about BranchCache in this document you can get from here.

Sources:

http://technet.microsoft.com/en-us/library/ff710475(v=ws.10).aspx

http://technet.microsoft.com/en-us/library/dd637793(v=ws.10).aspx

http://pertorben.wordpress.com/2013/04/19/branchcache-demonstration-part-1/

http://richfrombechtle.wordpress.com/2012/07/05/windows-server-2012-licensing-changes/

http://www.enterprisenetworkingplanet.com/windows/article.php/52231_3896131_2/Simplify-Windows-WAN-Optimization-With-BranchCache.htm

http://vninja.net/virtualization/installing-and-configuring-wanem-virtual-appliance/

http://www.itsyourip.com/networking/howto-add-persistent-static-routes-in-windows/comment-page-1/

Tagged , ,

Windows – Installation from Harddrive

Hello everyone. Today I found a method to install Windows directly from a hard drive.

To do so you need to do the following:

  • Get a hard drive you want to install into your machine (I chose a 64GB SSD)
  • Format it and choose NTFS as file system

setup_windows_harddrive_hdd

After you prepared your hard drive you need to copy the following folders and files from your Setup Medium to your hard drive:

  • boot
  • sources
  • bootmgr

setup_windows_harddrive_setup_files

Now run cmd as Administrator and run the following commands to make your hard drive bootable:

diskpart
list disk
select disk x
list partition
select partition x
active
exit
X:\boot\bootsect.exe /nt60 X:

Replace x and X with the values of your hard drive.

setup_windows_harddrive_cmd_bootsect

That´s it. Your preparations are done. Now insert the hard drive into your machine and make sure to boot from hard drive.

Install Windows as you would do normally but do not format your hard drive, otherwise all setup files would get lost and the setup will not finish successfully.

After Windows has been installed successfully, run cmd as Administrator and run the following command:

msconfig

setup_windows_harddrive_msconfig_boot

This will open a window like the one in the screenshot above. Now choose the Boot tab and select Windows Setup (\windows) and delete it. This will remove the Windows Setup option from the Boot Manager window when you boot your machine.

setup_windows_harddrive_delete_sources

The last step is to remove the setup files. To do so, delete the sources folder from the C partition of the machine.

That´s it. You successfully installed Windows without using any CDs/DVDs or USB Sticks or additional software. For more information have a look at the sources.

Sources:

http://www.instructables.com/id/Install-Windows-7-without-USB-or-DVD-without-upgra/

http://www.instructables.com/id/How-to-CLEAN-Install-Windows-8-directly-from-Hard-/

Tagged