Skip to content

Instantly share code, notes, and snippets.

@atErik
Last active August 29, 2015 14:10
Show Gist options
  • Save atErik/ac3920f8a2d144c9120a to your computer and use it in GitHub Desktop.
Save atErik/ac3920f8a2d144c9120a to your computer and use it in GitHub Desktop.
Windows Batch Script, For Portable HexChat With Portable Perl Support
@echo off
@rem | | | | | | | |
@rem A windows batch/cmd script to run HexChat from USB/Portable drive, with
@rem portable perl support. HexChat is IRC Client/communication software.
@rem This script also allows to run a second HexChat in same computer,
@rem without conflicting with system/default/full installed/other HexChat.
@rem HexChat is based on XChat software.
@rem |
@rem When installing HexChat, you must select "Portable" option, if you want
@rem to run HexChat from a USB drive or from your own choice of sub-folder,
@rem and if you want it to not conflict with existing 1st/main/other HexChat.
@rem When installing also select "Interface" > "Perl" option, if you
@rem want Perl support for running your xchat compatible perl scripts.
@rem |
@rem Copy & paste these codes into a file, name the file HexChat-USB.cmd
@rem You must place the file next to hexchat.exe file, inside same folder,
@rem for example, in E:\HexChat\
@rem |
@rem If HexChat includes perl interface interpreter for VERSION 5.20, then
@rem download strawberry PORTABLE ZIP file VERSION 5.20
@rem |
@rem If "HexChat" is in this E:\ location (E:\HexChat\), then create
@rem a "Perl" folder next to it, means, create a "Perl" folder in same
@rem prefix location, in E:\ So in end, "Perl" will be in E:\Perl\
@rem |
@rem Decompress strawberry portable perl zip file inside E:\Perl\
@rem You may use 7zip, or Windows OS default zip extraction.
@rem So in end, perl.exe file will have to be here E:\Perl\perl\bin\
@rem |
@rem Double click on HexChat-USB.cmd file, to start HexChat, from USB
@rem or portable/second location.
@rem |
@rem If this script, is (supposedly) used to start a portable HexChat,
@rem always from same sub-folder location, then, select HexChat-USB.cmd
@rem file, press Ctrl+C (Copy), then right click on an empty area
@rem of Desktop (or inside StartMenu), and select the "Paste shortcut"
@rem option. Then use (or double-click on) that shortcut/link to start
@rem portable HexChat.
@rem If portable HexChat is here C:\PortableFiles\HexChat\ then portable
@rem perl should be next to it, here C:\PortableFiles\Perl\
@rem And perl.exe have to be here C:\PortableFiles\Perl\perl\bin\
@rem |
@rem Get latest version of this script from below webpage location:
@rem https://gist.github.com/atErik/ac3920f8a2d144c9120a#file-HexChat-USB-cmd
@rem On that page, right-click on "Raw" button, and select "Save link as"
@rem option, browse into & select portable HexChat folder location, and
@rem click on "Ok"/"Save" button. Web-browser may add .txt file-extension
@rem at end of filename, right-click on the file and select "Rename",
@rem then remove that .txt portion from end. Filename must end with .cmd
@rem Make backup of previous file if exists, before overwriting.
@rem |
@rem To view all file's file-extension portion : open "Windows Explorer"
@rem (by pressing the Windows-Flag button & E button, together), then
@rem you must goto "Folder Options" window : Go into Win-Explorer's main
@rem menu bar in top-side > click "View" menu > click on right-most side
@rem "Options" ribbon button > click "Change folder and search options"
@rem row > "Folder Options" window will appear, click on "View" tab > in
@rem list of options, find & UNSELECT this specific option line:
@rem "Hide extensions for known file types" > click on "Ok".
@rem |
@rem Search for "Notepad2" software, (or get Notepad++), download and
@rem install. Its very very helpful for editing and fixing/altering
@rem various formats.
@rem Open HexChat-USB.cmd file inside Notepad2. Not inside Notepad.
@rem Goto main menu bar & click on "File" menu > goto "Line Endings" in
@rem Notepad2, select the "CR+LF (Windows)" option, press Ctrl+S to
@rem save, now file will work & run in Windows OS platform.
@rem |
@rem No copyright. For anyone to use anywhere. by tErik/atErik/Erik.
@rem |
@rem First developed: 2014-11-26 14:27 UTC-08:00.
@rem Last modification: 2014-11-28 07:20 UTC-08:00.
@rem | | | | | | | |
setlocal
@rem echo %~dp0
@rem E:\HexChat\
set STARTPTH=%~dp0
set PERLPATH=%STARTPTH%..\Perl\;%STARTPTH%..\Perl\perl\;%STARTPTH%..\Perl\perl\bin\
set PATH=%STARTPTH%;%PERLPATH%;%PATH%
@rem Display environment variable's value/content:
@echo STARTPTH=%STARTPTH%
@echo .
@echo PERLPATH=%PERLPATH%
@echo .
@echo PATH=%PATH%
@echo .
@echo .
IF EXIST %STARTPTH%..\Perl\perl\bin\perl.exe GOTO perlFnd
:perlNfnd
@rem | | | | | | | |
@echo ERROR: perl.exe file NOT FOUND, (inside the "Perl" directory/folder
@echo structure for portable use, which suppose to be placed next to "HexChat"
@echo folder/directory). See "notes" inside HexChat-USB.cmd file.
@echo .
IF NOT EXIST %STARTPTH%hexchat.exe GOTO HxcNfnd
@rem | | | | | | | |
@echo HexChat is now Executed to run, (without Portable Perl support,
@echo and HexChat will try to use host system's Perl, if exists & specified
@echo in host system's PATH environment variable, and if that perl version
@echo is compatible with perl interface interpreter included with HexChat).
GOTO StartHxc
:perlFnd
@rem | | | | | | | |
IF NOT EXIST %STARTPTH%hexchat.exe GOTO HxcNfnd
@echo HexChat is now Executed to run, (with custom/portable Perl support).
:StartHxc
@rem | | | | | | | |
@echo .
@echo After HexChat starts up,
@rem @echo When HexChat is closed, then, (or after HexChat starts up),
@echo this window will AUTO CLOSE AFTER 20 SECONDS.
@echo .
@rem Syntax: START "title" [/D path] [options] "command" [parameters]
@START "HexChat (Portable)" /D%STARTPTH% "hexchat.exe"
@rem Syntax: CMD [charset] [options] [/K Command]
@rem For test:
@rem %WINDIR%\system32\cmd.exe /K ""%%STARTPTH%%\hexchat.exe""
@rem For functional:
@rem %WINDIR%\system32\cmd.exe /C ""%%STARTPTH%%\hexchat.exe""
GOTO endScript
:HxcNfnd
@rem | | | | | | | |
@echo ERROR: hexchat.exe program file is NOT FOUND inside below folder!
@echo %STARTPTH%
@echo .
@echo This window will AUTO CLOSE AFTER 20 SECONDS.
@echo .
:endScript
timeout 20
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment