batch file - how to block social medias from windows -
i block social medias pc according time. block after 9 pm , unblock after 11 (like parental control) have tried following failed.
created block.bat
file
@echo off (get-content c:\windows\system32\drivers\etc\hosts) | foreach-object { $_ -replace "#127.0.0.1 facebook.com", "127.0.0.1 facebook.com" } | set-content c:\windows\system32\drivers\etc\hosts
created unblock.bat
file
@echo off (get-content c:\windows\system32\drivers\etc\hosts) | foreach-object { $_ -replace "127.0.0.1 facebook.com", "#127.0.0.1 facebook.com" } | set-content c:\windows\system32\drivers\etc\hosts
and added these 2 bat file task scheduler. block run @ 11 , unlock @ 9 pm.
i getting error powershell:
set-content : input object cannot bound because did not contain information required bind mandatory parameters: path @ line:1 char:140 + ... e "#127.0.0.1 facebook.com", "127.0.0.1 facebook.com" } | set-content + ~~~~~~~~~~~ + categoryinfo : invalidargument: (# copyright (c)...microsoft corp.:string) [set-content], parameterbindingexception + fullyqualifiederrorid : inputobjectmissingmandatory,microsoft.powershell.commands.setcontentcommand
and manually running bat file nothing.
give shot code :
@echo off cls & color 0a & echo. mode con cols=55 lines=5 set copyright=hackoo 2016 title block-unblock facebook %copyright% ::::::::::::::::::::::::::::::::::::::::: :: automatically check & admin rights ::::::::::::::::::::::::::::::::::::::::: cls echo. echo. echo ************************************** echo running admin shell echo ************************************** ::pause :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 ************************************** echo invoking uac privilege escalation echo ************************************** setlocal disabledelayedexpansion set "batchpath=%~0" setlocal enabledelayedexpansion ( echo set uac = createobject^("shell.application"^) echo args = "elev " echo each strarg in wscript.arguments echo args = args ^& strarg ^& " " echo next 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 :::::::::::::::::::::::::::: setlocal enabledelayedexpansion set copyright=hackoo 2016 title block-unblock facebook %copyright% rem if didn't want create shortcut , see intro on desktop comment line below if not exist %userprofile%\desktop\block-unblock_facebook.lnk goto:intro ::*********************************************************************************************** :checkpassword mode con cols=55 lines=3 cls & color 0a & echo. set mypassword=hackoo set "pscommand=powershell -command "$pword = read-host 'enter password' -assecurestring ; ^ $bstr=[system.runtime.interopservices.marshal]::securestringtobstr($pword); ^ [system.runtime.interopservices.marshal]::ptrtostringauto($bstr)"" /f "usebackq delims=" %%p in (`%pscommand%`) set password=%%p if %mypassword%==%password% (goto:good) else (goto:bad) exit/b ::*********************************************************************************************** :good cls & color 0a echo( echo password timeout /t 1 /nobreak>nul goto:menuloop ::*********************************************************************************************** :bad cls & color 0c echo( echo bad password timeout /t 1 /nobreak>nul goto:checkpassword ::*********************************************************************************************** :menuloop mode con cols=85 lines=8 cls & color 0b title block , unblock facebook %copyright% echo( echo( ================================menu================================ echo( /f "tokens=2* delims=_ " %%a in ('"findstr /b /c:":menu_" "%~f0""') echo %%a %%b echo( echo( ==================================================================== set choice= echo( & set /p choice=make choice or hit enter quit: || goto :eof echo( & call :menu_[%choice%] goto:menuloop ::******************************************************************************************** :menu_[1] blocking facebook mode con cols=85 lines=8 cls & color 0c call:skipline 3 call:tab 6 echo %x% "deactivate write protection" ... timeout /t 2 /nobreak>nul set hostspath=%windir%\system32\drivers\etc\hosts set backuphosts=%appdata%\hosts.hackoo if not exist %backuphosts% attrib -r %hostspath% && type %hostspath% > %backuphosts% cls attrib -r %hostspath% ( echo ########################### echo # block facebook %copyright%# echo ########################### echo 127.0.0.1 www.facebook.com echo 127.0.0.1 facebook.com echo 127.0.0.1 ok.facebook.com echo 127.0.0.1 www.ok.facebook.com echo 127.0.0.1 a.ok.facebook.com echo 127.0.0.1 www.a.ok.facebook.com echo 127.0.0.1 facebook.com.au echo 127.0.0.1 www.facebook.com.au echo 127.0.0.1 nl-nl.facebook.com echo 127.0.0.1 www.nl-nl.facebook.com echo 127.0.0.1 facebook.nl echo 127.0.0.1 www.facebook.nl echo 127.0.0.1 login.facebook.com.au echo 127.0.0.1 www.login.facebook.com.au echo 127.0.0.1 www-10-01-snc2.facebook.com echo 127.0.0.1 www-11-01-snc2.facebook.com echo 127.0.0.1 www-10-03-ash1.facebook.com echo 127.0.0.1 www-12-08-ash1.facebook.com echo 127.0.0.1 www-13-08-ash1.facebook.com echo 127.0.0.1 static.ak.fbcdn.net echo 127.0.0.1 www.static.ak.fbcdn.net echo 127.0.0.1 login.facebook.com echo 127.0.0.1 www.login.facebook.com echo 127.0.0.1 login.facebook.com.nl echo 127.0.0.1 www.login.facebook.com.nl echo 127.0.0.1 fbcdn.net echo 127.0.0.1 www.fbcdn.net echo 127.0.0.1 fbcdn.com echo 127.0.0.1 www.fbcdn.com echo 127.0.0.1 ads.ak.facebook.com echo 127.0.0.1 www.ads.ak.facebook.com echo 127.0.0.1 static.ak.connect.facebook.com echo 127.0.0.1 www.static.ak.connect.facebook.com echo 127.0.0.1 login.facebook.com echo 127.0.0.1 www.login.facebook.com ) > %hostspath% cls call:skipline 3 call:tab 5 echo %x% "facebook blocked %copyright%" attrib +r %hostspath% timeout /t 2 /nobreak>nul start www.facebook.com ::goto :menuloop exit ::******************************************************************************************** :menu_[2] unblocking facebook cls & color 0a title unblocking facebook .... call:skipline 3 call:tab 5 set hostspath=%windir%\system32\drivers\etc\hosts set backuphosts=%appdata%\hosts.hackoo if exist %backuphosts% attrib -r %hostspath% && type %backuphosts% > %hostspath% attrib +r %hostspath% echo %x% "facebook unblocked %copyright%" timeout /t 2 /nobreak>nul start www.facebook.com exit ::goto :menuloop ::****************************************************************************************** :play ( echo play "%~1" echo sub play(url^) echo dim sound echo set sound = createobject("wmplayer.ocx"^) echo sound.url = url echo sound.settings.volume = 100 echo sound.controls.play echo while sound.currentmedia.duration = 0 echo wscript.sleep 100 echo loop echo wscript.sleep (int(sound.currentmedia.duration^)+1^)*1000 echo end sub )>%~2 ::******************************************************************************************** :skipline /l %%i in (1,1,%1) echo( goto:eof ::******************************************************************************************** :tab set "x=" /l %%i in (1,1,%1) set "x=!x! " rem ^-- tab goto :eof ::******************************************************************************************** :intro color 0a & mode con cols=101 lines=57 echo( echo ` `` ` ` ` `` `` echo ``` ` ````````` ` ` echo ` .-/+osyhhhhhhhhhhhhyyso+:-` ` ` echo ````/hddddddddddddddddddddddddddhy- `` ` echo `` :mdmdmdmmddddddddddddddddddddddy` echo ` onmmmmddddddddddddddddddddddmmmd. ` echo ` ynmnnnmmmmmmmmmmmmmmmmmmmmmmmmmm: echo ` .dnmnmnnmmnmmmmmmmmmmmmmmmmmmmmmn+ `` echo ` :nmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmny ` `` echo ` onmmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmm. ` echo ` hnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmn: ` ` echo `` ` .mnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmn+ `` `` ` echo ` ` `..-/++osynmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmnmny``` `` echo ` ` `.:+syhddddddmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmnmyoo/:-.`` echo ` ``-/shhddddddddddddmnnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmnmdddddddhyo+:-``` ``` echo ` `.+ydddddddddddddddddnnnnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmdddmddddmmddhyo:.`` echo ``+dddddddddddddddddmmmnnnnmmmmmmmmdddddmddddddddmmdmmmmmmnmdmdddddddddddddddy/` echo ` `ydddddddddddddddddddmnnnnnmmmmmdddddddddddddddddddddmmmnnnmdddddddddddddddddddd/`` echo omdmdddddddddddddddddmnnnmmmmmmmmddddddddddddddddddddmmnnnmmdmddddddddddddddddddd. ` echo ` omddddddddddddmddddmmdmmmmmmnmmmmmddddddddddddddddmmmmmnmmmdddddddddddddddddddddy` ` ` echo `ymdddddddddddddddddmddddmmmmmmmmmdddddddddddddddddmmmdmddddddddddddddddddddddds. `` echo ` `+dmdddddmmdmmmmddmmmdddddmmmddddddddddddddddddddddddddddddddddmmddmddddddmh+.` ` ` echo `` ``/shmdmddmmmmmmmddddmmmmmmmmmmdddddddddddddddddddddddddddddmmddmdddddhy+-` ` ` ` echo ` ` ```-/oyhdddmmmmmmmmmmmmmmmmmmdddddddddddddmddddmmmdmmddddddddddhyo/-` ` ` ` ` echo ` ` ` ` ` ``-/+sydddddddddmddmmdmdddmdddddmmmdmmmdddddddhhhhhho/-.` ` echo ``` ` :mnmnnnnnmdhhhhhhhddddddddhdhhhhhhhyyhmmnnnmmd. ` echo ` :mnnnnnmnnnhsooo+++++oyyo+oo++/://++++snnnnnnmh/ `` echo ``` :dnnnnnnmnnndyssoo++/+oyy++o++////+oooohnnnnnnmd/ ` ` ` echo `:dnnnnnnmnnnnmyyssooo+osyy++ooo++++oosssdnnnnnnmdo ` ` echo ``./hnnnnnnnnnnnmndsyhhoooyoys+/+o+++++yhssymnnnnnnmdy. echo ` `` .oymnnnnmnnnmnnnnmhosdmdysohho+hs+++sddossmnnnnnnnmdmo```` echo ` ` -/smnnnnnnnnnnnnnmndosyydmmmdoodnmmddssosmmnmnnnnnmmdds:.` echo ` ` ` .+dmnnnmnnnnnnnnnnmndosyssssoo+osoooososmmmnmnnnnmnmmddds:.`` echo ` ``` `` ` ``.-/odnnnnnnmnmnnnnnnmmmmmmssyooooyys++++oohnmmmnmnnnnmnmmmmnnnmdho-` ` echo ` `` `.-/+syhdmnnnnmmnnnnnnnnnnnnmnmnnmnnhso++smms//+oodnnmmnmnmmnnmnnmnmnnnnnnnmhs/.` ` ` echo ` ` .+ydmnnnnnnnnnmnmmnnnnnnnnnnnnnnmmmnmmnmy+/hmdh:++ynnnmmmnnnmmmmmnnmnnnnnnnnnnnnmmhs:.` ` echo ```/dmnnnnnnnmnnnmmmmmmnmnnnnnnnnmnnmmmmmnmnnh+omno/sdmnmnnmmnnnmmmmmmnnnnnnnnnnnnnnnnmnmds:`` ` echo ``.smmmnnnnnnnnnnnnnnnnmnmnnnmnnmnmnnmnmmmnnnnnndnmdmnnnnnnmmnnnnnnmmmmnnnnnnnnnnnnnnnnnnnmmmh/` ` echo ``/dmmnmnnnnnnnnnnnnnnnnnnmmnnnnmmnnnmmmmmmmmmmmnmnnmnmnnnnnnnnnnnnnmmmmnnnnnnnnnnnnnnnnnmmnmmmms. ` echo nmmmmnnnmmmmnnnnnnnnnnnmmmnnnnnmnnnnnnnnnnnnnmnnmnnnnnnnnnnnnnnnnnmmmmnnnnnnnnnnnnnnnmmmmnmmmmmh-` echo mmmmnmnmmmmmmmnnnnnnnnmmmmmmmmnnnmnnnnnnnnnnnnnnnmnnnnnnnnnnnnnnmnnnmmmnnnnnnnnnnnnnnnnnmmmmmmmmmmd: echo mnnmmmmmmmmmmnnnnnmmmmmmnmnmmmmnnmnnnnnnnnnnnnnnnmnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnmmmmmmmmmmmmmmm echo nmmmmmmmmmmmnnnnnnnnmmnnnmnnnmmnnnnnnnnnnnnnnnnnnmnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnmmmmmmmmmmmmm echo( echo "/ | / | / | "; echo "$$ | $$ | ______ _______ $$ | __ ______ ______ "; echo "$$ |__$$ | / \ / |$$ | / | / \ / \ "; echo "$$ $$ | $$$$$$ |/$$$$$$$/ $$ |_/$$/ /$$$$$$ |/$$$$$$ |"; echo "$$$$$$$$ | / $$ |$$ | $$ $$< $$ | $$ |$$ | $$ |"; echo "$$ | $$ |/$$$$$$$ |$$ \_____ $$$$$$ \ $$ \__$$ |$$ \__$$ |"; echo "$$ | $$ |$$ $$ |$$ |$$ | $$ |$$ $$/ $$ $$/ "; echo "$$/ $$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$/ $$$$$$/ "; echo " "; echo " "; set vbsfile=%temp%\intro.vbs set url=http://hackoo.alwaysdata.net/intro.mp3 call:play %url% %vbsfile% start %vbsfile% timeout /t 18 /nobreak>nul ::******************************************************************** set myfile=%~f0 set shorcutname=block-unblock_facebook ( echo call shortcut("%myfile%","%shorcutname%"^) echo ^'**********************************************************************************************^) echo sub shortcut(cheminapplication,nom^) echo dim objshell,desktoppath,objshortcut,mytab echo set objshell = createobject("wscript.shell"^) echo mytab = split(cheminapplication,"\"^) echo if nom = "" echo nom = mytab(ubound(mytab^)^) echo end if echo desktoppath = objshell.specialfolders("desktop"^) echo set objshortcut = objshell.createshortcut(desktoppath ^& "\" ^& nom ^& ".lnk"^) echo objshortcut.targetpath = dblquote(cheminapplication^) echo objshortcut.iconlocation = "winver.exe,0" echo objshortcut.save echo end sub echo ^'********************************************************************************************** echo ^'fonction pour ajouter les doubles quotes dans une variable echo function dblquote(str^) echo dblquote = chr(34^) ^& str ^& chr(34^) echo end function echo ^'********************************************************************************************** ) > %temp%\shortcutme.vbs start /wait %temp%\shortcutme.vbs del %temp%\shortcutme.vbs goto:checkpassword ::**************************************************************************************************** :eof exit
Comments
Post a Comment