Windows: Set Environment variables for users

For some cases you might need to set environment variables for your .NET application.
This is true to .NET core too, when you are storing your application settings in these variables.

How to set up a script for the job

It’s handy to create a windows command line script for creating these variables, because when you are on a new work environment, than you don’t need to look up the keys and values.

So bring up your most-loved text editor, make your environment_variable_creator.bat, and add the following code:

@echo on
SETX VARIABLE1 VALUE
SETX PREFIX_VARIABLE2 true
pause

If you are using .NET core’s configuration builder with a prefix like this:

				ConfigurationBuilder cfgBuilder = new ConfigurationBuilder();
				cfgBuilder.AddEnvironmentVariables("PREFIX_");
				IConfigurationRoot configuration = cfgBuilder.Build();
				var value = configuration["VARIABLE2"];

Then you need to set your variables with prefix “PREFIX_” in the bat file. In this scenario, VARIABLE1 can not be read, because it does not contain the prefix.

The code sets the variables only for your user account, not for others. You can parameterize the SETX command to set the settings for a different user, but i recommend, to run the script with a command line for the targeted user, because its much easier.

To run your script under other users name, then open your command prompt with ‘Run as… different user’

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Windows : Allow your programs through Windows Firewall

Search for applications with “firewall” keyword.
On Windows 10 – You will need Windows Defender Firewall with Advanced Security.

Click on “Inbound rules”, and on the right pane, select “New Rule..”.

Select The Port Option

If you want a specific port to unlock, select the port option. Select the correct transport protocol and port number on the next step

You can name your rule. It is recommended to choose a name, that describes the application which uses this port.

Your port now accessible on your local network. If you want to unlock a port to the Internet, you need to set up a port forward in your router’s settings.

This content has 3 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Windows: “Leírás nélküli hiba történt”

“Leírás nélküli hiba történt” mondják a Magyar Windows Server 2008-tól felfelé található verziói, felhasználó hozzáadásánál.

A probléma előidézése a következőképpen: Szerveren megnyitjuk a Számítógép kezelést, azon belül a Felhasználók és Csoportok lapon a Felhasználóknál új felhasználót szeretnénk felvinni, akinek a jelszava soha nem jár le, és a felhasználó nem módosíthatja a jelszót (Ezeknek a variációját nem próbáltam,  de ebben az esetben mindenképpen találkozunk a problémával.)

Amennyiben a jelszó túl könnyűnek számít, az adminisztrátor abban az esetben találkozik a fent említett hibaüzenettel.

A Windows csoportházirendében van egy Password policiryre vonatkozó beállítás, amellyel engedélyezhetjük a könnyű jelszavak használatát, de ennek állítása nem ajánlott, főleg kiszolgálókon.

Ajánlott megoldás: Válasszunk egy erős jelszót, amelyben kis- nagybetűk szerepelnek, számokkal együtt, és legalább 8 karakter hosszúak.

This content has 5 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.