hjf

Monday, December 28, 2015

Web search query from command line (Windows and Linux)

Web search query from command line (Windows and Linux)



If you are like me and you do as much as you can on a computer by command line then there may have been a time in your life that you wanted to do your web searches straight from the command line (cmd/terminals etc...). Also, if you are like me, then you like to use as few 3rd party apps as possible and scripts only if possible.

In Linux there are text based browsers for command line and in Windows you can use Telnet or Links, but like I said, I like scripts (or exe/bin conversions of) and for years I have made sloppy variations of search engine scripts for both OS's. Recently I have perfected and cleaned up those scripts for general use for the public.

Each script has comments/remarks explaining each section and the Windows bat/cmd script has been made easy to use in batch to exe conversions and still work normally if not. Both scripts (Windows/Linux) use the same simple syntax by passing your query directly to the file; which, the files can be named whatever you want. For example if I wanted to use the script as a google search tool and named the script google.cmd(or bat) or google.sh (no extension necessary if shell is stated in file) then I would use any of these syntaxes to search your query:
Windows:

google my search terms
google.cmd my search terms
google.bat my search terms
Linux:
google my search terms
google.sh my search terms
sh google.sh my search terms
Of course you can name your file to whatever you want. If no search terms are provided it just opens the search engines web page.

Script Codes:
For each script you can change 3 variables:

  • Search Engine Url - all the way to right before the search string. E.g. https://www.google.com/#q=

  • Web Browser - your preference, Chrome, Firefox, IE, Opera etc... E.g. C:\Program Files\Google\chrome.exe

  • Spaces delimeter - urls don't work well with spaces so most spaces are replaced by %20, +, or similar.

Windows batch or cmd. Can be converted to an exe with a bat2exe program. Comments/Remarks denoted by 'REM'. For batch files with goto :EOF to work properly remember to leave an empty line at the end of the script file:
@echo off
setlocal EnableDelayedExpansion
REM Command line search utility;
REM can be used for any search engine.
REM by Lateralus138 aka Ian Pride

REM Variables; change as needed for any url search engine;
REM surl = Main search url;
REM bexe = Browser executable; The name or direct link to 
REM ...... the web browser you want to use;
REM spac = Space delimeter expansion/replacer. Most
REM ...... search engines use %20 (%%20 for this script),
REM ...... but some use the + sign;
set "surl=https://www.google.com/#q="
set "bexe=chrome.exe"
set "spac=+"


REM Check if parameters are passed; if not, open regular site;
REM If parameters are passed then continue with processing
REM search terms below;
if "%~1"=="" (
 echo Parameter/s not given.
 start "Starting Search Engine..." "%bexe%" "%surl%"
 goto :EOF
)

REM Process search query terms if given and open in a browser;
REM Variables; Do not change;
REM qry_prms = search terms passed to this script;
REM clr_file = Calling file. Processed out in variable expansion
REM .......... for use in bat2exe programs;
set "qry_prms=%*"
set "clr_file=%0 "
REM Delayed expansion to manipulate search query string for
REM use in your web browser;


REM Replace calling file for bat2exe type programs;
REM qry_strng = Extract calling file from the
REM ........... query parameters;
set "qry_strng=!qry_prms:%clr_file%=!"

REM Replace spaces with delimeter;
set qry_fnl=!qry_strng: =%spac%!

REM Process search query; open browser and searches;
start "Searching For Given Query..." "%bexe%" "%surl%!qry_fnl!"

Linux script or bin. It was, of course, easier to write this than the Windows one. Comments/Remarks denoted by '#':
#!/bin/bash
# Command line search utility;
# can be used for any search engine.
# by Lateralus138 aka Ian Pride

# Variables; change to suit your needs:

# Whatever internet browser you want to use
brwsr_clnt="google-chrome"

# Main search url all the way up to right 
# before the search string.
srch_url="http://kat.cr/usearch/"

# Replacement character for space character in
# the browsers search string url. Most use %20
# but some use the + character or similar.
brwsr_dlmtr="%20"

# Variables; End.

# Main script;

# Test if search string is given, if not, open
# the normal search site without a query in the
# browser of your choice. Exits script.
if [ -z "$*" ]; then
 "$brwsr_clnt" "$srch_url" &
 exit
fi

# If search string given then process string
# and then opens the query in the browser
# of your choice.
qry_strng="$*"
"$brwsr_clnt" "$srch_url${qry_strng// /$brwsr_dlmtr}"

# Main script; End.
Please feel free to comment to or message me with any questions.

Wednesday, November 11, 2015

Organize Downloads Folder In Linux (Or Mac)

Organize Downloads Folder In Linux
(Or Mac)



If any of you use Linux or Mac (even Windows, but I'm talking about *nix today) and download lots of stuff then you know how messy it can get really quick even if you try to stay organized.

I have written a shell script to organize your lose files in your home downloads folder fairly intuitively. It first checks for my preset directory tree to be built inside the downloads folder with sections: Archives, Audio, Video, Documents, Images and Installers with many preset sections inside each directory for the different file types. For example you would find .pdf files inside ...Documents/pdf... or .txt files in Documents/txt etc... If the directories are not found it creates them.

It then searches for a large list of preset file extensions in the main Downloads folder non-recursively and then checks the destination folder to see if the file already exists, if not it will then move the file to the destination. If the file is already there it will ask what you would like to do with the file: Replace, Delete or Do Nothing. This seems like a lot (I'm a good enough coder to turn 2600 lines of code into 200 :D ), but the folder checking literally takes less than 1 second (probably 500 ms) and the search for files takes less than a couple. Search is used with 'find' at -maxdepth 1 (for non-recursive).

This script is easily editable if you are familiar with *nix shells, directories and file types can be added accordingly. You can really pull my functions and and use in any type of folder organization.

This is open-source code; you may use in your home or business, but any use in any sell-able product is strictly prohibited unless I have given permission.

Script code below, header is for bash (#!/bin/bash), but I am sure this is POSIX friendly and doesn't need a head so strip the BASH header for non bash shells. If you do not already know how to use scripts then this script is probably not for you, but if you need help running and are willing to learn then please ask away; I'll help.

Script File if you prefer:
mvarchives: mvarchives script file @ Dropbox
Script Code:

#!/bin/bash
# Organizer for lose files in $HOME/Downloads

# Directory list
# Calling users download directory
dldir="$HOME/Downloads"

# Archive directories
arch="$dldir/Archives"
zip="$arch/zip"
gzd="$arch/gz"
tar="$arch/tar"
rar="$arch/rar"
bz2="$arch/bz2"
szdir="$arch/7z"

# Installer directories
instl="$dldir/Installers"
deb="$instl/deb"
rpm="$instl/rpm"

# Image directories
picf="$dldir/Images"
png="$picf/png"
jpg="$picf/jpg"
bmp="$picf/bmp"
tif="$picf/tif"
gif="$picf/gif"
ico="$picf/ico"
svg="$picf/svg"
jpeg="$picf/jpeg"

# Video directories
vidf="$dldir/Videos"
mov="$vidf/mov"
mp4="$vidf/mp4"
mpg="$vidf/mpg"
avi="$vidf/avi"
mkv="$vidf/mkv"
flv="$vidf/flv"
wmv="$vidf/wmv"
mpeg="$vidf/mpeg"
m4v="$vidf/mv4"
tgp="$vidf/3gp"

# Music directories
musf="$dldir/Audio"
mp3="$musf/mp3"
ogg="$musf/ogg"
flac="$musf/flac"

# Document directories
docf="$dldir/Documents"
txt="$docf/txt"
doc="$docf/doc"
bak="$docf/bak"
cfg="$docf/cfg"
css="$docf/css"
html="$docf/html"
php="$docf/php"
js="$docf/js"
asp="$docf/asp"
docx="$doc"
htm="$html"
ini="$docf/ini"
jso="$js"
log="$docf/log"
odf="$docf/odf"
ppt="$docf/ppt"
rtf="$docf/rtf"
xml="$docf/xml"
pdf="$docf/pdf"

# Main file moving function
mv_files () {
 fnamevar="$1"
 for archives in $(sudo find $dldir -maxdepth 1 -type f -iname "$fnamevar"); do
  fname=$(basename "$archives")
  if [ ! -f "$2/$fname" ]; then
   sudo mv "$archives" "$2"
   if [ ! -f "$2/$fname" ]; then
    echo "File: $fname was not moved to $2, something went wrong."
    echo ""
   else
    echo "File $fname was successfully moved to $2."
    echo ""
   fi
  else
   echo "File $fname was found in the target directory, file was not copied." 
   echo "What would you like to do with the file $archives? "
   PS3="Make a choice: "
   options=("Replace" "Delete" "Do Nothing")
   select opt in "${options[@]}"
   do
    case $opt in
     "Replace")
      sudo mv -f "$archives" "$2"
      if [ ! -f "$archives" ]; then
       echo "File: $fname in $dldir replaced file $fname in $2 successfully."
       echo ""
      else
       echo "File: $fname in $2 was not replaced, something went wrong."
       echo""
      fi
      break
      ;;
     "Delete")
      sudo rm -f "$archives"
      if [ ! -f "$archives" ]; then
       echo "File $archives deleted successfully."
       echo ""
      else
       echo "File $archives could not be deleted, something went wrong."
       echo ""
      fi
      break
      ;;      
     "Do Nothing")
       echo "You chose do nothing with file $archives, file remains."
       echo ""
      break
      ;;
     *) echo invalid option;;
    esac
   done   
  fi
 done
}

# Directory check and creation
dirn="$docf $txt $doc $bak $cfg $css $html $php $js $asp $docx $htm $ini $jso $log $odf $ppt $rtf $xml $pdf $arch $zip $gzd $tar $rar $bz2 $szdir $instl $deb $rpm $picf $png $jpg $jpeg $bmp $tif $gif $ico $svg $vidf $mov $mp4 $mpg $avi $mkv $flv $wmv $mpeg $m4v $tgp $musf $mp3 $ogg $flac"
read -r -a dirna <<< "$dirn"
for typed in ${dirna[@]}; do
 if [ ! -d "$typed" ]; then
  mkdir "$typed"
  if [ -d "$typed" ]; then
   echo "Folder $typed created successfully."
  else
   echo "Folder $typed was not created, something went wrong."
  fi
 fi
done

# File movement
IFS=$(echo -en "\n\b") 
mv_files "*.zip" "$zip"
mv_files "*.tar" "$tar"
mv_files "*.bz2" "$bz2"
mv_files "*.rar" "$rar"
mv_files "*.rpm" "$rpm"
mv_files "*.7z" "$szdir"
mv_files "*.deb" "$deb"
mv_files "*.gz" "$gzd"
mv_files "*.png" "$png"
mv_files "*.jpg" "$jpg"
mv_files "*.bmp" "$bmp"
mv_files "*.tif" "$tif"
mv_files "*.gif" "$gif"
mv_files "*.ico" "$ico"
mv_files "*.svg" "$svg"
mv_files "*.jpeg" "$jpeg"
mv_files "*.mov" "$mov"
mv_files "*.mp4" "$mp4"
mv_files "*.mpg" "$mpg"
mv_files "*.avi" "$avi"
mv_files "*.mkv" "$mkv"
mv_files "*.flv" "$flv"
mv_files "*.wmv" "$wmv"
mv_files "*.mpeg" "$mpeg"
mv_files "*.m4v" "$m4v"
mv_files "*.3gp" "$tgp"
mv_files "*.mp3" "$mp3"
mv_files "*.ogg" "$ogg"
mv_files "*.flac" "$flac"
mv_files "*.pdf" "$pdf"
mv_files "*.txt" "$txt"
mv_files "*.doc" "$doc"
mv_files "*.bak" "$bak"
mv_files "*.cfg" "$cfg"
mv_files "*.css" "$css"
mv_files "*.html" "$html"
mv_files "*.php" "$php"
mv_files "*.js" "$js"
mv_files "*.asp" "$asp"
mv_files "*.docx" "$doc"
mv_files "*.htm" "$html"
mv_files "*.ini" "$ini"
mv_files "*.jso" "$js"
mv_files "*.log" "$log"
mv_files "*.odf" "$odf"
mv_files "*.ppt" "$ppt"
mv_files "*.rtf" "$rtf"
mv_files "*.xml" "$xml"

Thursday, July 9, 2015

Titan Empires 5.1-6.0 upgrade "Game content can't be found" error fix.

Titan Empires 5.1-6.0 upgrade "Game content can't be found" error fix.



Recently, Titan Empires had a semi-major update from version 5.1 to 6.0 and many people are receiving an error "Game content can't be found" or something very similar to that. This update wasn't normal because instead of replacing the old app like usual it had you install a whole new apk file and had 2 installations on the device.

Ok, whatever, not a big deal as you can just uninstall the old version and it still seem to run fine on my 10.5 inch Tab S. When I tried installing on any other device (both rooted and not) I received the aforementioned error. After a few hours (off and on) of uninstalling/reinstalling everything and cleaning all leftover traces nothing seemed to work. I then had an idea to try reinstalling the old version again and repeating the update process and it worked! I then repeated these steps on two more devices that had the error and they worked as well! I then uninstalled the old 5.1 version and 6.0 still works on all devices!

Steps to fix error:

  • Completely uninstall any traces of Titan Empires (if rooted you can look for left overs with something like SD Maid etc.).
  • Install the 5.1 version found here: Titan Empires V5.1.
  • Run V5.1 and it will tell you to update and take you to the Play Store. Install V6.0.
  • Run V6.0 to test and make sure it's working.
  • Uninstall V5.1 from your app manager or an uninstaller. Just make sure you are uninstalling V5.1

Hope this helps!

Sunday, March 1, 2015

WgetURL V1.0

WgetURL V1.0



Off and on throughout the years I have had, heard and seen many conversations with people about posting images (anything really) online and how secure they really are. By now we should all know they are not and even if a website has security in place if a hacker wants your files bad enough they can get them. Having said that most hackers aren't really wanting any pics of your trip to the local fair or your puckered selfies... so really in the end it''s not that big of a deal. If you're posting naked pics and people get them that's more than likely your fault for making them public as I doubt a real hacker wasted his time to get your amateur porn.

In one of these conversations I had with a person I did mention Wget as a way to download files from a web server from a command line interface, without having to use any browser or download manager you can download many files from a server as long as it doesn't have restrictions (as many do, BUT NOT ALL). This method is for legitimate users like web designers/hosts or just someone interested in the way a site is coded to download these files.

Of course, I love to write scripts for everything and so began my little quest to create WgetURL V1.0, a small utility to easily download all obtainable files from a web server with a simple command such as:

wgeturl www.websiteurl.com

instead of having to type a bunch of code like this:

wget --no-clobber --convert-links --random-wait -r -P %userprofile%\Desktop robots=off www.websiteurl.com --cut-dirs=1 --cut-dirs=2 --cut-dirs=3

Usage:

  • Note: I ended up creating this as an installer package with an uninstaller because it has several files and a PATH variable so I wanted a clean uninstall.
  • Note: Not for use in XP. It can be installed and the cli utility part can be used manually, but it will not function properly as is. XP is far outdated and I will not code for it at this time.
  • Note: As with most of my utilities this may show as a false positive in Anti-virus or warnings. It's is not signed and may show packed warnings because wget is packaged with this.

Installation:

The installer is very simple, it will install all files to C:\Bin\WgetURL using my WinBin system and give you the option to not create a Start Menu folder, but I don't recommend that.

Execution:

Can only be ran from a command line interface (cli) such as CMD by typing

wgeturl www.whatever-website-address-you-want.com

It will run from anywhere as the path is added to the PATH variable.

Uninstall:

Very clean uninstall either by a shortcut in the Start Menu, uninstaller found in the programs directory or by any normal means in your Uninstall Programs list.



Download



WgetURLV1.0-Setup for Windows Vista/7/8


Saturday, February 21, 2015

Windows Login Backdoor Creator V2.0

Note: This is a revision of the original post 'Creating backdoor at Windows login to reset password after losing it.' found here.

Over the years I have had many people ask me how to get into their computer after they have forgotten their password. There are a few ways to do this either with a bootable cd or usb stick with a 3rd party application, but to be honest this is very unsafe as anyone can get the cd and break into a computer and at the same time you or anyone else that uses such software can cause users or admins to lose data.

The only really safe way to do it is through your command prompt, but without knowing your password to get into the profile to use the console then you are screwed. Recently I have discovered a way to be able to access your command prompt from the Windows login screen by adding a value to the registry. Now you can create a registry file (.reg) to do this, but today we will just add it via the command prompt:


1. You must open your cmd (command prompt) as administrator so you can't open it from run. You must go to your start screen type "cmd" in the search bar and when you see it right click on it and select "Run as administrator".

2. Type the code below into the prompt:
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\windows\system32\cmd.exe"
Triple click on the above code to select all then copy and paste into your command prompt and hit "ENTER".

You now have access to the the command prompt at the Wcndows login screen.

Gain access by either:

  • Pressing SHIFT+ALT+PRTSC (Print Screen) or;
  • Hitting the SHIFT key 5 times in a row (good ol' Sticky Keys).



If you or anyone else on your Windows OS ever loses their password (or you just want to do anything else that you can do from the prompt) you can do it without logging in (be careful though!).

3. When you need to change your password from the prompt, type:
net user username password
Where username is, of course, your username and password your new password.

EXAMPLE:
net user bob apples
Would change user bob's password to apples etc...

If your name has a space in it you must wrap quotation marks around the name as a space denotes a new command. You must enter it like:

net user "bob for" apples


4. Login with your new password!



Downloads:

New version 2.0 is 90% re-written with 32 and 64 bit versions to accommodate x86 issues.

    Version Info
  • V1.0 - Original, batch script only. Bugs: Batch quote issue in paths, installs to wrong path on x86 systems with SysWOW. Bug fixes: none.
  • V2.0 - New re-write, 32 and 64 bit executables. Bugs: No known bugs. Bug fixes: Fixed batch quotes in paths issue, fixed install wrong locations issue.
      Features
    • Checks for registry value and script file and either installs the backdoor or fixes any part that may be broken.
    • Now runs great on Windows XP/Vista/7/8 32 and 64 bit.
I have created a batch file to automate this process so you don't have to do half of this. You can either download it here (Outdated V1.0 old script for archives) or if you are scared of downloading files you can just copy and paste the text below into a batch you create.

  • Right click on your desktop and select New>TXT File.
  • Rename the file from "New Text Document.txt" to "whateveryouwant.bat" (if you can't see the extension just go into folder options and uncheck "Hide extensions of known applications" or something like that.
  • Once it's a bat file right click on it and select "Edit". and paste the code below into it and save the file
  • Right click on the bat file you have created and select "Run as administrator" and it will run.
Code to paste in your batch file:
@echo off
Title Windows Login Backdoor Creator
color 0A
set "_bscript=%windir%/System32/backdoor.cmd"
cls
mode 54,4
echo(
echo Checking to see if script or registry value exist...
echo(
call :to
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger>nul
cls

if [%errorlevel%]==[1] if not exist "%_bscript%" (
call :notFound
cls
call :howTo
call :md
goto :eof
)

if [%errorlevel%]==[0] if not exist "%_bscript%" (
mode 49,5
echo(
echo Registry value exists, but the script does not.
echo Writing script file now...
echo(
call :to
call :writeScript
cls
call :howTo
call :md
goto :eof
)

if [%errorlevel%]==[1] if exist "%_bscript%" (
mode 49,5
echo(
echo Script exists, but the registry value does not.
echo Writing registry value now...
echo(
call :to
call :writeReg
cls
call :howTo
call :md
goto :eof
)
mode 48,5
echo(
echo Both the script and registry value were found,
echo no need to do anything.
echo(
pause
call :md
goto :eof

:notFound
mode 45,5
echo(
echo Backdoor was not found, writing both the
echo regsitry value and the script file....
echo(
call :to
call :writeBoth
cls
exit /b

:writeBoth
call :writeReg
call :writeScript
exit /b

:writeReg
echo(
echo Creating registry key....
echo(
call :to
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /v Debugger /t REG_SZ /d "C:\windows\system32\cmd.exe"
exit /b

:writeScript
mode 55,4
echo(
echo Creating script^: %_bscript%...
echo(
call :to
if exist "%_bscript%" del "%_bscript%"
echo Creating backdoor.cmd file...
echo @echo off > %_bscript%
echo title Creat New User Password >> %_bscript%
echo echo Enter username to reset your password: >> %_bscript%
echo set name= >> %_bscript%
echo set pass= >> %_bscript%
echo set /P name="Username:" >> %_bscript%
echo set /P pass="New Password:" >> %_bscript%
echo net user "%%name%%" "%%pass%%" >> %_bscript%
echo timeout /t 3 ^>NUL >> %_bscript%
echo exit >> %_bscript%
exit /b

:howTo
mode 36, 10
echo To run:
echo(
echo At the login screen either press
echo shift+ctrl+printscreen (or prtsc)
echo or hit shift 5 times. This will
echo bring up the command prompt. At
echo the prompt type "backdoor" into
echo the new password screen and follow
echo the instructions.
echo(
pause
cls
exit /b

:to
timeout /t 3 >nul
exit /b

:md
color 0F
mode 80,25
exit /b

New icon I made for it:

 photo green-backdoor_zps376b76e9.png

Once it starts it will enter the registry entries as provided above to create the access to the command prompt at Windows login and it will also create a batch file located in you System32 fold called "backdoor.bat" which will start you through an automated easy process to change your password, so no need to type the commands yourself just run the backdoor file. This batch files is run from your command prompt by typing "backdoor" or "backdoor.bat" and it

  • Run this batch file from the command prompt bay typing "backdoor" or "backdoor.bat" and hit "Enter".
  • It will easily guide you through the process of changing your password in just a couple of steps
Again, login and enjoy!!!

Tuesday, February 17, 2015

WinBin V1.0

WinBin V1.0

No matter what OS you use, if you use any console or command line interface then you know that if your script or executable isn't in a path the computer can read or if the cli is not in the direct path of the said file then it can not be run/found.

In most Linux systems there is a user bin system usually located in $HOME/bin where you can drop any of your user installed programs or scripts and they can be run form the terminal just like any system command.

In Windows it's not so simple (although, not so hard either) as any path read by Windows must be declared in the PATH(%PATH%) variable.

The problem with Windows is that the preset paths are all in system folders and there can be some permission and security issues with some utilities you may use. So it is best to just stay away from system folders when possible. The way to do this is by adding a custom directory designated for the user and adding the directories location to the PATH variable.

For example I create a directory: C:\Bin and then enter this location into the variable from cmd this: setx /m PATH "%PATH%;C:\Bin". And now I can drop whatever scripts or executable into the C:\Bin folder and run them from anywhere on the computer from cmd or any other cli.

Automate

I do this on every Windows rig I have and so I have created a quick bat to exe script to automate this process with slight error checking. WinBin V1.0 when started will check for a Bin folder and if exist warns the user that the old folder should be moved or deleted to complete the process. If no folder is found it continues to add the new directory and adds the location to the PATH variable. It then checks to makes sure the two functions were executed successfully and if so you can then use the system, if not you either have two many characters in your PATH variable (usually mostly from installed software) or the folder wasn't created successfully.

Usage

After the system is installed successfully then just drop anything at all that can be run from a cli into the C:\Bin folder and run from the cli!!! Very simple and quick and portable!

Download:

Icon I created

 photo WinBin_zpsae822e61.png

Tuesday, February 10, 2015

Collector V1.1

Collector (V1.1 - Updated)

Like most people I am constantly downloading files and installing software to my computer and because, like most people, I am busy all the time I don't have as much time as I would like to keep my system clean and so I like to write scripts to automate as much as I can to give me more free time away from my computer.

Over the years after cleaning, optimizing and fixing countless computers I have learned that most files that eat up disk space that can comfortably be removed are usually media and installation files; things you download from the internet pretty much. Lots of archived files like zips, rars etc... can end up taking up lots of space and even the most organized of us end up having files spread throughout our system and half the time we forget about them.

Recently I wrote a script (Collector V1.1) to copy all files of specific passed extension types to a folder on the desktop so that I can easily analyze the total file size of all said files. Doing this I also found files I forgot I even had and files I knew could be deleted I found the source files and deleted. I have converted my script to exe for easy portability and an administrative manifest.

Collector V1.1 is a command line utility (cli/clu) used by passing file extensions to it via a command line such as MS-DOS CMD.
E.g.:
collect.exe pdf txt log
will search your whole computer for all files with those extensions and then copy them to individual folders inside of a folder on your desktop named "Collection". There is no limit to the amount of passed extensions as it shifts each to %1 until [%1]==[].


Note: As with all bat to exe conversions this might come up as a false positive in your AV, just exclude in your AV. The collect.exe file must be placed in a folder that can be read from %PATH% such as C:\Windows\System32 or if you've added your own custom paths. You can also just cd to the path of your stored collect.exe.

Version Info:

  • Version 1.0 - Initial release. No known bugs.
  • Version 1.1 - Add log file with locations of original files.

Download:

Original Code:


@echo off
set "backd=%cd%"
title Collect Files
cls

:loop
mode 78,4
if [%1]==[] (
call :err
if exist "%mainf%" start "" explorer "%mainf%"
goto :eof
)

set "efile=%1"
set "mainf=%userprofile%\Desktop\Collection\"
set "wdir=%mainf%%efile%\"

cd C:\
echo(
echo Copying all "%efile%" files to %wdir%
echo(
for /r %%i in (*.%efile%) do (xcopy "%%i" "%wdir%" /q /y) >nul 2>nul
cls
cd %backd%
shift
goto :loop

:err
color FC
mode 38,4
cls
echo(
echo No more files to process...
echo(
pause
cls
color 0F
mode 80,25
title %backd%
exit /b

collector

Friday, February 6, 2015

Reboot for Windows - Linux Alternative

Windows Reboot V1.0

A lot of us who use both Windows and Linux find Windows cli commands lacking at times. Linux is best ran by the command (terminal) line in my opinion and almost everything you can do on a computer in Linux can and should be done via the terminal. One of the most annoying things I have found in Windows is the horrible way you have to reboot your computer from Windows CMD. In Linux it's as simple as typing 'reboot'.


In Windows in order to reboot your computer from a command line you must type 'shutdown /r /t 0' to reboot your computer. While this comes in handy for some things it is annoying for normal every day usage. I have created a batch to exe (for portability and easy use with administrative priveledges) script to emulate this feature in Windows. Simply place the reboot.exe in your C:\Windows\System32\ or any path in Windows %PATH% variable and run from command line with 'reboot'.


The difference between Linuxs 'reboot' and my Windows version is that an amount of time to wait before reboot can be passed to it as you would any passed parameter:
reboot 30
will wait 30 seconds before the reboot.


This is available in 3 versions; the original cmd script, reboot with admin manifest and a reboot without admin manifest (rename to reboot) for use on public computers:

Orignal script:

@echo off

if [%1]==[] (
call :restart
) else (
set rt=%1
call :passed
)

goto :eof

:passed
shutdown /r /t %rt%
exit /b

:restart
shutdown /r /t 0
exit /b