Task Running on Port

Find Process Listening on Port

Execute on powershell to find the process that listens on port 8080:

Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess

Take the Id and kill it e.g. in task manager.

Golang With Race Detector on Windows

Install gcc with:

# does not work anymore with eset virus scanner, get permission denied while compiling go programs
choco install winlibs
# better use
scoop install mingw-winlibs

Convert MBR to GPT

Follow this manual:

https://learn.microsoft.com/en-us/windows/deployment/mbr-to-gpt

Remote Reboot

Remote Reboot

net use \\<<server>>\IPC$ <<password>> /USER:<<user>>
shutdown /r /m \\<<server>> /c "Comment" /f /d U:0:0

If you got an error message:

A system shutdown is in progress.(1115)

You can try https://download.sysinternals.com/files/PSTools.zip

Execute:

.\pskill \\Computer-Name winlogon
.\pskill \\Computer-Name TrustedInstaller

Docker

With virtualbox

Docker and virtualbox are not working together.

Docker uses Hyper-V which breaks Virtualbox.

To disable Hyper-V execute in an admin shell:

bcdedit /set hypervisorlaunchtype off

and reboot.

To enable it again:

bcdedit /set hypervisorlaunchtype auto

and reboot.

Backup using rsync

The backup will copy files from windows to a NAS that has a share available via rsync.

Install Cygwin

Make sure you have cygwin installed with the package rsync.

For all further steps I expect that cygwin was installed in C:\cygwin64

Configure the NAS

Backup Script

I store my script in folder %userprofile%.

#!/bin/sh
rsync -aP --delete /cygdrive/d/bilder rsync://idefix@nas/Bilder

Shortcut in Windows

To get the script easily executed we create a shortcut on our desktop.

Fill as target:

C:\Windows\System32\cmd.exe /c ""C:\cygwin64\bin\sh.exe" --login -i /cygdrive/c/Users/idefix/backup.sh"

Fill as path:

C:\cygwin64

If you now click the shortcut, it should open a window and directly start with the sync.

Add Script to Taskbar

To add a script (e.g. a shell script) into your taskbar create a shortcut of your script. Then edit the target from e.g.:

D:\tools\updateapp.bat

to

cmd /C D:\tools\updateapp.bat

Maybe you would like to also change the icon?

Now right click it and select “Pin to taskbar”.

Run Script As Admin

To run a script on newer windows version with UAC enabled you can use the following wrapper:

:::::::::::::::::::::::::::::::::::::::::
:: Automatically check & get admin rights
:::::::::::::::::::::::::::::::::::::::::
@echo off
CLS
ECHO.
ECHO =============================
ECHO Running Admin shell
ECHO =============================

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

setlocal DisableDelayedExpansion
set "batchPath=%~0"
setlocal EnableDelayedExpansion
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO args = "ELEV " >> "%temp%\OEgetPrivileges.vbs"
ECHO For Each strArg in WScript.Arguments >> "%temp%\OEgetPrivileges.vbs"
ECHO args = args ^& strArg ^& " "  >> "%temp%\OEgetPrivileges.vbs"
ECHO Next >> "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%SystemRoot%\System32\WScript.exe" "%temp%\OEgetPrivileges.vbs" %*
exit /B

:gotPrivileges
if '%1'=='ELEV' shift /1
setlocal & pushd .
cd /d %~dp0

::::::::::::::::::::::::::::
::START
::::::::::::::::::::::::::::

REM Run shell as admin (example) - put here code as you like
ECHO Arguments: %1 %2 %3 %4 %5 %6 %7 %8 %9
C:\WINDOWS\system32\cmd.exe /c ""C:\Program Files\Git\usr\bin\sh.exe" --login -i /d/tools/restarttomcat.sh"

Git on Windows

To install git for windows go to website: https://git-for-windows.github.io/ and download the latest version. I tested it with Git-2.3.5.8-dev-preview-32-bit.exe.

Apache virtual host configuration:

gitweb.conf
<VirtualHost *:80>
SetEnv GIT_PROJECT_ROOT "D:/Gitrepos"
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAliasMatch \
	"(?x)^/(.*/(HEAD | \
			info/refs | \
			objects/(info/[^/]+ | \
				[0-9a-f]{2}/[0-9a-f]{38} | \
				pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
			git-(upload|receive)-pack))$" \
			"D:/Git/mingw64/libexec/git-core/git-http-backend.exe/$1"

DocumentRoot "D:/Git/mingw64/share/gitweb"
<Directory "D:/Git/mingw64/share/gitweb">
	DirectoryIndex gitweb.cgi
	<Files *.cgi>
		SetHandler cgi-script
	</Files>
	Options ExecCGI FollowSymLinks
	SetEnv  GITWEB_CONFIG "d:/Gitrepos/gitweb.conf"
	AuthType Digest
	AuthName "Git Password Required"
	AuthDigestDomain /git/
	AuthUserFile "D:/Gitrepos/htdigest_passwd"
	Require valid-user
</Directory>
<Directory />
	AuthType Digest
	AuthName "Git Password Required"
	AuthDigestDomain /git/
	AuthUserFile "D:/Gitrepos/htdigest_passwd"
	Require valid-user
</Directory>
</VirtualHost>

Edit the file d:\Git\mingw64\share\gitweb\gitweb.cgi and change the first line to:

#!D:/Strawberry/perl/bin/perl.exe

And modify the function get_file_owner:

sub get_file_owner {
	my $path = shift;

	my $owner = "Matthias Fechner";
	return to_utf8($owner);
}

Create a config file for gitweb:

d:\gitrepos\gitweb.conf
our $GIT = "d:/Git/bin/git";
our $projectroot= "d:/Gitrepos";
our $git_temp = "/d";
our $projects_list = "d:/Gitrepos/projects.list";
our $export_ok = "git-daemon-export-ok";
our $strict_export = "false";

If you get an error message that CGI.pm is missing you can install it manually using the cpan shell. At first we define a possibly required proxy, so open a git shell and do:

export http_proxy=http://proxyhost:proxyport/
export ftp_proxy=http://proxyhost:proxyport/
cpan install CGI

If you have problems with proxy authentication you can configure user and password also manually with:

cpan
o conf http_proxy proxyhost
o conf ftp_proxy proxyhost
o conf proxy_user username
o conf proxy_passw password
o conf commit
exit

Kill remotely a task

taskkil /S \\<<servername>> /IM Tomcat7.exe

Using Remote Desktop 8-bit Color Depth

If you use a high resolution screen and windows server 2003 SP2 only shows you 8-bit color (256 colors) you can do the following. See these links:
http://www.microsoft.com/en-us/search/DownloadResults.aspx?q=kb2685939 http://support.microsoft.com/kb/942610

Download hotfix:
http://hotfixv4.microsoft.com/Windows%20Server%202003/sp3/Fix205471/3790/free/330838_ENU_i386_zip.exe

After applying the hotfix change registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\AllowHigherColorDepth
to 1.

Virtualbox

Use physical disk on Win7

Run cmd as administrator. Run diskpart.

list disk
select disk 3
offline disk
attributes disk clear readonly
attributes disk

Exit diskpart.

Create vmdk file with:

"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" internalcommands createrawvmdk -filename d:\virtualbox\usb3disk0.vmdk -rawdisk \\.\PhysicalDrive3
RAW host disk access VMDK file d:\virtualbox\usb3disk0.vmdk created successfully.

Start Virtualbox and enter global settings. Change the path for VMs to D:\virtualbox. Close virtualbox and start it as administrator.

Choose you VM, click change, and add your vmdk file as harddisk. Start your VM and enjoy.

Vista

Integrate Updates to Install DVD

At first we need the windows AIK, you can download it here [[http://www.microsoft.com/downloads/details.aspx?displaylang=de&FamilyID=94bb6e34-d890-4932-81a5-5b50c657de08]]

Vista 64Bit -> 32Bit Programs cant reach the Network - solution

Start the Command-Line as Administrator (Start, Run “cmd”, Rightklick, Run as Administrator)

A black Commandline-Box appears, type:

netsh
winsock
reset

Now the following Text appears:

Der Winsock-Katalog wurde zurückgesetzt.
Sie müssen den Computer neu starten, um den Vorgang abzuschließen.

Type

exit

Reboot the Computer.

XP

Slow domain login

Do the following to speed up the login:

start-->run-->gpedit.msc-->Computer Configuration-->Administrative Templates-->System-->Logon

Enable “Always wait for the network at computer startup and logon”.

see

How to remove not connected Devices

To see and remove not connected devices in the DeviceManager, do the following:

Set an Evironment Variable “DEVMGR_SHOW_NONPRESENT_DEVICES” to the Value “1”. Over the DOS-Box:

SET DEVMGR_SHOW_NONPRESENT_DEVICES=1

or over the Menue:

German Windows: "Systemeigenschaften" - "Erweitert" - "Umgebungsvariablen"

Now go to the DeviceManager, and activate in the Pulldown-Menue

German Windows: "Ansicht" - "Ausgeblendete Geräte anzeigen"

now you can see all Devices, Present or not. Removal of un-used Devices increases the Bootup-Speed too.

Optimize Removal Devices to Remove Without Deactivating

Rightklick on the Drive, Properties (Eigenschaften)
Tab “Hardware”
Search for the Device in the List, select Properties (Eigenschaften)
Tab “Richtlinien”
German Windows: “Für schnelles Entfernen optimieren”
English Windows: “Optimice for fast removal”

Login User Automatically

http://support.microsoft.com/kb/315231/de

Or the easyer Way:
Start - Run: “CONTROL USERPASSWORDS2”
In the upcoming Dialog remove the Checkfield “User must enter Passwort”. Select the User who shouldt be Logged in. Press OK, enter the desired Password - ok.

Windows “Zeitsynchronisierung” select new Intervall

Bei Windows-Rechnern, die nicht in Domänen hängen:

Um die Zeitsynchronisation unter Windows häufiger ausführen zu lassen (Standart ist jede Woche einmal):
In der Registry folgenden Wert anpassen:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient\SpecialPollInterval

Das gewünschte neue Intervall in Sekunden in den Wert eintragen.
Danach den Dienst “W32Time” (Windows-Zeitgeber) neu starten.

Auf die Uhrzeit in der Taskleiste doppelklicken (alternativ Systemsteuerung/Datum und Uhrzeit), und einen gültigen NTP-Server eintragen. “Jetzt Synchronisieren” klicken. Das Datum der nächsten Abfrage sollte nun richtig sein.

Reduce the Wait Time for chkdsk at Startup

To reduce the 10 seconds to 0 type in the console:

chkntfs /T:0

Build your Own Windows CD

http://www.german-nlite.de/

Log MSI Installation

Add to your registry the following key:

KEY_LOCAL_MACHINE\\Software\\Policies\\Microsoft\\Windows\\Installer
String value: Logging=voicewarmup

It generates in your temp folder a logfile, search their for commandline.

Single Sign On

[[http://support.etouch.net/cm/wiki/support.Downloads.wiki/home/Configuring%20SSO%20using%20NTLM%20for%20IIS5.0.html]]

Process Explorer

[[http://www.microsoft.com/technet/sysinternals/processesandthreads/processexplorer.mspx]]

Automatic Proxy Configuration

Typical names for proxy auto configuration are:

You can also ask the nameserver with:

dig axfr @<nameserver> zone |grep wpad

The link is then:

wpad.domain/wpad.dat

Remove Service

Go to management console and search for the service name inside the service property. Stop the service now.

Then open the command shell and insert:

sc delete <servicename>

Scan Windows Systemfiles for Changes (DE)

Windows XP Systemdateien überprüfen lassen

Windows XP legt glücklicherweise automatisch eine Kopie der wichtigsten Systemdateien an um einen fehlerfreien Betrieb zu gewährleisten. Diese Kopien der Systemdateien befinden sich im Ordner Windows\System32\dllcache. Dieser Ordner ist versteckt und nur sichtbar, wenn man die entsprechenden Optionen im Explorer eingestellt hat.

Wird eine dieser dort gesicherten Systemdateien gelöscht oder beschädigt, beispielsweise durch einen Virus oder ein Missgeschick, wird die Originaldatei automatisch wiederhergestellt.

Man kann diese Überprüfung und Wiederherstellung auch manuell starten und durchführen z.B. wenn man den Verdacht hat das irgendetwas in dieser Richtung passiert ist. Dazu öffnet man durch Eingabe von cmd unter Start -> Ausführen die Eingabeaufforderung. Hier wird nun der Befehl sfc eingegeben. Zusätzlich werden an sfc noch Parameter, getrennt mit einem Leerzeichen, angehängt.

Folgende Parameter sind dabei möglich:

Werden falsche oder beschädigte Dateien gefunden, werden diese durch die Original-Versionen ersetzt. Dies geschieht, bildschirmgeführt, mit der Windows-CD.

Windows