All notes
Windows

# Windows server

## RDC, remote desktop connection

### Enable RDC

Search for “Remote Access” in the Start Menu or Start Screen.

Or, right click on "Computer", then "Properties" - "Remote Settings" - "Remote".

#### Problem: The credentials that were used to connect are incorrect.

First of all, make sure any RDC version is allowed. In the System Properties dialog box, under Remote Desktop, click either Allow connections from computers running any version of Remote Desktop or Allow connections only from computers running Remote Desktop with Network Level Authentication, and then click OK.

As for my problem, I found cause by manipulating on mmc (Microsoft Management Console), adding Snap-in of Local Users and Groups on local computer. It turns out that the credential failure is because I wanted to change the username to wheel but instead I only changed the display name.

#### How To Disable Credentials Prompt Of Remote Desktop 6.0

• To permanently skip the additional credential screen of RDP 6.0 client, edit the Default.RDP file in notepad to include enablecredsspsupport:i:0.
• The Default.rdp is located in each user’s My Documents folder.
• Including enablecredsspsupport:i:0 disables the Credentials Security Service Provider for the connection.
• If you use separate .RDP file for different servers, modify each of those .RDP files.

Below is the content section of the default.rdp file with enablecredsspsupport:i:0 option included.

redirectposdevices:i:0
authentication level:i:0
enablecredsspsupport:i:0
prompt for credentials:i:0
negotiate security layer:i:1


# Shortcuts

== Window related ==

ALT+SPACE: Displays the main window's System menu
(from the System menu, you can restore, move, resize, minimize, maximize, or close the window)
ALT+- (ALT+hyphen): Displays the Multiple Document Interface (MDI) child window's System menu
(from the MDI child window's System menu, you can restore, move, resize, minimize, maximize, or close the child window)

Windows + up: maximize window
Windows + down: restore window / minimize window

Windows Logo+M: Minimize all
SHIFT+Windows Logo+M: Undo minimize all

ALT+F4: Closes the current window
CTRL+F4: Closes the current Multiple Document Interface (MDI) window

== Explorer =

Alt+D: go to (edit) path.

== Other ==

ALT+double click: Displays properties

Windows Logo+E: Windows Explorer
Windows Logo+F: Find files or folders
Windows Logo+D: Displays the desktop

TAB: Move to the next control in the dialog box
SHIFT+TAB: Move to the previous control in the dialog box


## Windows command invoker for configure tools

• Microsoft Management Console (mmc.exe)
• Group Policy edit: gpedit.msc

# Commands

## appwiz.cpl

Fast way to open: "Control panel: Programs and Features".

## dism

Enable and Disable Hyper-v. Superuser.


dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All


## ipconfig


:: 清除dnscache.
ipconfig /flushdns
ipconfig /displaydns

:: windows dhcp renew command line
:: https://kb.wisc.edu/page.php?id=562
ipconfig /all
ipconfig /release
ipconfig /renew


## gpedit.msc

Group Policy Editor.

## net

### spooler

Forcefully clear the Print Queue in Windows:


net stop spooler
del %systemroot%\System32\spool\printers\* /Q /F /S
net start spooler


### net use


net use z: \\server\share

:: https://www.lifewire.com/net-user-command-2618097

net use * "\\server\my media" /persistent:no
:: In this example, I used the net use command to connect to the my media shared folder on a computer named server. The my media folder will be mapped to my highest free drive letter [*], which for me happens to be y:, but I don't want to continue mapping this drive every time I log on to my computer [/persistent:no].

net use e: \\usrsvr002\smithmark Ue345Ii /user:pdc01\msmith2 /savecred /p:yes
:: Here's a slightly more complicated example that you might see in a business setting.
:: In this net use example, I want to map my e: drive to the smithmark shared folder on usrsvr002. I want to connect as another user account I have [/user] by the name of msmith2 that's stored on the pdc01 domain with a password of Ue345Ii. I don't want to map this drive manually every time I start my computer [/p:yes] nor do I want to enter my username and password each time [/savecred].

net use p: /delete
:: I suppose an appropriate final example of net use would be the removal [/delete] of a currently mapped drive, in this case p:.



### net user


net user /?

net user [<UserName> [/delete] [/domain]]

## netsh


:: Direct connections from 192.168.1.111:4422 to 192.168.0.33:80

:: To remove forwarding:
netsh interface portproxy delete v4tov4 listenport=4422 listenaddress=192.168.1.111


## pkgmgr


pkgmgr /iu:"TelnetClient"


## runas




## sc

SO.


REM You must have quotation marks around the actual exe path, and a space after the binPath=.
sc.exe create <new_service_name> binPath= "<path_to_the_service_executable>"

Note that it will not work for just any executable: the executable must be a Windows Service (i.e. implement ServiceMain).


schtasks [/query] [/fo {TABLE | LIST | CSV}] [/nh] [/v] [/s computer [/u [domain\]user /p password]]

REM --------------------

schtasks /create /tn TaskName /tr TaskRun /sc schedule [/mo modifier] [/d day] [/m month[,month...] [/i IdleTime] [/st StartTime] [/sd StartDate] [/ed EndDate] [/s computer [/u [domain\]user /p password]] [/ru {[Domain\]User | "System"} [/rp Password]] /?

/sc   schedule   : Specifies the schedule type. Valid values are MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.

REM It schedules a security script, Sec.vbs, to run every 20 minutes. Because the command does not include a starting date or time, the task starts 20 minutes after the command completes, and runs every 20 minutes thereafter whenever the system is running.
schtasks /create /sc minute /mo 20 /tn "Security Script" /tr \\central\data\scripts\sec.vbs

REM scheduled shutdown

REM --------------------

REM SchTasks.exe ends only the instances of a program started by a scheduled task. To stop other processes, use TaskKill.



## services.msc

sophos.com. Opening the Windows Services list.

## shutdown


shutdown [{-l|-s|-r|-a}] [-f] [-m [\\ComputerName]] [-t xx] [-c "message"] [-d[u][p]:xx:yy]

-l : Logs off the current user, this is also the defualt. -m ComputerName takes precedence.
-s : Shuts down the local computer.
-r : Reboots after shutdown.
-a : Aborts shutdown. Ignores other parameters, except -l and ComputerName. You can only use -a during the time-out period.

-m [ \\ ComputerName ] : Specifies the computer that you want to shut down.
-f : Forces running applications to close.

-t xx : Sets the timer for system shutdown in xx seconds. The default is 20 seconds.
-c " message "   : Specifies a message to be displayed in the Message area of the System Shutdown window. You can use a maximum of 127 characters. You must enclose the message in quotation marks.

-d [ u ][ p ] : xx : yy   : Lists the reason code for the shutdown. The following table lists the different values.
u Indicates a user code.
p Indicates a planned shutdown code.
xx Specifies the major reason code (0-255).
yy Specifies the minor reason code (0-65536).


To shut down \\MyServer in 60 seconds, force running applications to close, restart the computer after shutdown, indicate a user code, indicate that the shutdown is planned, log major reason code 125, and log minor reason code 1, type: shutdown -r -f -m \\MyServer -t 60 -d up:125:1

/u   Domain \ User
/fi   FilterName
/pid   ProcessID
/im   ImageName Specifies the image name of the process to be terminated. Use the wildcard (*) to specify all image names.

/f   : Specifies that process(es) be forcefully terminated. This parameter is ignored for remote processes; all remote processes are forcefully terminated.
/t   : Specifies to terminate all child processes along with the parent process, commonly known as a tree kill.


taskkill /pid 1230 /pid 1241 /pid 1253
taskkill /s srvmain /u maindom\hiropln /p [email protected] /fi "IMAGENAME eq note*" /im *
taskkill /f /fi "PID ge 1000" /im *


## msiexec


:: Uninstall program:
msiexec /x {Package | ProductCode}

/a: Applies the administrative installation option.
/i: Installs or configures a product.
/x: Uninstall.
ProductCode: Specifies the globally unique identifier (GUID) of the Windows Installer package.


## mstsc

mstsc: MS terminal service client.

/v: computername — specifies the name of the computer to connect to.
/f — starts the connection in a full screen.
/w:width — specifies the width of the remote desktop screen.
/h:height — specifies the height of the remote desktop screen.


mstsc /v: Kaltec /w:640 /h:480


# Directories

## AppData\Roaming

Windows uses the Roaming folder for application specific data, such as custom dictionaries, which are machine independent and should roam with the user profile. The AppData\Roaming folder in Windows Vista is the same as the Documents and Settings\username\Application Data folder in Windows XP.

# Windows FAQ

## Sougou Input method

How to disable Ctrl+L shortcut?

1. Right click on Sougou input method bar and get the settings GUI.
2. Click "输入法管理".
3. Find "搜狗拼音快捷键", change it to other combination.

1. 选择“本地网络”, 右键“属性”
2. 选择“INTERNET PROTOCOL （TCP/IP）”然后点击“属性”。
3. 面板打开后，这时点击右下方的“高级”
4. 在IP地址下方点击“添加”　上方填上你的IP。

UPDATE 3: I switched back to native Ad-hoc support, and it works find now. Something to note: 1. Avira Antivirus is disabled since some says it may cause trouble to Adhoc. 2. When my cell phone goes out of scope, the WiFi adhoc will be automatically turned off after it finds no clients is connected. Just re-enable it.

UPDATE 2: Although windows 10 has native support for Ad-Hoc, but the connection is still un-stable. See howtogeek for other tips on how to reverse tethering. wcfNote: I tried the "Connectify Hotspot" and it works very well, except that it still need you to operate on LAN interface to share its internet.

UPDATE: now windows 10 has native support for Ad-Hoc. But after enabling the Ad-Hoc, you still need to operate on LAN interface to share its internet to the newly created connection.

tomsharedware shows that the Ad-Hoc network has "192.168.137.0".

1. Windows + X keys to open the power user settings panel, and launch Command Prompt (Admin) to get started.
2. Simply replace “adhocname” with a name of your choice, and to change the password, replace “password” with one of your choice: netsh wlan set hostednetwork mode=allow ssid=adhocname key=password.
3. Start the network: netsh wlan start hostednetwork.
4. Open the “View network connections” window, which can be found easily by searching for it using search bar in the Taskbar.
5. Right-click your Ethernet connection and select Properties and switch to the Sharing tab. Check the “Allow other network users to connect through this computer’s Internet connection” option, and choose the newly created WiFi connection from the drop down list located under “Home networking connection”.

REM First stop the old:
netsh wlan stop hostednetwork
netsh wlan set hostednetwork mode=disallow

netsh wlan set hostednetwork mode=allow ssid=wifi key=12345678
netsh wlan start hostednetwork

netsh wlan start hostednetwork
Start the wireless Hosted Network.

netsh wlan stop hostednetwork
Stop the wireless Hosted Network.

netsh wlan set hostednetwork [mode=]allow|disallow
Enable or disable the wireless Hosted Network.

netsh wlan set hostednetwork [ssid=] [key=] [keyUsage=]persistent|temporary
Configure the wireless Hosted Network settings.

netsh wlan refresh hostednetwork [data=] key
Refresh the wireless Hosted Network key.

netsh wlan show hostednetwork [[setting=]security]
Display wireless Hosted Network information.

netsh wlan show settings
Display wireless LAN global settings.


## Default printer changes on every restart of Windows 2008

1. Click Start, type "gpedit.msc" in the Start Search box, and then press ENTER.
2. Under "Local Policy", find through: Local policies | Computer config | admin templates | windows components | terminal services | terminal server | printer redirection. Enalbe the following:
• do not set default client printer to be default printer in a session
• redirect only the default client printer

If you leave the group policy setting “Do not set default client printer to be default printer in a session” as not Not Configured, in both Local Group Policy and domain Group Policy level, the server will automatically set the default printer on the client to be the default one in the remote session.

If you want to change this behavior, please change the policy setting to be Enable. In that situation, the default printer will be the local printer configured on the server side.

Policy path:
Windows Components\Remote Desktop Services\Remote Desktop Session Host\Printer Redirection
Scope: Machine

Registry settings:
HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\fForceClientLptDef


## Disable UAC

1. Goto "Control Panel".
2. Search for "uac".
3. Move the slider to the "Never notify".

## Host file

C:\Windows\System32\Drivers\etc\hosts.




## Page file, PAGEFILE.SYS

Optimizing Your Paging File. RAM, virtual memory, pagefile, and memory management in Windows. Windows NT uses a paging file for virtual memory called PAGEFILE.SYS.

• This file is created during Windows NT Setup and is always located in the root directory.
• The paging file is not necessarily a single file. The files are collectively referred to as "the paging file."
• When the memory being used by all the existing processes exceeds the available RAM, the operating system moves pages (4-KB pieces) of one or more virtual address spaces to the computer’s hard disk.
• If you have enough surplus RAM to support the operating system and application memory requirements, the need for a large paging file is lessened.
• If you have multiple hard disks, splitting up the paging file is a good idea, as it will speed up the access time. However, there is no point in splitting up the paging file between multiple partitions as it does not increase the ability of the hard disk to access the paging file.
• The location and size of the page file is configured in System Properties (click Advanced, click Performance, and then click the Settings button).

### Virtual memory

• In modern operating systems such as Windows, applications and many system processes always reference memory by using virtual memory addresses. Only core parts of the operating system kernel bypass this address translation and use real memory addresses directly.
• Virtual memory addresses are automatically translated to real (RAM) addresses by the hardware.
• Virtual memory is always being used, even when the memory that is required by all running processes does not exceed the volume of RAM that is installed on the system.
• All processes (for example, application executables) that are running under 32-bit versions of Windows are assigned virtual memory addresses (a virtual address space), ranging from 0 to 4,294,967,295 (2*32-1 = 4 GB), regardless of how much RAM is actually installed on the computer.
• In the default Windows configuration, 2 gigabytes (GB) of this virtual address space are designated for the private use of each process, and the other 2 GB is shared between all processes and the operating system. Typically, applications (for example, Notepad, Word, Excel, and Acrobat Reader) use only a fraction of the 2 GB of private address space. The operating system assigns RAM page frames only to those virtual memory pages that are being used.

#### Open Start up folder

Type "shell:startup" in start menu, the folder will open in explorer.

## Print Word with high quality images

bioPDF: PDF image quality. In Bullzip settings, uncheck the "Compress images". Then print to Bullzip.

MicroSoft answers. Try using the free PrimoPDF converter to convert (print) you document to a pdf file. In it's Prepress mode, the default setting is for "No Downsampling".

MSDN. If they insert an eps file into word and send it to us in a docx, we rename the docx to .zip and look in the images folder. What we find is that the images have been converted to well formed .emf files. The .emf files can be inserted into word 2010 and converted to a pdf with perfect quality.

Microsoft Anwsers. For Office newer than Version 2010, take a look in File tab - Options command - Advanced option - Image Size and Quality section. Look at the options to "Do Not Compress images in file" and "Set default target output to: ".

## Remove drivers

### Method 1

An easier (and arguably less error-prone) method to find the oem.inf file name would be to go into Device Manager, right-click the device, go to Properties, then Details tab, and select INF Name from the dropdown list.

### Method 2

Another option (the Microsoft way, without doing random unknown deletings in the registry) is to start CMD as "run as admin" and then list all installed drivers in the Windows 7 driver store via:


pnputil -e > C:\driverexport.txt

REM If you have found now the driver you need to remove use the following comand:
pnputil.exe -d OemNUMBER.inf

replace NUMBER with your number from your example. You might try to use -F to force the uninstallation. Once a reboot is done the driver should be gone. This might be also usefull to delete old drivers and get some HD space back.

1. Right click on This PC, and click on Manage to launch the Computer Management console. Once there, head over to the left pane, and click on Task Scheduler under System Tools.
2. The center pane will now show up a summary of scheduled tasks, along with information such as task status, active tasks etc. Move to the right Actions pane, and click on Create Basic Task to start the task scheduler wizard.
3. The Basic Task Wizard provides a simple stepwise approach for creating a simple scheduled task. At the first step of the wizard, provide a name and description to the task, and hit Next. On the next screen, you can configure the starting time for the task, as well as specify whether the task is a recurring one or not.
4. Over the next two steps of the wizard, you can specify the exact time and date for automatically running the task, and of course, select the program that you want to run automatically at the designated time.

## What is UNC

Universal Naming Convention (UNC).

In Windows operating systems, the UNC name format is:

\\servername\sharename\path\filename


## Install .Net 3.5 on windows 2012

Solution: update windows 2012 to latest and install again.

The bug is caused by that, installation of .Net 3.5 requires sxs installation media (thus the warning), while on Azure we don't have this.

## Nginx as a service

2. Rename the exe as nginxWrapper.exe. Add nginxWrapper.xml as follows.
3. nginxWrapper.exe install/uninstall/start/stop
4. Check whether there is already a nginx service.

NginxWrapper.xml:


<?xml version="1.0" encoding="UTF-8" ?>
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<executable>nginx.exe</executable>
<logmode>roll</logmode>
<arguments></arguments>
<depend></depend>
</service>

# Excel

## Shortcuts

### Windows

F2: Edit cell.
Ctrl+Shift+HOME: Select all text in a cell.


### MacOS

Apple+Shift+Left: Select all text in a cell.


# Visual studio

SN for 2013 ultimate: BWG7X-J98B3-W34RT-33B3R-JVYW9

# Softwares

• Image Viewer: IrfanView