Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Monday, March 23, 2015

Block all files in a folder in Windows Firewall

If you want to block all programs/files recursively in a folder from accessing the internet it is easier to use the following batch file (source).

@echo off
REM    BATCH FILE CREATED BY CHARLES DE HAVILLAND 20/02/2012

cls
If "%1"=="" GOTO :norulename
SET RULENAME=%1
ECHO Create in/out firewall rules for all *.exe files with the rulename of

"%RULENAME%" ?
ECHO.
ECHO.

pause
Echo.
FOR /r %%G in ("*.exe") Do (@echo %%G
NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=in program="%%G"

action="block" enable="yes")
FOR /r %%G in ("*.exe") Do (@echo %%G
NETSH advfirewall firewall add rule name="%RULENAME%-%%~nxG" dir=out program="%%G"

action="block" enable="yes")
Echo.
Echo done.
Echo.
GOTO :Finish
:norulename
Echo Error! - You did not specify a Rulename type - Addfwrs "Rulename"
Echo.
:Finish
Echo Batch ended...


Save it as addfwrs.bat. 

Place the file in a directory that is included in your system path (so it can be called easily), OR  place it in the root folder of the programs you want to block internet access for.

With Administrator access (type cmd, then right click on it and select 'Run as administrator'), change directory to the root directory of the programs you want to block internet access for (example: cd c:\Programs Files (x86)\YourProg\), run the batch file by typing: addfwrs [rulename]   example: addfwrs "YourProg"

N.B: It's important you add a firewall rule name, so that you can identify the rules when added to the firewall at a later date.

Follow the on screen information, it will advise you which rules it is creating.
 That's it.
 

Saturday, October 25, 2014

Aliases in cmd.exe (Unix like)

You can use doskey to get aliases in cmd.exe.

Put this in alias.bat. 

doskey moff=nircmd monitor off
doskey pch=shutdown/h
doskey pcs=shutdown/f

cls


Modify a cmd.exe short cut to point to %windir%\system32\cmd.exe /k D:\alias.bat


Thursday, October 16, 2014

Launch My Computer instead of Libraries from taskbar


explorer.exe /e,::{20D04FE0-3AEA-1069-A2D8-08002B30309D}

The File explorer icon pinned to Windows taskbar launches the Libraries by default. This annoys me since I haven't set up any libraries and have to do one or two clicks in the sidebar to reach where I want to go every time.

This is how to get it back.

Right click on the icon -> Properties.

In the target field put the above code. It should now directly launch My Computer.


Source : http://dsss.be/w/start

Sunday, March 24, 2013

Vim like cursor keys Autohotkey

if you want to use vim cursor keys for directional navigation like h j k l, you could use the following auto hotkey script shared by redditt user dirtywizard.

HJKL navigation while holding down space key Autohotkey script :

 

    #If GetKeyState("Space", "P")
    $h::
    Send {LEFT}
    sendSpace := false
    return
    $j::
    Send {DOWN}
    sendSpace := false
    return
    $k::
    Send {UP}
    sendSpace := false
    return
    $l::
    Send {RIGHT}
    sendSpace := false
    return
    #If
     
    $Space::
    sendSpace := true
    return
     
    $Space Up::
    if (sendSpace)
        SendInput {Space}
    return
‏

r/vim discussion