diff --git a/DateAndTime/DateParts.bat b/DateAndTime/DateParts.bat deleted file mode 100644 index 7709d32..0000000 --- a/DateAndTime/DateParts.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -rem gets Date Parts -rem by Vasil "npocmaka" Arnaudov -rem 21.01.15 - improvement was proposed by Ildar Shaimordanov - a.k.a siberia-man -rem - to use empty folder to increase performance -for /f "skip=10 tokens=2,3,4,5,6,7,8 delims=: " %%D in (' - robocopy /l * "%windir%\System32\wbem\MOF\bad" "%windir%\System32\wbem\MOF\bad" /ns /nc /ndl /nfl /np /njh /XF * /XD * -') do ( - set "dow=%%D" - set "month=%%E" - set "day=%%F" - set "HH=%%G" - set "MM=%%H" - set "SS=%%I" - set "year=%%J" -) - -echo Day of the week: %dow% -echo Day of the month : %day% -echo Month : %month% -echo hour : %HH% -echo minutes : %MM% -echo seconds : %SS% -echo year : %year% diff --git a/DateAndTime/W32DOW.bat b/DateAndTime/W32DOW.bat deleted file mode 100644 index 20498b2..0000000 --- a/DateAndTime/W32DOW.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal -rem :: prints the day of the week -rem :: works on Vista and above -rem :: by Vasil "npocmaka" Arnaudov - - rem :: getting ansi date ( days passed from 1st jan 1601 ) , timer server hour and current hour - FOR /F "skip=16 tokens=4,5 delims=:( " %%D in ('w32tm /stripchart /computer:localhost /samples:1 /period:1 /dataonly /packetinfo') do ( - set "ANSI_DATE=%%D" - set "TIMESERVER_HOURS=%%E" - goto :end_for ) - :end_for - set "LOCAL_HOURS=%TIME:~0,2%" - if "%TIMESERVER_HOURS:~0,1%0" EQU "00" set TIMESERVER_HOURS=%TIMESERVER_HOURS:~1,1% - if "%LOCAL_HOURS:~0,1%0" EQU "00" set LOCAL_HOURS=%LOCAL_HOURS:~1,1% - set /a OFFSET=TIMESERVER_HOURS-LOCAL_HOURS - - rem :: day of the week will be the modulus of 7 of local ansi date +1 - rem :: we need need +1 because Monday will be calculated as 0 - rem :: 1st jan 1601 was Monday - - rem :: if abs(offset)>12 we are in different days with the time server - - IF %OFFSET%0 GTR 120 set /a DOW=(ANSI_DATE+1)%%7+1 - IF %OFFSET%0 LSS -120 set /a DOW=(ANSI_DATE-1)%%7+1 - IF %OFFSET%0 LEQ 120 IF %OFFSET%0 GEQ -120 set /a DOW=ANSI_DATE%%7+1 - - - echo Day of the week: %DOW% - exit /b 2147483648 -endlocal diff --git a/DateAndTime/W32tmSleep.bat b/DateAndTime/W32tmSleep.bat deleted file mode 100644 index 2933d57..0000000 --- a/DateAndTime/W32tmSleep.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -:: yet another sleep emulator working on everything from NT and above -if "%~1"=="" goto :help -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL || goto :help -IF %~1 LSS 0 goto :help - -setLocal - set /a adj=%~1/2+1 - w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:%adj% >nul 2>&1 -endLocal - -goto :eof -:help -echo. -echo %~n0 -echo Sleep emulator -echo Wait for a specified number of seconds. -echo. -echo Usage: CALL %~n0 seconds -echo. -echo seconds - seconds to wait -echo. -echo. -echo by Vasil "npocmaka" Arnaudov diff --git a/DateAndTime/getTime.bat b/DateAndTime/getTime.bat deleted file mode 100644 index ee91982..0000000 --- a/DateAndTime/getTime.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -:: gets time using typePerf command -:: with put some effort to be made fast and maximum compatible - -setlocal -::check if windows is XP and use XP valid counter for UDP performance -if defined USERDOMAIN_roamingprofile (set "v=v4") else (set "v=") -set "mon=" -for /f "skip=2 delims=," %%# in ('typeperf "\UDP%v%\*" -si 0 -sc 1') do ( - if not defined mon ( - for /f "tokens=1-7 delims=.:/ " %%a in (%%#) do ( - set mon=%%a - set date=%%b - set year=%%c - set hour=%%d - set minute=%%e - set sec=%%f - set ms=%%g - ) - ) -) -echo %year%.%mon%.%date% -echo %hour%:%minute%:%sec%.%ms% -endlocal diff --git a/DateAndTime/sleeptp.bat b/DateAndTime/sleeptp.bat deleted file mode 100644 index 6a2405e..0000000 --- a/DateAndTime/sleeptp.bat +++ /dev/null @@ -1,18 +0,0 @@ -@echo off -:: yet another sleep emulator working on everything from NT and above -if "%~1"=="" goto :help -ECHO.%*| FINDSTR /R /X /C:"[0-9][0-9]*" >NUL 2>NUL || goto :help -IF %~1 LSS 0 goto :help - -typeperf "\System\Processor Queue Length" -si %~1 -sc 1 >nul - -goto :eof -:help -echo. -echo %~n0 -echo Sleep emulator -echo Wait for a specified number of seconds. -echo. -echo Usage: CALL %~n0 seconds -echo. -echo seconds - seconds to wait diff --git a/Java/getJavaVersion.bat b/Java/getJavaVersion.bat deleted file mode 100644 index ba37c6e..0000000 --- a/Java/getJavaVersion.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rem : ------------------------------ -rem : -rem : sets java version as a number to jver -rem : variable in one line. -rem : by Vasil "npocmaka" Arnaudov -rem : -rem : ------------------------------ - -for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k%%l%%m" - -rem : ------------------------------ -rem : for execution directly to the command prompt use the line bellow -rem : for /f tokens^=2-5^ delims^=.-_^" %j in ('java -fullversion 2^>^&1') do @set "jver=%j%k%l%m" -rem : ------------------------------ diff --git a/Java/javaDetect.bat b/Java/javaDetect.bat deleted file mode 100644 index 8c916d9..0000000 --- a/Java/javaDetect.bat +++ /dev/null @@ -1,48 +0,0 @@ -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -@ECHO OFF -set __COMPAT_LAYER=RunAsInvoker -:: Export java settings from registry to a temporary file -START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft" - - -if not exist "%Temp%\java.reg" ( - START /W REGEDIT /E %Temp%\java.reg "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft" -) - - - -if not exist "%Temp%\java.reg" ( - echo java not installed - exit /b 1 -) - - - -:: Find java location -FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%\java.reg ^| FIND "INSTALLDIR"') DO SET JAVA_HOME=%%B -SET JAVA_HOME=%JAVA_HOME:"=% -SET JAVA_HOME=%JAVA_HOME:\\=\% -SET JAVA_HOME - -:: Get java version -::FOR /F "tokens=1* delims==" %%A IN ('TYPE %Temp%\java.reg ^| FIND "CurrentVersion"') DO SET JAVA_VERSION=%%B -::SET JAVA_VERSION=%JAVA_VERSION:"=% -::SET JAVA_VERSION -::SET JAVA_VERSION=%JAVA_VERSION:.=% -::SET JAVA_VERSION=%JAVA_VERSION:_=% -::SET /A JAVA_VERSION=%JAVA_VERSION% - -for /f tokens^=2-5^ delims^=.-_^" %%j in ('%JAVA_HOME%\bin\java.exe -fullversion 2^>^&1') do set "JAVA_VERSION=%%j%%k%%l%%m" - -:: Delete temp file -rem @DEL %Temp%\java.reg /S /Q > NUL 2>&1 -set JAVA_VERSION -:: Check java version compatibility -IF %JAVA_VERSION% LSS 16020 ( -ECHO. -ECHO YOU NEED AT LEAST JAVA WITH VERSION 1.6.0_20 -- this is just an example echo. -GOTO :EOF -) - -PAUSE -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: diff --git a/Java/javaExtInstaller.bat b/Java/javaExtInstaller.bat deleted file mode 100644 index aa85959..0000000 --- a/Java/javaExtInstaller.bat +++ /dev/null @@ -1,19 +0,0 @@ - @echo off - :: requires Admin permissions - :: allows a files with .JAVA (in this case ) extension to act like .bat/.cmd files. - :: Will create a 'caller.bat' asociated with the extension - :: which will create a temp .bat file on each call (you can consider this as cheating) - :: and will call it. - :: Have on mind that the %0 argument will be lost. - - - rem :: "installing" a caller. - if not exist "c:\javaCaller.bat" ( - echo @echo off - echo copy "%%~nx1" "%%temp%%\%%~nx1.bat" /Y ^>nul - echo "%%temp%%\%%~nx1.bat" %%* - ) > c:\javaCaller.bat - - rem :: associating file extension - assoc .java=javafile - ftype javafile=c:\javaCaller "%%1" %%* diff --git a/Java/javaHybrid.bat b/Java/javaHybrid.bat deleted file mode 100644 index 39a93d1..0000000 --- a/Java/javaHybrid.bat +++ /dev/null @@ -1,46 +0,0 @@ -@Deprecated /* >nul 2>&1 - -:: self compiled java/.bat hybrid -:: -:: deprecated is the only one annotation that can be used outside the class definition -:: and is needed for 'mute' start of multi-line java comment -:: that will be not printed by the batch file. -:: though it still creates two files - the .class and the .java -:: it still allows you to embed both batch and java code into one file - -@echo off -setlocal -java -version >nul 2>&1 || ( - echo java not found - exit /b 1 -) - -::find class name -::can be different than the script name -for /f "usebackq tokens=3 delims=} " %%c in (`type %~f0 ^|find /i "public class"^|findstr /v "for /f"`) do ( - set "javaFile=%%c" - goto :skip -) -:skip - -copy "%~f0" "%javaFile%.java" >nul 2>&1 - -javac "%javaFile%.java" -java "%javaFile%" - -::optional -::del %javaFile%.* >nul 2>&1 -endlocal -exit /b 0 - -*******/ - - - -public class TestClass -{ - public static void main(String args[]) - { - System.out.println("selfcompiled .bat/.java hybrid"); - } -} diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7bdba4d..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Vasil Arnaudov - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/ProcessesUtils/StartPID.bat b/ProcessesUtils/StartPID.bat deleted file mode 100644 index 66e2155..0000000 --- a/ProcessesUtils/StartPID.bat +++ /dev/null @@ -1,155 +0,0 @@ -@echo off -setlocal - - -for %%# in ( "" "/h" "-h" "/help" "-help") do ( - if /i "%~1" equ "%%~#" goto :echoHelp -) - - -set /A shifter=1 -set "workdir=." - - -:argParser - if /i "%~1" EQU "-exec" ( - set "exec=%~2" - ) - if /i "%~1" EQU "-commandline" ( - set "commandline=%~2" - ) - if /i "%~1" EQU "-workdir" ( - set "workdir=%~2" - ) - if /i "%~1" EQU "-host" ( - set "host=%~2" - ) - if /i "%~1" EQU "-user" ( - set "user=%~2" - ) - if /i "%~1" EQU "-pass" ( - set "pass=%~2" - ) - if /i "%~1" EQU "-record" ( - set "record=%~2" - ) - - if /i "%~1" EQU "-debug" ( - set "debug=%~2" - ) - - shift - shift - set /A shifter=%shifter% + 1 - - if %shifter% EQU 8 ( - goto :endArgParser - ) - -goto :argParser -:endArgParser - -if "%exec%" EQU "" ( - echo executable not defined - goto :eof -) - -if "%host%" NEQ "" ( - set "host_param=/NODE:%host%" - if "%user%" NEQ "" ( - set "user_param=/USER:%user%" - if "%pass%" NEQ "" ( - set "pass_param=/PASSWORD:%pass%" - ) - ) -) - -if "%record%" NEQ "" ( - set "record_param=/RECORD:%record%" -) - -set "global_params=%record_param% %host_param% %user_param% %pass_param%" - -set "ProcessId=" -set "ReturnValue=" - -if defined debug ( - echo executing: - echo wmic %global_params% process call create "%exec% %commandline%"^,"%workdir%" -) - -for /f " skip=5 eol=} tokens=* delims=" %%a in ('wmic %global_params% process call create "%exec% %commandline%"^,"%workdir%"') do ( - - for /f "tokens=1,3 delims=; " %%c in ("%%a") do ( - set "%%c=%%d" - ) -) - - -::successfull -if defined ProcessId ( - endlocal && ( - echo %ProcessId% - exit /B %ProcessId% - ) -) - -::unsuccessful with code -::check the return code and give hints - - -if defined ReturnValue ( - echo error code : %ReturnValue% - - if "%ReturnValue%" EQU "2" ( - echo -Access Denied - ) - - if "%ReturnValue%" EQU "3" ( - echo -Insufficient Privilege - ) - - if "%ReturnValue%" EQU "8" ( - echo -Unknown failure - echo Hint: Check if the executable and workdir exists or if command line parameters are correct. - ) - - if "%ReturnValue%" EQU "9" ( - echo -Path Not Found - echo Hint: check if the workdir or executable exist. - ) - - if "%ReturnValue%" EQU "21" ( - echo -Invalid Parameter - echo Hint: Check executable path.Check if host and user are corect. - ) - - endlocal && ( - exit /b 0 - ) -) - - - -::unsuccessful with no code -echo execution of the following line has failed: -echo wmic %global_params% process call create "%exec% %commandline%","%workdir%" -echo( -echo HINT :brackets,quotes or commas in the password or the command line could break the script -goto :eof - -endlocal -goto :eof - - -:echoHelp - echo starts process on the local or a remote machine and returns it's PID to the ERRORLEVEL - echo %~n0 -exec executubale [-commandline command_line] [ -workdir working_directory] [-host remote_host [-user user [-pass password]]] [-record path_to_xml_output] [-debug debug] - echo\ - echo localhost cant' be used as in -host variable - echo Examples: - echo %~n0 -exec "notepad" -workdir "c:/" -record "test.xml" -commandline "/A startpid.txt" - echo %~n0 -exec "cmd" -workdir "c:/" -record "test.xml" -host remoteHost -user User - echo\ - -goto :eof diff --git a/ProcessesUtils/startHidden.bat b/ProcessesUtils/startHidden.bat deleted file mode 100644 index 6f951d5..0000000 --- a/ProcessesUtils/startHidden.bat +++ /dev/null @@ -1,106 +0,0 @@ -@echo off -:: Starts a hidden process and tries and gets its PID on -:: a machines with OS higher than Vista -:: requires Admin permissions - -:: it uses SCHTASKS with a task 'on demand' -:: PID is get from the event logs with WEVTUTIL command - -:: todo - start the process on a remote machine -:: todo - start the process with a different user -:: todo - start the process in different mode - -setlocal -:: check for elevated permissions -fltmc 1>nul 2>&1 || ( - echo you need an admin permissions - exit /b 5 -) -if "%1" EQU "" ( - echo %~nx0 path_to_executable [arguments] - exit /b 1 -) - -if "%1" EQU "-help" ( - echo %~nx0 path_to_executable [arguments] - exit /b 0 -) - -set "arguments=" -if "%2" NEQ "" ( - set "arguments=%2" -) - -::escape quotes if there are any -if defined arguments ( - set "arguments=%arguments:"=\"%" -) - - -set "executable=%~s1" -set "inpath=%~dp$PATH:1" - -:: check if executable exists.Both with its value and within %PATH% variable -if not exist "%executable%" ( - if "%inpath%" equ "" ( - echo path to executable item does not exist - exit /B 2 - ) else ( - for %%f in ("%~dp$PATH:1%~1") do set "executable='%%~sf'" - ) -) - -:: getting the current time -:: if the machine has SCHTASKS it has also WMIC -FOR /F "skip=1 tokens=1-3" %%A IN ('WMIC Path Win32_LocalTime Get Hour^,Minute^,Second /Format:value') DO ( - for /f "delims=" %%# in ("%%A") do if "%%#" NEQ "" set "%%A" -) - -set time_stamp=%Hour%%Minute%%Second% - - -if "%time_stamp%" equ "" ( - echo "some kind of error" - exit /B 2 -) - -::enable task log in case it is dissabled in order to get the PID -wevtutil sl "Microsoft-Windows-TaskScheduler/Operational" /e:true >null 2>&1 - -:: A trick that will create a task on demand but will log a warning -SCHTASKS /Create /sc ONCE /sd 01/01/1910 /st 00:00 /TN created_%time_stamp% /TR "%executable% %arguments%" /RU SYSTEM /F /RL HIGHEST 1>nul 2>&1 || ( - echo Error while creating the task - exit /b 3 -) -::w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:2 >nul 2>&1 -SCHTASKS /Run /TN created_%time_stamp% 1>nul 2>&1 || ( - echo Error while starting the task - exit /b 4 -) -SCHTASKS /Delete /TN created_%time_stamp% /f 1>nul 2>&1 || ( - echo Error deleting the task -) -:: Attempt to acquire the PID of the started process trough task scheduler event logs -:: not possible for WinXP/2003 but there task scheduler logs are located elsewhere -:: so this check will stop execution for older machines - -if exist "%__APPDIR__%winevt\Logs\" ( - setlocal enableDelayedExpansion - - rem sleep for 2 seconds to give a time for event logging - w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:2 >nul 2>&1 - rem WEVTUTIL should be available from Vista and above - - for /f "usebackq tokens=13 delims==" %%# in ( - `"wevtutil qe Microsoft-Windows-TaskScheduler/Operational /q:*[System/EventID=129]/EventData[@Name='CreatedTaskProcess']/Data[@Name='TaskName']='\created_!time_stamp!'"` - ) do ( - for /f "tokens=2 delims=><" %%$ in ("%%#") do ( - echo Started: "%executable% %arguments%" - echo PID: %%$ - ) - ) - - endlocal -) - -endlocal diff --git a/README.md b/README.md deleted file mode 100644 index 92c23df..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -batch.scripts -============= diff --git a/dataStructures/binaryTree.bat b/dataStructures/binaryTree.bat deleted file mode 100644 index 351a563..0000000 --- a/dataStructures/binaryTree.bat +++ /dev/null @@ -1,110 +0,0 @@ -@echo off -setlocal enableDelayedExpansion - -:: Binary tree implementation with pure batch -:: only insert and find methods are implmented so far -:: -:: it uses the binary tree name as the variable that holds -:: the root element and adds revursively to namer right elements -:: and namel the left elements. - -:::--- some tests ----- -call ::insert test_tree6 1 -call ::insert test_tree6 5 -call ::insert test_tree6 8 -call ::insert test_tree6 9999 - -color -echo searching for value 8 -call ::find test_tree6 8 -echo %errorlevel% - if 0 element is found -echo searching for value 123 -call ::find test_tree6 123 -echo %errorlevel% - if 1 element is not found -set test_tree6 -:::::::::::::::::::::::::::::: - -exit /b 0 - - -:find three_name value -setlocal enableDelayedExpansion -set /a value=%~2 -set node=%1 - -if %value% equ !%1! ( - endlocal & ( - echo %1 - exit /b 0 - ) -) - - -if %value% GTR !%1! ( - if defined %1r ( - endlocal & ( - call ::find %1r %value% - ) - ) else ( - endlocal & exit /b 1 - ) -) - -if %value% LSS !%1! ( - if defined %1l ( - endlocal & ( - call ::find %1l %value% - ) - ) else ( - endlocal & exit /b 1 - ) -) - - -exit /b - - - -:insert three_name value -setlocal -::set "three_name=%~1" -set /a value=%~2 - -if not defined %~1 ( - endlocal & ( - set "%~1=%value%" - exit /b 0 - ) -) - -if %value% GEQ %~1r ( - if not defined %~1r ( - endlocal & ( - set %~1r=%value% - exit /b 0 - ) - ) else ( - endlocal & ( - call ::insert %~1r %value% - rem exit /b 0 - ) - ) -) - -if %value% LSS %~1l ( - if not defined %~1l ( - endlocal & ( - set %~1l=%value% - exit /b 0 - ) - ) else ( - endlocal & ( - call ::insert %~1r %value% - rem exit /b 0 - ) - ) -) - -exit /b 0 - -:delete diff --git a/discovers_and_bugs/bugs/EOFbreaker.bat b/discovers_and_bugs/bugs/EOFbreaker.bat deleted file mode 100644 index e84fab9..0000000 --- a/discovers_and_bugs/bugs/EOFbreaker.bat +++ /dev/null @@ -1,9 +0,0 @@ -:: http://ss64.org/viewtopic.php?id=1554 -:: redirecting to/from escaped EOF crashes the command prompt -:: as explained in dbenham in the above link -:: this was also featured here -:: http://stackoverflow.com/questions/23284131/cmd-exe-parsing-bug-leads-to-other-exploits - -@echo off -rem do not set new lines at the end or you'll break the breaker -echo combobreaker |( goto :eof >^ diff --git a/discovers_and_bugs/bugs/FORbreaker.bat b/discovers_and_bugs/bugs/FORbreaker.bat deleted file mode 100644 index 339937e..0000000 --- a/discovers_and_bugs/bugs/FORbreaker.bat +++ /dev/null @@ -1,6 +0,0 @@ -::http://ss64.org/viewtopic.php?id=1554 - -@echo on -:: this prints for %%A in ((nul)) do echo %%A -:: before command prompt crash -break | for %%A in () do echo %%A diff --git a/discovers_and_bugs/bugs/ParamExpansionAndDriveVars b/discovers_and_bugs/bugs/ParamExpansionAndDriveVars deleted file mode 100644 index 7d13f60..0000000 --- a/discovers_and_bugs/bugs/ParamExpansionAndDriveVars +++ /dev/null @@ -1,23 +0,0 @@ -C:\>for %I in (a: b: c: ">:" "&:") do @echo %~fI -C:\>pushd c: -C:\>set " - -the output is: - -=&:=&:\ - -=>:=>:\ - -=A:=A:\ - -=B:=B:\ - -=C:=C:\ - -.... - - - -Will not work if there's path attached to the mimic drives in the for set or if the "push ." (cd . also can be used) is skipped. -Looks like the parameter expansion splits the paths in two parts - drive and the rest of the path and later concattanes them. -And used drives are stored somewhere - and if there's no path part they are not deleted. CD and PUSHD resets drive variables. diff --git a/discovers_and_bugs/bugs/callCrasher.bat b/discovers_and_bugs/bugs/callCrasher.bat deleted file mode 100644 index 0feb041..0000000 --- a/discovers_and_bugs/bugs/callCrasher.bat +++ /dev/null @@ -1,2 +0,0 @@ -:: Do not set any symbols after the closing bracket -(call :: & :: ) diff --git a/discovers_and_bugs/bugs/callForCallIf.txt b/discovers_and_bugs/bugs/callForCallIf.txt deleted file mode 100644 index 4dfeb9d..0000000 --- a/discovers_and_bugs/bugs/callForCallIf.txt +++ /dev/null @@ -1,32 +0,0 @@ -:: http://stackoverflow.com/questions/19445153/why-i-cant-call-if-and-for-neither-in-batch-nor-in-the-cmd - -:: Call command cannot execute IF and FOR commands , despite syntax errors are detected -:: Examples bellow (should be executed in command prompt but not from batch file) - - -C:\Windows\system32>call @if a==a echo called -',' is not recognized as an internal or external command, -operable program or batch file. - -C:\Windows\system32>call (@if a==a echo called) -';' is not recognized as an internal or external command, -operable program or batch file. - -C:\Windows\system32>call if a==a echo called -'if' is not recognized as an internal or external command, -operable program or batch file. - -C:\Windows\system32>call for %a in (1) do @echo called -'for' is not recognized as an internal or external command, -operable program or batch file. - -C:\Windows\system32>call @for %a in (1) do @echo called -'+' is not recognized as an internal or external command, -operable program or batch file. - -C:\Windows\system32>call (@for %a in (1) do @echo called) -';' is not recognized as an internal or external command, -operable program or batch file. - - - diff --git a/discovers_and_bugs/bugs/callbrackets.bat b/discovers_and_bugs/bugs/callbrackets.bat deleted file mode 100644 index 791e28d..0000000 --- a/discovers_and_bugs/bugs/callbrackets.bat +++ /dev/null @@ -1,34 +0,0 @@ -::http://stackoverflow.com/questions/24418084/why-call-command-cannot-execute-a-command-enclosed-with-brackets -:: -:: Call command is unable to execute expression enclosed in brackets -:: Examples bellow -:: -:: - -@echo off - -:: the echo that will never be -call(echo echo echo) - -:: its the same with non-cmd internal commands -call ( notepad.exe ) - -:: and even with a code that should fail -call(gibberish) - -:: moreover the execution is successful -call (gibberish)&&echo %errorlevel% - -:: though there's some parsing done -call(this will print call help because contains "/?"-/?) - -:: and will detect a wrong syntax of some parsed-before-execution commands -call ( if a==) - -:: and this too -call (%~) - -:: same with labels -call(:label) -call(:no_label) -:label diff --git a/discovers_and_bugs/bugs/forCrasher.bat b/discovers_and_bugs/bugs/forCrasher.bat deleted file mode 100644 index d193875..0000000 --- a/discovers_and_bugs/bugs/forCrasher.bat +++ /dev/null @@ -1 +0,0 @@ -set "h=/?" && call if %%h%% diff --git a/discovers_and_bugs/bugs/forEmptyTokens b/discovers_and_bugs/bugs/forEmptyTokens deleted file mode 100644 index 3742262..0000000 --- a/discovers_and_bugs/bugs/forEmptyTokens +++ /dev/null @@ -1,18 +0,0 @@ -@@echo off -:::this prints - 1:[i] 2:[] 3:[] 4:[] 5:[] 6:[] 7:[] -for /f "tokens=1,1,1,1,1,1,1" %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) - -:::this prints - 1:[i] 2:[ii] 3:[iii] 4:[iv] 5:[] 6:[] 7:[%g] -for /f "tokens=2,3,1-4" %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) - -:::this prints - 1:[i] 2:[ii] 3:[iii] 4:[] 5:[] 6:[] 7:[%g] -for /f "tokens=1-3,1-3," %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) - -exit /b 0 -http://stackoverflow.com/questions/25950181/why-for-f-sets-empty-values-for-repeated-numbers-in-the-rest-of-tokens diff --git a/discovers_and_bugs/bugs/ifCrasher.bat b/discovers_and_bugs/bugs/ifCrasher.bat deleted file mode 100644 index d3b5cec..0000000 --- a/discovers_and_bugs/bugs/ifCrasher.bat +++ /dev/null @@ -1 +0,0 @@ -set "h=/?"&& call for %%h%% diff --git a/discovers_and_bugs/bugs/ifDefined.bat b/discovers_and_bugs/bugs/ifDefined.bat deleted file mode 100644 index d33d647..0000000 --- a/discovers_and_bugs/bugs/ifDefined.bat +++ /dev/null @@ -1,59 +0,0 @@ -:: Checking if variable that name contains spaces (or default delimiters - pointed by Liviu) -:: is not so easy -:: Escaping delimiters with ^ does not work and even its buggy -:: -:: To perform proper checking you need delayed expansion -:: or FOR /F wrapping (proposed by penpen) -:: -:: http://www.dostips.com/forum/viewtopic.php?f=3&t=6148 -:: -:: using delayed expansion - -:: some explantations here : http://stackoverflow.com/questions/28000194/why-if-checking-ignores-delimtersome-word-after-the-check-expression - -@echo off - -setlocal enableDelayedExpansion - -set sim salabim=magic -set sim=simulation - -set "checker=sim salabim" - -if defined !checker! echo # - -rem the commented lines produce errors -rem if defined sim salabim echo $ -rem if defined %checker% echo @ -rem if defined "sim salabim" echo * - - -endlocal - - -:: using FOR /F (penpen) - -@echo off -setlocal disableDelayedExpansion -set sim salabim=magic - -for %%a in ("sim salabim") do if defined %%~a echo --- -endlocal -goto :eof - - -:: If defined parser bug demonstration - -@echo off - -setlocal - - set "undefined1=" - set "undefined2=" - set "undefined3=" - - set "var1=1" - - if defined var1^ undefined1^ undefined2^ undefined3 echo ### - -endlocal diff --git a/discovers_and_bugs/bugs/pipeIf.bat b/discovers_and_bugs/bugs/pipeIf.bat deleted file mode 100644 index de36529..0000000 --- a/discovers_and_bugs/bugs/pipeIf.bat +++ /dev/null @@ -1,33 +0,0 @@ -:: http://www.dostips.com/forum/viewtopic.php?f=3&t=5539 -:: -:: when something is piped to IF command the spaces before first operand are eaten (check the link above) -:: While I've only found the problem - the root cause and the solution were found by jeb - - @echo off - rem prints 1 is geq than 1 - echo.|if defined 1 geq 1 echo 1 is geq than 1 - rem prints 2 is gtr than 100 - echo.|if defined 2 gtr 100 echo 2 is gtr than 100 - - rem prints 1 is gteater than 100 - echo.|if 1 gtr gtr 100 echo 1 is gteater than 100 - rem prints 100 is gteater and the same time less than 100 - echo.|if 100 lss gtr 100 echo 100 is gteater and the same time less than 100 - -:: the root cause is visible by executing the following line in command prompt (found by jeb): -::C:\>echo pipe | if defined X lss Y echo %^cmdcmdline% -:: In both cases - befora and after swalowing of the spaces syntax errors are detected (that's why the examples above works -:: - a second comparison operator is added) - - -:: the solution (proposed by jeb): - - -@echo off -set "myLine=if 1 lss 2 more" -echo pipe | ( %%myLine%%) - -:: If command dows now swallow the pipe and passed string can be used both in IF and ELSE commands. - - - diff --git a/discovers_and_bugs/bugs/remCrasher.bat b/discovers_and_bugs/bugs/remCrasher.bat deleted file mode 100644 index e26f345..0000000 --- a/discovers_and_bugs/bugs/remCrasher.bat +++ /dev/null @@ -1 +0,0 @@ -set "h=/?"&call rem %%h%% diff --git a/discovers_and_bugs/discovers/DPATH b/discovers_and_bugs/discovers/DPATH deleted file mode 100644 index 3974768..0000000 --- a/discovers_and_bugs/discovers/DPATH +++ /dev/null @@ -1,22 +0,0 @@ -@echo off -dpath /? -dpath -type cmd.exe -set /p=&1 >nul -if "%0" == ":%anonymous%" ( - echo Anonymous called - exit /b 0 -)>&3 - - -rem example with code block ecnlosed with brackets -echo Before anonymous call: -echo %%1=%1 %%2=%2 %%3=%3 - -for /l %%N in (1 1 5) do ( - set /a N=%%N*2 - call :%%anonymous%% a b c 3>&1 >nul - echo --- -) -if "%0" == ":%anonymous%" ( - echo( - echo Anonymous call: - echo %%1=%1 %%2=%2 %%3=%3 N=%N% - exit /b 0 -)>&3 - -echo( -echo After anonymous call: -echo %%1=%1 %%2=%2 %%3=%3 - - diff --git a/discovers_and_bugs/discovers/boolKeys.bat b/discovers_and_bugs/discovers/boolKeys.bat deleted file mode 100644 index d51ff6c..0000000 --- a/discovers_and_bugs/discovers/boolKeys.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -goto :endComment - Nothing useful , just observation over KEYS internal state and how it differs from ECHO. - KEYS changes its state even if it's called within brackets or in conditional execution statements and to child threads/processes spawned with pipes or FOR (unlike ECHO): - https://www.dostips.com/forum/viewtopic.php?t=6914#p45037 -:endComment -setlocal disableDelayedExpansion - -set "if_on=for /f "tokens=3" %%# in ('keys') do if %%#==on. " -set "if_off=for /f "tokens=3" %%# in ('keys') do if %%#==off. " - -rem :: echo state cannot be examined so easy -::for /f "tokens=3" %%# in ('echo') do echo %%# -::echo|for /f "tokens=3" %%# in ('more') do echo %%# -::echo|find "on." -( - - keys on - %if_on% echo Should be displayed - %if_off% echo Should be not - keys off - %if_off% echo Should be displayed - %if_on% echo Should be not - ( - keys on - ) - %if_on% echo Should be displayed - %if_off% echo Should be not - -) diff --git a/discovers_and_bugs/discovers/callArgs.bat b/discovers_and_bugs/discovers/callArgs.bat deleted file mode 100644 index d2e7cd7..0000000 --- a/discovers_and_bugs/discovers/callArgs.bat +++ /dev/null @@ -1,42 +0,0 @@ -:: using SHIFT and accessing arguments within same brackets context -:: might cause troubles -:: -:: following code with this arg. line ich ni san shi go roku -:: -:: @echo off -:: for /l %%c in (1=1=5) do ( -:: echo --%1-- -:: shift -:: ) -:: echo --%1-- -:: -:: gives following output -:: -:: --ich-- -:: --ni-- -:: --san-- -:: --shi-- -:: --go-- -:: --roku-- -:: -:: the only way to access arguments in this case is using CALL -:: http://ss64.org/viewtopic.php?id=1708 - -@echo off -for /l %%c in (1 ; 1 ; 5) do ( - call echo --%%1-- - shift -) -echo --%1-- - -:: -:: with delayed expansion -:: - -setlocal enableDelayedExpansion -set /a counter=0 -for /l %%x in (1 ; 1 ; 5) do ( - set /a counter=!counter!+1 - call echo %%!counter! -) -endlocal diff --git a/discovers_and_bugs/discovers/callcolons.bat b/discovers_and_bugs/discovers/callcolons.bat deleted file mode 100644 index de10ee3..0000000 --- a/discovers_and_bugs/discovers/callcolons.bat +++ /dev/null @@ -1,10 +0,0 @@ -:: calling lables can be used like -:: call ::label arguments - -@echo off - -call ::label -echo -after- -exit /b o -:label -echo printed diff --git a/discovers_and_bugs/discovers/certutil.txt b/discovers_and_bugs/discovers/certutil.txt deleted file mode 100644 index df21681..0000000 --- a/discovers_and_bugs/discovers/certutil.txt +++ /dev/null @@ -1,71 +0,0 @@ -http://ss64.org/viewtopic.php?id=1562 - -Certutil is available on my WIN 7 and Vista machines by default.I think it should be also available for XP but I'm not 100% sure. - -1. The thing I used this for wad to decode and encode BASE64 strings. (-decode and -encode command switches) .It has two annoying features here - for decode and encode it needs ------END CERTIFICATE----- and -----BEGIN CERTIFICATE----- at begining and at the of base64 file.And it prints decoded file in lines with max length of 64 symbols. -So here are two very very very simple scripts that use certutil to decode and encode base64 string (and dealing with begin and end tags) (there are no checks for file existence and if the parameters are correct - I rely on certutil error messages): -decode: -@echo off -setlocal -for /f "delims== tokens=1" %%A in ('type %1') do ( - set encoded=%%A -) -rem two additional lines are needed by certutil -echo -----BEGIN CERTIFICATE-----> %2.tmp -echo %encoded%>>%2.tmp -echo -----END CERTIFICATE----->> %2.tmp - - -certutil /decode %2.tmp %2 -del /S /Q %2.tmp -endlocal -encode: -@echo off -setlocal -certutil /encode %1 %1.encoded -rem create an empty file -break > %2 - -setlocal ENABLEDELAYEDEXPANSION -( - for /f "eol=-" %%A in (' type %1.encoded ') do ( - rem this not works - left an empty spaxes after each line from typed file - rem null< (set /p #=%%A) >>%1.encoded - - set result=!result!%%A - ) -) -endlocal & set result=%result% -echo %result%>> %2% -del /S /Q -endlocal - - -The bad thing is that the base64 strings are stored in a variable and there's a limitations for it's size.But for a small strings it wokrs. - - - - - -2. Much more interesting.In the help it shows that there's an -decodehex switch.And I was surprised to find that there's also an undocumentes switch -encodehex (strange - decodehex looks more dangerous , because it can be used to produce binaries). Here's an example structure of encoded file: -0000 73 65 74 20 78 3d 15 0d 0a 73 65 74 20 79 3d 12 set x=...set y=. -0010 0d 0a 65 63 68 6f 20 2a 2a 25 78 25 25 79 25 2a ..echo **%x%%y%* -0020 2a * - -(just as every hex editor) -This was my attempt to create file that set LF and CR to variables smile - and I still don't know why it was unsuccessful it prints "§↕" (any help here will be welcomed - I don't know what goes wrong). -EDIT: I've set DEC codes instead HEX .Anyway still not works. -In fact the data that is behind the hexes is not necessary - it's only for visualisation . -To decode the sample just use this (if this above is saved in sample.hex) : -certutil -decodehex sample.hex not.working.bat - -Any way it works for creation of the famous beep.bat : - -0000 65 63 68 6f 20 07 -this pattern can be used for creation of bat that echoes a random symbols by hex.Just edit the last character. -and this is a pattern for setting a symbol by hex to %#% variable (just edit the last character): -0000 73 65 74 20 78 3d 15 0d -Anyway there are few more things that I want to try with this smile - -here's a how forfiles can be used for hex symbols diff --git a/discovers_and_bugs/discovers/defaultJumpDir.bat b/discovers_and_bugs/discovers/defaultJumpDir.bat deleted file mode 100644 index ccb6485..0000000 --- a/discovers_and_bugs/discovers/defaultJumpDir.bat +++ /dev/null @@ -1,19 +0,0 @@ -:: For every drive there's dynamic environment variable -:: that points to the last accessed directory e.g. : -:: -:: =D:=D:\someFolder -:: -:: defining same variable in-advance will -:: allow direct jump to some directory by entering the drive -:: (if directory does not exist it will print it as a message) -:: This will not harm the command prompt. -:: If different folder is entered the value of the variable will be changed durring the -:: command prompt session. -:: -::http://ss64.org/viewtopic.php?id=1559 -:: - - -reg add HKCU\Environment /v "=D:" /d "Get out of here stalker" /f - -:: SETX won't allow defining variable starting with equal sign on every machine.So it's better to use REG diff --git a/discovers_and_bugs/discovers/emptyTokens.bat b/discovers_and_bugs/discovers/emptyTokens.bat deleted file mode 100644 index d1a55a8..0000000 --- a/discovers_and_bugs/discovers/emptyTokens.bat +++ /dev/null @@ -1,19 +0,0 @@ -:: http://stackoverflow.com/questions/25950181/why-for-f-sets-empty-values-for-repeated-numbers-in-the-rest-of-tokens - -:: For /f command set empty value for each requested token in options section -:: Examples bellow - -:::this prints - 1:[i] 2:[] 3:[] 4:[] 5:[] 6:[] 7:[] -for /f "tokens=1,1,1,1,1,1,1" %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) - -:::this prints - 1:[i] 2:[ii] 3:[iii] 4:[iv] 5:[] 6:[] 7:[%g] -for /f "tokens=2,3,1-4" %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) - -:::this prints - 1:[i] 2:[ii] 3:[iii] 4:[] 5:[] 6:[] 7:[%g] -for /f "tokens=1-3,1-3," %%a in ("i ii iii iv v vi vii") do ( - @echo 1:[%%a] 2:[%%b] 3:[%%c] 4:[%%d] 5:[%%e] 6:[%%f] 7:[%%g] -) diff --git a/discovers_and_bugs/discovers/fileRedirection.bat b/discovers_and_bugs/discovers/fileRedirection.bat deleted file mode 100644 index f77d940..0000000 --- a/discovers_and_bugs/discovers/fileRedirection.bat +++ /dev/null @@ -1,8 +0,0 @@ -::Only the last file in the sequence will be affected.Not existing files will be not created -echo #>a>b>c>d>e>f -::Info will be red only from the last file in the row.Not existing files will be ignored -set /p="a"b"""c""" -type abc -set /p= can be used as number separators in for /L -echo\ -for /L %%A in (1;1=5) do echo %%A - -:: everyting except first three numbers will be igonred -:: 1000 will be ignored - -for /L %%A in (1;1=5,1000) do echo %%A - -:: every string not containing numbers in the first three items will be taken as 0 - -for /l %%a in (null ; 1 ; 5) do echo %%a - -:: if a string starts with figits only the starting number will be taken into accoung - -set BottleRum=13DeadMen - -for /l %%P in (%BottleRum% 1;%BottleRum%) do set DevilDozen=%%P - -echo %DevilDozen% -echo Yo-Ho-Ho! - -:: http://ss64.org/viewtopic.php?id=1667 diff --git a/discovers_and_bugs/discovers/internal_commands.txt b/discovers_and_bugs/discovers/internal_commands.txt deleted file mode 100644 index 551856f..0000000 --- a/discovers_and_bugs/discovers/internal_commands.txt +++ /dev/null @@ -1,19 +0,0 @@ -Two internal commands were re-"discovered" here: - -http://ss64.org/viewtopic.php?id=1558 - - -KEYS and DPATH - - -DPATH help message points to APPEND command and is not useful at all. -It's syntax is the same as PATH command.Later Carlos Mortinez discovered that -TYPE command uses %DPATH% variable set by DPATH command and can print files in DPATH -directories like there in the same directory.The same with input redirection: -http://ss64.org/viewtopic.php?id=1876 -http://ss64.org/viewtopic.php?id=1875 - - -KEYS command message also is missleading - it claims that has no effect but sets a %KEYS% vaiable (ON or OFF) -despite the command itself does not rely on the environment variable to check its status. - diff --git a/discovers_and_bugs/discovers/keys b/discovers_and_bugs/discovers/keys deleted file mode 100644 index 1e085b3..0000000 --- a/discovers_and_bugs/discovers/keys +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -keys /? -set "keys=" -keys off -echo %keys% -set "keys=" -keys - -exit /b 0 - -::==== -demonstrates the effects of keys command. -I've mentioned the command here http://ss64.org/viewtopic.php?id=1558 -and later in the thread Dave Benham discovered that the command sets an environemnt -variable , which means that the help message is wrong - it affects the current console. -Keys does not relly on %keys% variable to display its state correctly -::===== diff --git a/discovers_and_bugs/discovers/msg.txt b/discovers_and_bugs/discovers/msg.txt deleted file mode 100644 index 8854861..0000000 --- a/discovers_and_bugs/discovers/msg.txt +++ /dev/null @@ -1,16 +0,0 @@ -http://ss64.org/viewtopic.php?id=2075 -Some tests I've made over MSG command (aware that you need installed terminal services to make this command available) showed that there are some special characters that cannot be set at the beginning of the message ( / and - ): -msg "%username%" "--#" -msg "%username%" "//#" -both lines will print the help message . - -They can be esacped with \ (only the first appearance need to be escaped): -msg "%username%" "\--#" -msg "%username%" "\//#" - -it can be used also to put as message with quotes in : -msg "%username%" "\"message with quotes\"" -I havent found other special sequences that can be used with \ - - -Max length of the symbols in the message is 255 diff --git a/discovers_and_bugs/discovers/multiLineComments.txt b/discovers_and_bugs/discovers/multiLineComments.txt deleted file mode 100644 index b448399..0000000 --- a/discovers_and_bugs/discovers/multiLineComments.txt +++ /dev/null @@ -1,148 +0,0 @@ -https://stackoverflow.com/questions/8526946/commenting-multiple-lines-in-dos-batch-file/28522310#28522310 - -The update in the dbenham's answer gave me some ideas. First - there are two different cases where we can need multi line comments - in a bracket's context where GOTO cannot be used and outside it. Inside brackets context we can use another brackets if there's a condition which prevents the code to be executed.Though the code thede will still be parsed and some syntax errors will be detected (FOR,IF ,improperly closed brackets, wrong parameter expansion ..).So if it is possible it's better to use GOTO. - -Though it is not possible to create a macro/variable used as a label - but is possible to use macros for bracket's comments.Still two tricks can be used make the GOTO comments more symetrical and more pleasing (at least for me). For this I'll use two tricks - 1) you can put a single symbol in front of a label and goto will still able to find it (I have no idea why is this.My guues it is searching for a drive). 2) you can put a single : at the end of a variable name and a replacement/subtring feature will be not triggered (even under enabled extensions). Wich combined with the macros for brackets comments can make the both cases to look almost the same. - -So here are the examples (in order I like them most): - -With rectangular brackets: - -@echo off - -::GOTO comment macro -set "[:=goto :]%%" -::brackets comment macros -set "[=rem/||(" & set "]=)" - -::testing -echo not commented 1 - -%[:% - multi - line - comment outside of brackets -%:]% - -echo not commented 2 - -%[:% - second multi - line - comment outside of brackets -%:]% - -::GOTO cannot be used inside for -for %%a in (first second) do ( - echo first not commented line of the %%a execution - %[% - multi line - comment - %]% - echo second not commented line of the %%a execution -) -With curly brackets: - -@echo off - -::GOTO comment macro -set "{:=goto :}%%" -::brackets comment macros -set "{=rem/||(" & set "}=)" - -::testing -echo not commented 1 - -%{:% - multi - line - comment outside of brackets -%:}% - -echo not commented 2 - -%{:% - second multi - line - comment outside of brackets -%:}% - - -for %%a in (first second) do ( - echo first not commented line of the %%a execution - %{% - multi line - comment - %}% - echo second not commented line of the %%a execution -) -With parentheses: - -@echo off - -::GOTO comment macro -set "(:=goto :)%%" -::brackets comment macros -set "(=rem/||(" & set ")=)" - -::testing -echo not commented 1 - -%(:% - multi - line - comment outside of brackets -%:)% - -echo not commented 2 - -%(:% - second multi - line - comment outside of brackets -%:)% - - -for %%a in (first second) do ( - echo first not commented line of the %%a execution - %(% - multi line - comment - %)% - echo second not commented line of the %%a execution -) -Mixture between powershell and C styles (< cannot be used because the redirection is with higher prio.* cannot be used because of the %*) : - -@echo off - -::GOTO comment macro -set "/#:=goto :#/%%" -::brackets comment macros -set "/#=rem/||(" & set "#/=)" - -::testing -echo not commented 1 - -%/#:% - multi - line - comment outside of brackets -%:#/% - -echo not commented 2 - -%/#:% - second multi - line - comment outside of brackets -%:#/% - - -for %%a in (first second) do ( - echo first not commented line of the %%a execution - %/#% - multi line - comment - %#/% - echo second not commented line of the %%a execution -) diff --git a/discovers_and_bugs/discovers/negativeGOTO.bat b/discovers_and_bugs/discovers/negativeGOTO.bat deleted file mode 100644 index edb3360..0000000 --- a/discovers_and_bugs/discovers/negativeGOTO.bat +++ /dev/null @@ -1,31 +0,0 @@ - :: Goto to not existing label exits the script and put in commpand prompt context - :: so commands with negative conditional execution will be executed - :: First I proposed using negative conditiontional execution here: - :: http://stackoverflow.com/questions/23318951/how-to-treat-user-input-as-two-words-instead-of-one-in-batch - :: later the user that I've answered to discovered that only the conditions on the same line will be executed: - :: http://stackoverflow.com/questions/23327304/my-goto-redirect-is-not-working-but-works-with-echo - :: Where jeb's found that the script goes to command prompt context - :: And here I've found that the brackets and FOR contexts are not broken : - :: http://www.dostips.com/forum/viewtopic.php?f=3&t=5928 - - - @echo off - setlocal enableDelayedExpansion - - for /f "tokens=1,2,3" %%a in ("1 2 3 ") do ( - set /a n=1+1 - goto :no_label_ >nul 2>&1 || break just fills the end of line - echo brackets context is not broken - echo( - echo and so variables cannot be accessed - set "n2=something else" - echo -%n%- and -%n2%- - echo but more delayed expansioon does not work --^> !n! :-( - echo( - echo and for context is not broken!!!! - echo %%a--%%b--%%c - echo pass a command line parameter to check the output of this: - echo ~"%~1"~ - - ) - echo never printed diff --git a/discovers_and_bugs/discovers/plainfor b/discovers_and_bugs/discovers/plainfor deleted file mode 100644 index 59c227c..0000000 --- a/discovers_and_bugs/discovers/plainfor +++ /dev/null @@ -1 +0,0 @@ -@ diff --git a/discovers_and_bugs/discovers/promptFeatures.txt b/discovers_and_bugs/discovers/promptFeatures.txt deleted file mode 100644 index 4a6fb91..0000000 --- a/discovers_and_bugs/discovers/promptFeatures.txt +++ /dev/null @@ -1,20 +0,0 @@ -Some undocumented prompt command features: -(http://ss64.org/viewtopic.php?pid=7706#p7706) - - -PROMPT - (Here I'll list some things ) -1.By default %PROMPT% variable is not defined (then prompt displays it's default value $P$G) - -2.If %PROMPT% variable is defined or pre-set via registry deleting it will set again prompt to its default value. - -3.PROMPT command is highly dependable on %PROMPT% variable and editing the variable will lead to the same results (e.g. SET "PROMPT=$P$G") - -4. Everything after a dollar sign sequence that is not in the supported list ( $A $B $C $D $E $F $G $H $L $M $N $P $Q $S $T $V $_ $$ $+ ) will be ignored - -5. Limitations for prompt length are 400 symbols in Windows XP and 511 from Vista and above . Hitting the limit also produces -different results in XP/Vista and the fresher versions: -5.1.On XP it produces error message -5.2.On 7 and above it just only takes the first 511 symbols. - -On XP limitation can be worked-around by setting longer than 400 symbols value directly to PROMPT variable (For these I need clarification by more people so I'll start a separate thread) -Special $-sequneces will be taken as a single symbol. diff --git a/discovers_and_bugs/discovers/splitCommand.bat b/discovers_and_bugs/discovers/splitCommand.bat deleted file mode 100644 index 8e59a12..0000000 --- a/discovers_and_bugs/discovers/splitCommand.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off - -:: https://stackoverflow.com/a/64752041/388389 -:: Splits a long command into a few lines. -:: Limitations are that some special symbols should be escaped (carets, closing brackets and etc.) - -:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -set "{{=setlocal enableDelayedExpansion&for %%a in (" & set "}}="::end::" ) do if "%%~a" neq "::end::" (set command=!command! %%a) else (call !command! & endlocal)" -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:: Example: - -%{{% - echo - "command" - written - on a - few lines -%}}% diff --git a/discovers_and_bugs/discovers/tasklist b/discovers_and_bugs/discovers/tasklist deleted file mode 100644 index f5c38c2..0000000 --- a/discovers_and_bugs/discovers/tasklist +++ /dev/null @@ -1,9 +0,0 @@ -tasklist filters support wildcard (*) if it is put at the end -> -http://stackoverflow.com/questions/36602024/regular-expression-or-wild-card-in-tasklist/36602530#36602530 -tasklist /FI "IMAGENAME eq cm*" - - -And a double quotes can be escaped with \" unless they are not at the end. -title "aa" -tasklist /FI "WINDOWTITLE eq \"aa*" -and backslash can be escaped with double backslash diff --git a/discovers_and_bugs/discovers/typeList.bat b/discovers_and_bugs/discovers/typeList.bat deleted file mode 100644 index c93f999..0000000 --- a/discovers_and_bugs/discovers/typeList.bat +++ /dev/null @@ -1,83 +0,0 @@ -:: Type command accepts wildcards and file lists -:: Every time when a wildcard or a list of more than one -:: file is used it will print file names in StdErr -:: even if a single file applies to the wildcard expression -:: or the file list -:: http://ss64.org/viewtopic.php?id=1794 - -@echo off -echo hello>lang.en -echo holla>lang.es -echo hallo>lang.de - -echo -- -echo -- testing type lang.?? -echo -- -type lang.?? - -echo -- -echo -- testing type lang* 2^>nul -echo -- -type lang* 2>nul - -echo -- -echo -- testing type lang* ^>nul -echo -- -type lang?* >nul - -echo -- -echo -- testimg more lang* -echo -- -more lang* - -exit /b 0 - - -:: the output is - --- --- testing type lang.?? --- - -lang.de - - -hallo - -lang.en - - -hello - -lang.es - - -holla --- --- testing type lang* 2>nul --- -hallo -hello -holla --- --- testing type lang* >nul --- - -lang.de - - - -lang.en - - - -lang.es - - --- --- testimg more lang* --- -hallo -hello -holla - diff --git a/fileUtils/SHA512.bat b/fileUtils/SHA512.bat deleted file mode 100644 index de84145..0000000 --- a/fileUtils/SHA512.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates SHA512 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "SHA512=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" SHA512') do ( - if not defined SHA512 ( - for %%Z in (%%#) do set "SHA512=!SHA512!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%SHA512%" - ) -) else ( - echo %SHA512% -) -endlocal diff --git a/fileUtils/dirTimes.bat b/fileUtils/dirTimes.bat deleted file mode 100644 index f877d11..0000000 --- a/fileUtils/dirTimes.bat +++ /dev/null @@ -1,38 +0,0 @@ -@echo off -setlocal -for %%# in (/h /help -h -help) do ( - if "%~1" equ "%%#" ( - (echo() - echo %~nx0 - Displays LastModified,LastAccessed and DateCreated times of a given directory - echo in format YYYYMMDDhhmmss - (echo() - echo example: - echo call %~nx0 "C:\directory\" - ) -) - -if "%~1" equ "" ( - echo no directory passed - exit /b 1 -) - -if not exist "%~f1" ( - echo directory "%~f1" does not exist - exit /b 2 -) - -if exist "%~f1\" if not exist "%~f1" ( - echo "%~f1" is a file but not a directory - exit /b 3 -) - -set "dirname=%~f1" -set dirname=%dirname:\=\\% -echo directory timestamps for %~f1 : -(echo() -for /f "useback delims=." %%t in (`"WMIC path Win32_Directory WHERE name="%dirname%" get LastModified,CreationDate,LastAccessed /format:value"`) do ( - for /f %%$ in ("%%t") do if "%%$" neq "" echo %%$ -) -endlocal && ( - exit /b %errorlevel% -) diff --git a/fileUtils/encodingDetect.bat b/fileUtils/encodingDetect.bat deleted file mode 100644 index 5011397..0000000 --- a/fileUtils/encodingDetect.bat +++ /dev/null @@ -1,85 +0,0 @@ -@echo off -:detect_encoding -setLocal -if "%1" EQU "-?" ( - endlocal - call :help - exit /b 0 -) -if "%1" EQU "-h" ( - endlocal - call :help - exit /b 0 -) -if "%1" EQU "" ( - endlocal - call :help - exit /b 0 -) - - -if not exist "%1" ( - echo file does not exists - endlocal - exit /b 54 -) - -if exist "%1\" ( - echo this cannot be used against directories - endlocal - exit /b 53 -) - -if "%~z1" EQU "0" ( - echo empty files are not accepted - endlocal - exit /b 52 -) - - - -set "file=%~snx1" -del /Q /F "%file%.hex" >nul 2>&1 - -certutil -f -encodehex %file% %file%.hex>nul - -rem -- find the first line of hex file -- - -for /f "usebackq delims=" %%E in ("%file%.hex") do ( - set "f_line=%%E" > nul - goto :enfdor -) -:enfdor -del /Q /F "%file%.hex" >nul 2>&1 - -rem -- check the BOMs -- -echo %f_line% | find "ef bb bf" >nul && echo utf-8 &&endlocal && exit /b 1 -echo %f_line% | find "ff fe 00 00" >nul && echo utf-32 LE &&endlocal && exit /b 5 -echo %f_line% | find "ff fe" >nul && echo utf-16 &&endlocal && exit /b 2 -echo %f_line% | find "fe ff 00" >nul && echo utf-16 BE &&endlocal && exit /b 3 -echo %f_line% | find "00 00 fe ff" >nul && echo utf-32 BE &&endlocal && exit /b 4 - -echo ASCII & endlocal & exit /b 6 - - - -endLocal -goto :eof - -:help -echo. -echo %~n0 file - Detects encoding of a text file -echo. -echo for each encoding you will recive a text responce with a name and a errorlevel codes as follows: - -echo 1 - UTF-8 -echo 2 - UTF-16 BE -echo 3 - UTF-16 LE -echo 4 - UTF-32 BE -echo 5 - UTF-32 LE -echo 6 - ASCII - -echo for empty files you will receive error code 52 -echo for directories you will receive error code 53 -echo for not existing file you will receive error code 54 -goto :eof diff --git a/fileUtils/extInstaller b/fileUtils/extInstaller deleted file mode 100644 index 475bed8..0000000 --- a/fileUtils/extInstaller +++ /dev/null @@ -1,19 +0,0 @@ - @echo off - :: requires Admin permissions - :: allows a files with .TEST (in this case ) extension to act like .bat/.cmd files. - :: Will create a 'caller.bat' asociated with the extension - :: which will create a temp .bat file on each call (you can consider this as cheating) - :: and will call it. - :: Have on mind that the %0 argument will be lost. - - - rem :: "installing" a caller. - if not exist "c:\caller.bat" ( - echo @echo off - echo copy "%%~nx1" "%%temp%%\%%~nx1.bat" /Y ^>nul - echo "%%temp%%\%%~nx1.bat" %%* - ) > c:\caller.bat - - rem :: associating file extension - assoc .test=batps - ftype batps=c:\caller "%1" %* diff --git a/fileUtils/file2hex.bat b/fileUtils/file2hex.bat deleted file mode 100644 index 13c53fa..0000000 --- a/fileUtils/file2hex.bat +++ /dev/null @@ -1,26 +0,0 @@ -@echo off -:stringToHex -del tmp.hex >nul 2>nul - -if "%~2" equ "" ( - echo destination not given - exit /b 10 -) - -set "source=%~f1" -set "destination=%~2" -del "%destination%" >nul 2>&1 - -if not exist "%source%" ( - echo source file "%source%" does not exist - exit /b 11 -) - -certutil -encodehex "%source%" tmp.hex >nul -setlocal enableDelayedExpansion -set "hex_str=" -for /f "usebackq tokens=2 delims= " %%A in ("tmp.hex") do ( - set "line=%%A" - set line=!line:~0,48! -)>>"%destination%" -del tmp.hex >nul 2>nul diff --git a/fileUtils/fileModifiedTime.bat b/fileUtils/fileModifiedTime.bat deleted file mode 100644 index ccd8691..0000000 --- a/fileUtils/fileModifiedTime.bat +++ /dev/null @@ -1,43 +0,0 @@ -@echo off -setlocal -for %%# in (/h /help -h -help) do ( - if "%~1" equ "%%#" ( - (echo() - echo %~nx0 [rtnVar] - gets last modified time of a file in YYYY/MM/DD HH:mm:SS format - echo rtnVar - optional variable name where the result will be stored - (echo() - echo example: - echo call %~nx0 C:\file.ext lastModified - ) -) - -if "%~1" equ "" ( - echo no file passed - exit /b 1 -) - -if not exist "%~f1" ( - echo file "%~f1" does not exist - exit /b 2 -) - -if exist "%~f1\" ( - echo "%~f1" is a directory but not a file - exit /b 3 -) -set "file_loc=%~f1" -for %%# in ("%file_loc%") do set file_dir=%%~dp# -for %%# in ("%file_loc%") do set file_name=%%~nx# -pushd %file_dir% - -for /f "skip=2 tokens=1,2" %%a in ('robocopy "." "%temp%" /l /fat /ts /LEV:1 /NP /NC /NS /NJS /NJH /IF "%file_name%"') do ( - echo last modified date of "%~f1" : - echo %%a %%b - set "fdate_time=%%a %%b" -) -popd - -endlocal && ( - if "%~2" neq "" set "%2=%fdate_time%" - exit /b %errorlevel% -) diff --git a/fileUtils/fileTimes.bat b/fileUtils/fileTimes.bat deleted file mode 100644 index c6f8312..0000000 --- a/fileUtils/fileTimes.bat +++ /dev/null @@ -1,38 +0,0 @@ -@echo off -setlocal -for %%# in (/h /help -h -help) do ( - if "%~1" equ "%%#" ( - (echo() - echo %~nx0 - Displays LastModified,LastAccessed and DateCreated times of a given file - echo in format YYYYMMDDhhmmss - (echo() - echo example: - echo call %~nx0 C:\file.ext - ) -) - -if "%~1" equ "" ( - echo no file passed - exit /b 1 -) - -if not exist "%~f1" ( - echo file "%~f1" does not exist - exit /b 2 -) - -if exist "%~f1\" ( - echo "%~f1" is a directory but not a file - exit /b 3 -) - -set "file_loc=%~f1" -set file_loc=%file_loc:\=\\% -echo file timestamps for %~f1 : -(echo() -for /f "useback delims=." %%t in (`"WMIC DATAFILE WHERE name="%file_loc%" get LastModified,CreationDate,LastAccessed /format:value"`) do ( - for /f %%$ in ("%%t") do if "%%$" neq "" echo %%$ -) -endlocal && ( - exit /b %errorlevel% -) diff --git a/fileUtils/fileassembler.bat b/fileUtils/fileassembler.bat deleted file mode 100644 index d41e70c..0000000 --- a/fileUtils/fileassembler.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -if "%~1" EQU "" echo parameter not entered & exit /b 1 -set "parts=%~1.part" - -setlocal enableDelayedExpansion -set numb=0 -for /f "delims=." %%P in ('dir /b %parts%*') do ( - set /a numb=numb+1 -) -rem echo !numb! - - -setlocal enableDelayedExpansion -set "string=%~1.part.1" -for /l %%n in (2;1;!numb!) do ( - set "string=!string!+!parts!.%%n" -) -rem echo !string! -copy /y /b !string! %~1%~x1 -endlocal diff --git a/fileUtils/firstLines.bat b/fileUtils/firstLines.bat deleted file mode 100644 index 9498a96..0000000 --- a/fileUtils/firstLines.bat +++ /dev/null @@ -1,7 +0,0 @@ - - -break>"%temp%\empty"&&fc "%temp%\empty" "%file_to_process%" /lb X /t |more +4 | findstr /B /E /V "*****" - -rem comperatively brief way to show first N lines of a file -rem will fail the file contains ***** and MORE command will replace tab characters (if any) with space -rem http://stackoverflow.com/questions/27509846/batch-script-to-overwrite-a-file-with-first-5-lines diff --git a/fileUtils/firstLinesP.bat b/fileUtils/firstLinesP.bat deleted file mode 100644 index 42811c6..0000000 --- a/fileUtils/firstLinesP.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -setlocal enableExtensions - -rem ------ validate parameters ------ -:: parametrized version of batch.scripts/fileUtils/firstLiles.bat -for %%H in ("/h" "-h" "-help" "/help") do if /I "%~1" EQU "%%~H" goto :help -if "%~2" EQU "" goto :help -if not exist "%~1" echo file does not exist && exit /b 3 -set /a "lines=%~2" -if not defined lines echo pass a number bigger than 0 for the lines to be shown&&exit /b 1 -if defined lines if %lines%0 equ 0 echo pass a number bigger than 0 for the lines to be shown&&exit /b 2 -rem --------------------------------- - -;break>"%temp%\empty" -@@fc "%temp%\empty" "%~1" /lb %lines% /t |more +4 | findstr /B /E /V "*****" -;del /q /f "%temp%\empty" - -goto :eof -endlocal - -:help -echo Displays first lines of a given file -echo. -echo %~n0 file lines -echo. -echo. -echo lines Number of lines to display.Must be bigger than 0. -echo file Specifies the file. -:: -:: by Vasil "npocmaka" Arnaudov -:: diff --git a/fileUtils/folderOwner.bat b/fileUtils/folderOwner.bat deleted file mode 100644 index fe38358..0000000 --- a/fileUtils/folderOwner.bat +++ /dev/null @@ -1,24 +0,0 @@ -:folderOwner -@echo off - -set "folder=%%~1" - -for /f "tokens=* delims=" %%a in ("%folder%") do ( - set "fpath=%%~pa" - set "fname=%%~na" - set "fdrive=%%~da" -) - -set "fpath=%fpath:\=\\%" - -for /f "usebackq tokens=* delims=" %%a in (`wmic path Win32_Directory where "path='%fpath%' and drive='%fdrive%' and filename='%fname%'" get CSName /format:value`) do ( - for /f "tokens=* delims=" %%z in ("%%a") do ( - - if "%%z" neq "" ( - set "%%z" - ) - ) -) - -echo %CSName% -exit /b 0 diff --git a/fileUtils/listFS.bat b/fileUtils/listFS.bat deleted file mode 100644 index a385d3d..0000000 --- a/fileUtils/listFS.bat +++ /dev/null @@ -1,5 +0,0 @@ -fltmc volumes | find ":" -rem :: lists file system types (NTFS,FAT32,CDFS ..) on all drivres -rem as fltmc utility is not listed in technet A-Z reference it's rather an example how can it be used -rem requires less code than fsutil -rem http://stackoverflow.com/questions/6995813/how-can-i-use-batch-to-determine-if-a-computer-is-using-fat32-or-ntfs diff --git a/fileUtils/md2.bat b/fileUtils/md2.bat deleted file mode 100644 index e85137d..0000000 --- a/fileUtils/md2.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates MD2 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "MD2=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" MD2') do ( - if not defined MD2 ( - for %%Z in (%%#) do set "MD2=!MD2!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%MD2%" - ) -) else ( - echo %MD2% -) -endlocal diff --git a/fileUtils/md4.bat b/fileUtils/md4.bat deleted file mode 100644 index 6148ff6..0000000 --- a/fileUtils/md4.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates MD4 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "MD4=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" MD4') do ( - if not defined MD4 ( - for %%Z in (%%#) do set "MD4=!MD4!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%MD4%" - ) -) else ( - echo %MD4% -) -endlocal diff --git a/fileUtils/md5.bat b/fileUtils/md5.bat deleted file mode 100644 index f432f2c..0000000 --- a/fileUtils/md5.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates MD5 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "md5=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" MD5') do ( - if not defined md5 ( - for %%Z in (%%#) do set "md5=!md5!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%md5%" - ) -) else ( - echo %md5% -) -endlocal diff --git a/fileUtils/progressCopy.bat b/fileUtils/progressCopy.bat deleted file mode 100644 index 700c4bf..0000000 --- a/fileUtils/progressCopy.bat +++ /dev/null @@ -1,94 +0,0 @@ -@echo off - -:: Copies a single file with progress bar -:: requires at least windows vista -:: uses esentutl command -:: http://ss64.org/viewtopic.php?id=1727 - -rem ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -rem Esentutl is a command that performs some operations over a special windows database files (e.g. restore point files) -rem From Windows Vista and above it supports copy operation which has a progress bar and can be used on ordinary files: - -rem esentutl /y "FILE.EXT" /d"DEST.EXT" /o -rem May be it is not completely reliable: - -rem If performed on arbitrary files, this operation may fail -rem at the end of the file if its size is not sector-aligned. - -rem :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -:progressCopy -setlocal -echo. -for /f "skip=2 tokens=2,3 delims=. " %%V in ('esentutl /d#') do ( - echo esentutl version %%V.%%W - set /a "version=%%V%%W" - goto :break -) -:break -color -if defined version if %version%0 LSS 600 ( - echo UNSUPORTED VERSION - echo Lower than 6.0 - exit /b 3 -) - - -for %%H in ("/h" "-h" "-help" "/help") do ( - if /I "%~1" EQU "%%~H" goto :help -) - -if "%~1" EQU "" ( - goto :help -) -set "source=%~1" - -if not exist "%source%" ( - (echo() - echo source file does not exist - exit /b 2 -) - -for %%F in ("/f" "/force") do ( - if /I "%~3" EQU "%%~F" set "force=1" - if /I "%~2" EQU "%%~F" set "force=1" && set "dest=%~nx1" -) - -if "%~2" NEQ "" ( - if not defined dest set "dest=%~2" -) else ( - if not defined dest set "dest=%~nx1" -) - -if exist "%dest%" if not defined force ( - (echo() - echo file already exist and force option is not set - echo exit /b 1 -) - -if exist "%dest%" if defined force ( - (echo() - echo file already exist and will be overwritten - del /Q /F "%dest%" -) - -esentutl /y "%source%" /d"%dest%" /o -endlocal -goto :eof - -:help -echo. -echo Copying a file with a progress bar -echo. -echo. -echo %~nx0 source [destination] [/force^|/f] -echo. -echo. -echo source - path to the source file -echo. -echo destination - path to the destination file.If not -echo defined it will be set to the current directory. -echo. -echo /force - overwrite the source file if exists -echo. diff --git a/fileUtils/sha1.bat b/fileUtils/sha1.bat deleted file mode 100644 index 0ac7ab9..0000000 --- a/fileUtils/sha1.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates SHA1 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "SHA1=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" SHA1') do ( - if not defined SHA1 ( - for %%Z in (%%#) do set "SHA1=!SHA1!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%SHA1%" - ) -) else ( - echo %SHA1% -) -endlocal diff --git a/fileUtils/sha256.bat b/fileUtils/sha256.bat deleted file mode 100644 index 1e0131e..0000000 --- a/fileUtils/sha256.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates SHA256 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "SHA256=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" SHA256') do ( - if not defined SHA256 ( - for %%Z in (%%#) do set "SHA256=!SHA256!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%SHA256%" - ) -) else ( - echo %SHA256% -) -endlocal diff --git a/fileUtils/sha384.bat b/fileUtils/sha384.bat deleted file mode 100644 index e7d5c30..0000000 --- a/fileUtils/sha384.bat +++ /dev/null @@ -1,57 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -if "%~1" equ "" ( - echo no file passed - echo pass -help to see the help message - exit /b 1 -) - -for %%# in (-h -help /h /help) do ( - if "%~1" equ "%%~#" ( - echo generates SHA384 checksum for a given file - (echo() - echo USAGE: - (echo() - echo %~nx0 file [variable] - (echo() - echo variable string in which the generated checksum will be stored - (echo() - exit /b 0 - ) -) - -if not exist "%~1" ( - echo file %~1 does not exist - exit /b 2 -) - -if exist "%~1\" ( - echo %~1 is a directory - exit /b 3 -) - -for %%# in (certutil.exe) do ( - if not exist "%%~f$PATH:#" ( - echo no certutil installed - echo for Windows XP professional and Windows 2003 - echo you need Windows Server 2003 Administration Tools Pack - echo https://www.microsoft.com/en-us/download/details.aspx?id=3725 - exit /b 4 - ) -) - -set "SHA384=" -for /f "skip=1 tokens=* delims=" %%# in ('certutil -hashfile "%~f1" SHA384') do ( - if not defined SHA384 ( - for %%Z in (%%#) do set "SHA384=!SHA384!%%Z" - ) -) - -if "%~2" neq "" ( - endlocal && ( - set "%~2=%SHA384%" - ) -) else ( - echo %SHA384% -) -endlocal diff --git a/fileUtils/splitBin.bat b/fileUtils/splitBin.bat deleted file mode 100644 index e81207e..0000000 --- a/fileUtils/splitBin.bat +++ /dev/null @@ -1,120 +0,0 @@ -@echo off - -setlocal enableExtensions -rem :----------------------------------------- -rem : check if should prompt the help message -rem :----------------------------------------- -if "%~2" equ "" goto :help -for %%H in (/h -h /help -help) do ( - if /I "%~1" equ "%%H" goto :help -) -if not exist "%~1" echo file does not exist & exit /b 1 - - -rem :----------------------------------------- -rem : validate input -rem :----------------------------------------- -set /a size=%~2 -if not defined size echo something wrong with size parameter & exit /b 2 -if %size%0 LSS 00 echo not a valid number passed as a parameter & exit /b 3 - -rem : -- two hex symbols and an empty space are 1 byte -rem : -- so the sum of all hex symbols -rem : -- per part should be doubled -set /a len=%size%*2 -set "file=%~dfn1" - -for %%F in ("%file%") do set fn=%%~nxF - -rem : -- clear temp data -del /F /Q "%temp%\file" >nul 2>&1 -del /F /Q "%temp%\fn.p.*" >nul 2>&1 -certutil -encodehex -f "%file%" "%temp%\file" >nul -set "part=1" - -setlocal enableDelayedExpansion - set "hex_str=" - set hex_len=0 - break>%temp%\fn.p.!part! - -rem : -- reads the hex encoded file -rem : -- and make it on a parts that will -rem : -- decoded with certutil - -rem :-- the delimitier is wich separates -rem :-- line number from the rest of the information -rem :-- in the hex file -rem :---------------------------- v -for /f "usebackq tokens=2 delims= " %%A in ("%temp%\file") do ( - set "line=%%A" - rem : -- there's a double space in the middle of the line - rem :-- so here the line is get - set hex_str=!hex_str!!line:~0,48! - rem echo hex_str !hex_str! - rem :-- empty spaces are cleared - set hex_str=!hex_str: =! - rem echo hex_str !hex_str! - rem :-- the length of the hex line 32 - set /a hex_len=hex_len+32 - - rem : -- len/size is reached - rem : -- and the content is printed to a hex file - if !hex_len! GEQ !len! ( - echo !hex_len! GEQ !len! - set /a rest=hex_len-len - for %%A in (!rest!) do ( - (echo(!hex_str:~0,-%%A!)>>%temp%\fn.p.!part! - rem : -- the rest of the content of the line is saved - set hex_str=!hex_str:~-%%A! - set /a hex_len=rest - echo !hex_len! - ) - certutil -decodehex -f %temp%\fn.p.!part! %fn%.part.!part! >nul - echo -- !part!th part created -- - rem :-- preprarin next hex file - set /a part=part+1 - break>%temp%\fn.p.!part! - rem :-- reinitilization of the len/size of the file part - set /a len=%size%*2 - ) - rem : -- a buffer that not allows to - rem : -- to enter too long commmands - rem : -- used to reduce disk operations - if !hex_len! GEQ 7800 ( - (echo(!hex_str!)>>%temp%\fn.p.!part! - set "hex_str=" - set hex_len=0 - rem :-- the size that need to be reached is reduces - rem :-- as there's alredy part of the part of the file - rem :-- added to the hex file - set /a len=!len!-7800 - if !len! LSS 0 set len=0 - - ) - -) -rem : -- adding the rest of the file -echo !hex_str!>>%temp%\fn.p.!part! -certutil -decodehex -f %temp%\fn.p.!part! %fn%.part.!part! >nul -echo -- !part!th part created -- - -rem : -- clear created temp data -rem del /F /Q %temp%\fn.p.* >nul 2>&1 -rem del /F /Q %temp%\file >nul 2>&1 -endlocal -endlocal - -goto :eof -rem :----------------------------------------- -rem : help message -rem :----------------------------------------- - -:help -echo\ -echo Splits a file on parts by given size in bytes in 'pure' batch. -echo\ -echo\ -echo %0 file size -echo\ -echo\ -echo by Vasil "npocmaka" Arnaudov diff --git a/fileUtils/tailHead.bat b/fileUtils/tailHead.bat deleted file mode 100644 index 8b6b18c..0000000 --- a/fileUtils/tailHead.bat +++ /dev/null @@ -1,152 +0,0 @@ -@echo off -setlocal - -rem --------------------------- -rem ------ arg parsing -------- -rem --------------------------- - - if "%~1" equ "" goto :help - for %%H in (/h -h /help -help) do ( - if /I "%~1" equ "%%H" goto :help - ) - setlocal enableDelayedExpansion - set "prev=" - for %%A in (%*) do ( - if /I "!prev!" equ "-file" set file=%%~fsA - if /I "!prev!" equ "-begin" set begin=%%~A - if /I "!prev!" equ "-end" set end=%%A - set prev=%%~A - ) - endlocal & ( - if "%file%" neq "" (set file=%file%) - if "%begin%" neq "" (set /a begin=%begin%) - if "%end%" neq "" (set /a end=%end%) - ) - -rem ----------------------------- -rem --- invalid cases check ----- -rem ----------------------------- - - if "%file%" EQU "" echo file not defined && exit /b 1 - if not exist "%file%" echo file not exists && exit /b 2 - if not defined begin if not defined end echo neither BEGIN line nor END line are defined && exit /b 3 - -rem -------------------------- -rem -- function selection ---- -rem -------------------------- - - if defined begin if %begin%0 LSS 0 for /F %%C in ('find /c /v "" ^<"%file%"') do set /a lines_count=%%C - if defined end if %end%0 LSS 0 if not defined lines_count for /F %%C in ('find /c /v "" ^<"%file%"') do set lines_count=%%C - - rem -- begin only - if not defined begin if defined end if %end%0 GEQ 0 goto :end_only - if not defined begin if defined end if %end%0 LSS 0 ( - set /a end=%lines_count%%end%+1 - goto :end_only - ) - - rem -- end only - if not defined end if defined begin if %begin%0 GEQ 0 goto :begin_only - if not defined end if defined begin if %begin%0 LSS 0 ( - set /a begin=%lines_count%%begin%+1 - goto :begin_only - ) - rem -- begin and end - if %begin%0 LSS 0 if %end%0 LSS 0 ( - set /a begin=%lines_count%%begin%+1 - set /a end=%lines_count%%end%+1 - goto :begin_end - ) - if %begin%0 LSS 0 if %end%0 GEQ 0 ( - set /a begin=%lines_count%%begin%+1 - goto :begin_end - ) - if %begin%0 GEQ 0 if %end%0 LSS 0 ( - set /a end=%lines_count%%end%+1 - goto :begin_end - ) - if %begin%0 GEQ 0 if %end%0 GEQ 0 ( - goto :begin_end - ) -goto :eof - -rem ------------------------- -rem ------ functions -------- -rem ------------------------- - -rem ----- single cases ----- - -:begin_only - setlocal DisableDelayedExpansion - for /F "delims=" %%L in ('findstr /R /N "^" "%file%"') do ( - set "line=%%L" - for /F "delims=:" %%n in ("%%L") do ( - if %%n GEQ %begin% ( - setlocal EnableDelayedExpansion - set "text=!line:*:=!" - (echo(!text!) - endlocal - ) - ) - ) - endlocal -endlocal -goto :eof - -:end_only - setlocal disableDelayedExpansion - for /F "delims=" %%L in ('findstr /R /N "^" "%file%"') do ( - set "line=%%L" - for /F "delims=:" %%n in ("%%L") do ( - IF %%n LEQ %end% ( - setlocal EnableDelayedExpansion - set "text=!line:*:=!" - (echo(!text!) - endlocal - ) ELSE goto :break_eo - ) - ) - :break_eo - endlocal -endlocal -goto :eof - -rem --- end and begin case ----- - -:begin_end - setlocal disableDelayedExpansion - if %begin% GTR %end% goto :break_be - for /F "delims=" %%L in ('findstr /R /N "^" "%file%"') do ( - set "line=%%L" - for /F "delims=:" %%n in ("%%L") do ( - IF %%n GEQ %begin% IF %%n LEQ %end% ( - setlocal EnableDelayedExpansion - set "text=!line:*:=!" - (echo(!text!) - endlocal - ) ELSE goto :break_be - ) - ) - :break_be - endlocal -endlocal -goto :eof -rem ------------------ -rem --- HELP --------- -rem ------------------ -:help - echo( - echo %~n0 - dipsplays a lines of a file defined by -BEGIN and -END arguments passed to it - echo( - echo( USAGE: - echo( - echo %~n0 -file=file_to_process {-begin=begin_line ^| -end=end_line } - echo or - echo %~n0 -file file_to_process {-begin begin_line ^| -end end_line } - echo( - echo( if some of arguments BEGIN or END has a negative number it will start to count from the end of file - echo( - echo( http://ss64.org/viewtopic.php^?id^=1707 - echo( - echo( by Vasil "npocmaka" Arnaudov -goto :eof diff --git a/fileUtils/wmicVersion.bat b/fileUtils/wmicVersion.bat deleted file mode 100644 index 6487439..0000000 --- a/fileUtils/wmicVersion.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off -:wmicVersion pathToBinary [variableToSaveTo] -setlocal -set "item=%~1" -set "item=%item:\=\\%" - - -for /f "usebackq delims=" %%a in (`"WMIC DATAFILE WHERE name='%item%' get Version /format:Textvaluelist"`) do ( - for /f "delims=" %%# in ("%%a") do set "%%#" -) - -if "%~2" neq "" ( - endlocal & ( - echo %version% - set %~2=%version% - ) -) else ( - echo %version% -) diff --git a/hybrids/.net/FileTimeFilerJS.bat b/hybrids/.net/FileTimeFilerJS.bat deleted file mode 100644 index 3c7eb14..0000000 --- a/hybrids/.net/FileTimeFilerJS.bat +++ /dev/null @@ -1,268 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - - %~n0.exe %* 2>nul - -endlocal & exit /b %errorlevel% - - -*/ - -import System; -import System.Globalization; -import System.DateTime; -import System.IO; -import System.IO.Directory; -import System.Collections; - - - -var arguments:String[] = Environment.GetCommandLineArgs(); - -var directory="."; -//var filter="creation"; -var max_date=DateTime.Now.Ticks ; -var min_date=DateTime.MinValue.Ticks ; - -var DD=0; -var hh=0; -var mm=0; -var ss=0; - -var recursive=true; -var show_dirs=false; -var show_files=true; -var mask="*"; -var direction="after"; - -var getFunct=File.GetCreationTime; - - - -function printHelp(){ - Console.WriteLine(arguments[0] + " filters files/directories by date or time"); - Console.WriteLine(""); - Console.WriteLine("Usage:"); - Console.WriteLine(arguments[0] + " directory [options]"); - Console.WriteLine("Options:"); - Console.WriteLine("-beginDate dd-MM-yy#hh:mm:ss -endDate dd-MM-yy#hh:mm:ss"); - Console.WriteLine(" will show files/directories between the two dates.Date format can be"); - Console.WriteLine(" dd-MM-yy#hh:mm:ss|dd-MM-yy (time will be 00:00:00)|#hh:mm:ss( date will be current)|"); - Console.WriteLine(" dd-MM-yy#hh|dd-MM-yy#hh:mm"); - Console.WriteLine(" default are 01:01:0001#00:00:00 and the current"); - Console.WriteLine("-mask pattern "); - Console.WriteLine(" will show files/directories that applies a given pattern.Wildcards are accepted"); - Console.WriteLine(" Default is '*'"); - Console.WriteLine("-direction before|after "); - Console.WriteLine(" will search for files/directories before or after given date.Default is after"); - Console.WriteLine("-hh Number"); - Console.WriteLine(" Will add/subtract(if number is negative) hours to given dates"); - Console.WriteLine(" Default is 0"); - Console.WriteLine("-mm Number"); - Console.WriteLine(" Will add/subtract(if number is negative) minutes to given dates"); - Console.WriteLine(" Default is 0"); - Console.WriteLine("-dd Number"); - Console.WriteLine(" Will add/subtract(if number is negative) days to given dates"); - Console.WriteLine(" Default is 0"); - Console.WriteLine("-ss Number"); - Console.WriteLine(" Will add/subtract(if number is negative) seconds to given dates"); - Console.WriteLine(" Default is 0"); - Console.WriteLine("-recursive yes|no"); - Console.WriteLine(" Will search be recursive or not"); - Console.WriteLine(" Default is yes"); - Console.WriteLine("-show dirs|files"); - Console.WriteLine(" Will search files or directories"); - Console.WriteLine(" Default is files"); - Console.WriteLine(""); - Console.WriteLine("-filetime created|accessed|modified"); - Console.WriteLine(" Will search files or directories by passed time property "); - Console.WriteLine(" Default is created"); - Console.WriteLine("Examples:"); - Console.WriteLine(""); - Console.WriteLine("Will show files older than 5 hours"); - Console.WriteLine(arguments[0] + '"." -hh -5'); - Console.WriteLine(""); - Console.WriteLine("Will show files between the begin and end date with '.jpg' extension"); - Console.WriteLine(arguments[0] + '"." -beginDate 30-12-14#15:30:00 -endDate 10-01-15#00:00:10 -mask "*.jpg"'); - Console.WriteLine("Will show files newer than 5 hours starting from given date"); - Console.WriteLine(arguments[0] + '"." -hh 5 -beginDate -beginDate 30-12-14#15:30:00'); - Console.WriteLine(""); - Console.WriteLine("Will show files older than 5 hours starting from given date"); - Console.WriteLine(arguments[0] + '"." -hh 5 -beginDate -beginDate 30-12-14#15:30:00 -direction before'); - Console.WriteLine(""); -} - -function parseDate(stringDate){ - try { - var provider = CultureInfo.InvariantCulture; - switch (stringDate.length){ - case 8: - var pattern="dd-MM-yy"; - return DateTime.ParseExact(stringDate,pattern,provider).Ticks; - case 9: - var pattern="d-M-yyyy#hh:mm:ss"; - var c_date=DateTime.Now; - var remastered_date=c_date.Month+"-"+c_date.Day+"-"+c_date.Year+stringDate; - return DateTime.ParseExact(stringDate,pattern,provider).Ticks; - case 11: - var pattern="dd-MM-yy#hh"; - return DateTime.ParseExact(stringDate,pattern,provider).Ticks; - case 14: - var pattern="dd-MM-yy#hh:mm"; - return DateTime.ParseExact(stringDate,pattern,provider).Ticks; - case 17: - var pattern="dd-MM-yy#hh:mm:ss"; - return DateTime.ParseExact(stringDate,pattern,provider).Ticks; - default: - Console.WriteLine("Wrong date format"); - Environment.Exit(7); - } - } catch (err) { - Console.WriteLine(err.message) - } -} - -function parseArgs(){ - - if (arguments[1] == "-h" || arguments[1] == "-help"){ - printHelp(); - } - - if (arguments.length<2){ - Console.WriteLine("Wrong arguments"); - printHelp(); - Environment.Exit(1); - } - - if (arguments.length%2 != 0){ - Console.WriteLine("Wrong number of arguments"); - printHelp(); - Environment.Exit(2); - } - - directory=arguments[1]; - - for (var i=2;i max_date) { - min_date=min_date^max_date; - max_date=min_date^max_date; - min_date=min_date^max_date; -} - - - -function listItems(funct,getFunct){ - var files:String[]=funct(directory,"*",System.IO.SearchOption.AllDirectories); - for (var f=0;f= min_date && getFunct(files[f]).Ticks <= max_date){ - - Console.WriteLine(files[f]); - //Console.WriteLine(" ; " + getFunct(files[f]).Ticks); - } - } -} - - -if (show_dirs){ - listItems(Directory.GetDirectories ,getFunct); -} - -if (show_files){ - listItems(Directory.GetFiles,getFunct); -} diff --git a/hybrids/.net/ProcessStartJS.bat b/hybrids/.net/ProcessStartJS.bat deleted file mode 100644 index 912d455..0000000 --- a/hybrids/.net/ProcessStartJS.bat +++ /dev/null @@ -1,187 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - - %~n0.exe %* 2>nul - -endlocal & exit /b %errorlevel% - - -*/ - -import System; -import System.Diagnostics; - - -var arguments:String[] = Environment.GetCommandLineArgs(); - -var command=""; -var command_args=""; -var pid=0; -var priorityClass=ProcessPriorityClass.Normal; -var processorAffinity=1; -var workingDirectory="."; -var windowStyle=ProcessWindowStyle.Hidden; - -var newWindows=true; -var redirectStandartError=false; -var redirectStandartInput=false; -var redirectStandartOutput=false; -var useShellExecute=true; - -//var verbose=false; - - -function printHelp(){ - Console.WriteLine(arguments[0] + " starts a process in different modes"); - Console.WriteLine("Usage:"); - Console.WriteLine(arguments[0] + " command [-option value]"); - Console.WriteLine("Options:"); - Console.WriteLine("-style Hidden|Normal|Maximized|Minimized"); - Console.WriteLine("-arguments command_arguments"); - Console.WriteLine("-priority Normal|High|BellowNormal|AboveNormal|RealTime|Idle"); - Console.WriteLine("-directory working_directory"); - Console.WriteLine("-newWindow yes|no"); - Console.WriteLine("-affinity 1..7"); - Console.WriteLine("-redirectError yes|no"); - Console.WriteLine("-redirectInput yes|no"); - Console.WriteLine("-redirectOutput yes|no"); - Console.WriteLine("-useshellexecute yes|no"); - Console.WriteLine(""); - Console.WriteLine("More Info: https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo%28v=vs.110%29.aspx"); - -} - -function parseArgs(){ - - if (arguments[1] == "-h" || arguments[1] == "-help"){ - printHelp(); - } - - if (arguments.length<2){ - Console.WriteLine("Wrong arguments"); - printHelp(); - Environment.Exit(1); - } - - if (arguments.length%2 != 0){ - Console.WriteLine("Wrong number of arguments"); - printHelp(); - Environment.Exit(2); - } - - command=arguments[1]; - - for (var i=2;inul 2>&1 -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -if exist "%~n0.exe" ( - "%~n0.exe" %* -) - - -endlocal & exit /b %errorlevel% - -end of jscript comment*/ - -import System; -import System.Windows; -import System.Windows.Forms; -import System.Drawing; -import System.Drawing.SystemIcons; - - -var arguments:String[] = Environment.GetCommandLineArgs(); - - -var notificationText="Warning"; -var icon=System.Drawing.SystemIcons.Hand; -var tooltip=null; -//var tooltip=System.Windows.Forms.ToolTipIcon.Info; -var title=""; -//var title=null; -var timeInMS:Int32=2000; - - - - - -function printHelp( ) { - print( arguments[0] + " [-tooltip warning|none|warning|info] [-time milliseconds] [-title title] [-text text] [-icon question|hand|exclamation|аsterisk|application|information|shield|question|warning|windlogo]" ); - -} - -function setTooltip(t) { - switch(t.toLowerCase()){ - - case "error": - tooltip=System.Windows.Forms.ToolTipIcon.Error; - break; - case "none": - tooltip=System.Windows.Forms.ToolTipIcon.None; - break; - case "warning": - tooltip=System.Windows.Forms.ToolTipIcon.Warning; - break; - case "info": - tooltip=System.Windows.Forms.ToolTipIcon.Info; - break; - default: - //tooltip=null; - print("Warning: invalid tooltip value: "+ t); - break; - - } - -} - -function setIcon(i) { - switch(i.toLowerCase()){ - //Could be Application,Asterisk,Error,Exclamation,Hand,Information,Question,Shield,Warning,WinLogo - case "hand": - icon=System.Drawing.SystemIcons.Hand; - break; - case "application": - icon=System.Drawing.SystemIcons.Application; - break; - case "аsterisk": - icon=System.Drawing.SystemIcons.Asterisk; - break; - case "error": - icon=System.Drawing.SystemIcons.Error; - break; - case "exclamation": - icon=System.Drawing.SystemIcons.Exclamation; - break; - case "hand": - icon=System.Drawing.SystemIcons.Hand; - break; - case "information": - icon=System.Drawing.SystemIcons.Information; - break; - case "question": - icon=System.Drawing.SystemIcons.Question; - break; - case "shield": - icon=System.Drawing.SystemIcons.Shield; - break; - case "warning": - icon=System.Drawing.SystemIcons.Warning; - break; - case "winlogo": - icon=System.Drawing.SystemIcons.WinLogo; - break; - default: - print("Warning: invalid icon value: "+ i); - break; - } -} - - -function parseArgs(){ - if ( arguments.length == 1 || arguments[1].toLowerCase() == "-help" || arguments[1].toLowerCase() == "-help" ) { - printHelp(); - Environment.Exit(0); - } - - if (arguments.length%2 == 0) { - print("Wrong number of arguments"); - Environment.Exit(1); - } - for (var i=1;i [-user user -password password] [-proxy proxy] [-proxy_user proxy.user -proxy_pass proxy.pass]"); - -} - -function parseArgs(){ - - if (arguments.length < 3) { - Console.WriteLine("Wrong arguments"); - printHelp(); - Environment.Exit(1); - } - - if (arguments.length %2 != 1) { - Console.WriteLine("Wrong number arguments"); - printHelp(); - Environment.Exit(2); - } - - url=arguments[1]; - toFile=arguments[2]; - - for (var i=3;inul 2>nul - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -%~n0.exe "%jsc%" %* -del /q /f %~n0.exe 1>nul 2>nul -endlocal & exit /b %errorlevel% -*/ - -//https://github.com/npocmaka/batch.scripts/blob/master/hybrids/.net/bat2exe.bat -import System; -import System; -import System.IO; -import System.Diagnostics; - - -var arguments:String[] = Environment.GetCommandLineArgs(); -if (arguments.length<3){ - Console.WriteLine("Path to cmd\bat file not given"); - Environment.Exit(1); -} - -var binName=Path.GetFileName(arguments[2])+".exe"; -if(arguments.length>3){ - binName=Path.GetFileName(arguments[3]); -} -var batchContent:byte[]= File.ReadAllBytes(arguments[2]); -var compilerLoc=arguments[1]; - -var content="[" - -for (var i=0;inul||@goto :batch -/* -:batch -@echo off -setlocal - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /warn:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - - - - - - - using System; - using System.Drawing; - using System.Runtime.InteropServices; - - public class Win32 - { - [DllImport("user32.dll")] - static extern IntPtr GetDC(IntPtr hwnd); - - [DllImport("user32.dll")] - static extern Int32 ReleaseDC(IntPtr hwnd, IntPtr hdc); - - [DllImport("gdi32.dll")] - static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos); - - static public System.Drawing.Color GetPixelColor(int x, int y) - { - IntPtr hdc = GetDC(IntPtr.Zero); - uint pixel = GetPixel(hdc, x, y); - ReleaseDC(IntPtr.Zero, hdc); - Color color = Color.FromArgb((int)(pixel & 0x000000FF), - (int)(pixel & 0x0000FF00) >> 8, - (int)(pixel & 0x00FF0000) >> 16); - return color; - } - - public static void Main(string[] args) - { - int X= Int32.Parse(args[0]); - int Y=Int32.Parse(args[1]); - System.Console.WriteLine(GetPixelColor(X,Y)); - } - } diff --git a/hybrids/.net/c/listWindows.bat b/hybrids/.net/c/listWindows.bat deleted file mode 100644 index d2fbd0a..0000000 --- a/hybrids/.net/c/listWindows.bat +++ /dev/null @@ -1,118 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal - -::delete line when ready -del %~n0.exe >nul 2>nul - - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /warn:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System; -using System.Text; -using System.Diagnostics; - -/// -/// EnumDesktopWindows Demo - shows the caption of all desktop windows. -/// Authors: Svetlin Nakov, Martin Kulov -/// Bulgarian Association of Software Developers - http://www.devbg.org/en/ -/// -public class user32 -{ - /// - /// filter function - /// - /// - /// - /// - public delegate bool EnumDelegate(IntPtr hWnd, int lParam); - - - [DllImport("user32.dll", SetLastError=true)] - static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); - /// - /// check if windows visible - /// - /// - /// - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool IsWindowVisible(IntPtr hWnd); - - /// - /// return windows text - /// - /// - /// - /// - /// - [DllImport("user32.dll", EntryPoint = "GetWindowText", - ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] - public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpWindowText, int nMaxCount); - - /// - /// enumarator on all desktop windows - /// - /// - /// - /// - /// - [DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", - ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)] - public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam); - - /// - /// entry point of the program - /// - static void Main() - { - var collection = new List(); - user32.EnumDelegate filter = delegate(IntPtr hWnd, int lParam) - { - StringBuilder strbTitle = new StringBuilder(255); - int nLength = user32.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1); - string strTitle = strbTitle.ToString(); - - if (user32.IsWindowVisible(hWnd) && string.IsNullOrEmpty(strTitle) == false) - { - uint res; - GetWindowThreadProcessId(hWnd,out res); - //Console.WriteLine(Process.GetProcessById((int)res).ProcessName); - - collection.Add(Process.GetProcessById((int)res).ProcessName+"::"+strTitle); - } - return true; - }; - - if (user32.EnumDesktopWindows(IntPtr.Zero, filter, IntPtr.Zero)) - { - foreach (var item in collection) - { - Console.WriteLine(item); - } - } - //Console.Read(); - } -} diff --git a/hybrids/.net/c/mouse.bat b/hybrids/.net/c/mouse.bat deleted file mode 100644 index 42c435f..0000000 --- a/hybrids/.net/c/mouse.bat +++ /dev/null @@ -1,441 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /warn:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - -// To create this I've stole code from : -// http://inputsimulator.codeplex.com/ -// https://stackoverflow.com/a/8022534/388389 - -using System; -using System.Runtime.InteropServices; - -namespace MouseMover -{ - public class MouseSimulator - { - [DllImport("user32.dll", SetLastError = true)] - static extern uint SendInput(uint nInputs, ref INPUT pInputs, int cbSize); - [DllImport("user32.dll")] - public static extern int SetCursorPos(int x, int y); - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool GetCursorPos(out POINT lpPoint); - //----// - [DllImport("user32.dll")] - public static extern bool ClientToScreen(IntPtr hWnd, ref POINT lpPoint); - [DllImport("user32.dll")] - static extern void ClipCursor(ref Rect rect); - [DllImport("user32.dll")] - static extern void ClipCursor(IntPtr rect); - [DllImport("user32.dll", SetLastError = true)] - static extern IntPtr CopyImage(IntPtr hImage, uint uType, int cxDesired, int cyDesired, uint fuFlags); - [DllImport("user32.dll")] - static extern bool CopyRect(out Rect lprcDst, [In] ref Rect lprcSrc); - [DllImport("user32.dll")] - static extern int GetSystemMetrics(SystemMetric smIndex); - - - [StructLayout(LayoutKind.Sequential)] - struct INPUT - { - public SendInputEventType type; - public MouseKeybdhardwareInputUnion mkhi; - } - [StructLayout(LayoutKind.Explicit)] - struct MouseKeybdhardwareInputUnion - { - [FieldOffset(0)] - public MouseInputData mi; - - [FieldOffset(0)] - public KEYBDINPUT ki; - - [FieldOffset(0)] - public HARDWAREINPUT hi; - } - [StructLayout(LayoutKind.Sequential)] - struct KEYBDINPUT - { - public ushort wVk; - public ushort wScan; - public uint dwFlags; - public uint time; - public IntPtr dwExtraInfo; - } - [StructLayout(LayoutKind.Sequential)] - struct HARDWAREINPUT - { - public int uMsg; - public short wParamL; - public short wParamH; - } - [StructLayout(LayoutKind.Sequential)] - public struct POINT - { - public int X; - public int Y; - - public POINT(int x, int y) - { - this.X = x; - this.Y = y; - } - } - struct MouseInputData - { - public int dx; - public int dy; - public uint mouseData; - public MouseEventFlags dwFlags; - public uint time; - public IntPtr dwExtraInfo; - } - struct Rect - { - public long left; - public long top; - public long right; - public long bottom; - - public Rect(long left,long top,long right , long bottom) - { - this.left = left; - this.top = top; - this.right = right; - this.bottom = bottom; - } - } - - [Flags] - enum MouseEventFlags : uint - { - MOUSEEVENTF_MOVE = 0x0001, - MOUSEEVENTF_LEFTDOWN = 0x0002, - MOUSEEVENTF_LEFTUP = 0x0004, - MOUSEEVENTF_RIGHTDOWN = 0x0008, - MOUSEEVENTF_RIGHTUP = 0x0010, - MOUSEEVENTF_MIDDLEDOWN = 0x0020, - MOUSEEVENTF_MIDDLEUP = 0x0040, - MOUSEEVENTF_XDOWN = 0x0080, - MOUSEEVENTF_XUP = 0x0100, - MOUSEEVENTF_WHEEL = 0x0800, - MOUSEEVENTF_VIRTUALDESK = 0x4000, - MOUSEEVENTF_ABSOLUTE = 0x8000 - } - enum SendInputEventType : int - { - InputMouse, - InputKeyboard, - InputHardware - } - - enum SystemMetric - { - SM_CXSCREEN = 0, - SM_CYSCREEN = 1, - } - - static int CalculateAbsoluteCoordinateX(int x) - { - return (x * 65536) / GetSystemMetrics(SystemMetric.SM_CXSCREEN); - } - - static int CalculateAbsoluteCoordinateY(int y) - { - return (y * 65536) / GetSystemMetrics(SystemMetric.SM_CYSCREEN); - } - - static void DoubleClick() - { - ClickLeftMouseButton(); - //System.Threading.Thread.Sleep(100); - ClickLeftMouseButton(); - } - - static void MoveMouseBy(int x, int y) { - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE; - mouseInput.mkhi.mi.dx = x; - mouseInput.mkhi.mi.dy = y; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - } - - static void MoveMouseTo(int x, int y) { - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE|MouseEventFlags.MOUSEEVENTF_ABSOLUTE; - mouseInput.mkhi.mi.dx = CalculateAbsoluteCoordinateX(x); - mouseInput.mkhi.mi.dy = CalculateAbsoluteCoordinateY(y); - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - } - static void DragMouseBy(int x, int y) { - - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTDOWN; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - //does not work with MouseEventFlags.MOUSEEVENTF_MOVE | MouseEventFlags.MOUSEEVENTF_LEFTDOWN - // so two consec. send inputs - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE; - mouseInput.mkhi.mi.dx = CalculateAbsoluteCoordinateX(x); - mouseInput.mkhi.mi.dy = CalculateAbsoluteCoordinateY(y); - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTUP; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - } - static void DragMouseTo(int x, int y) { - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTDOWN; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_MOVE|MouseEventFlags.MOUSEEVENTF_ABSOLUTE; - mouseInput.mkhi.mi.dx = x; - mouseInput.mkhi.mi.dy = y; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTUP; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - } - - - //There's conflict between negative DWOR values and UInt32 so there are two methods - // for scrolling - static void ScrollUp(int amount) { - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_WHEEL; - mouseInput.mkhi.mi.mouseData = (UInt32)amount; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - } - - static void ScrollDown(int amount) - { - INPUT mouseInput = new INPUT(); - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_WHEEL; - mouseInput.mkhi.mi.mouseData = 0-(UInt32)amount; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - } - - - static void ClickLeftMouseButton() - { - - INPUT mouseInput = new INPUT(); - - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTDOWN; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - //mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_LEFTUP; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - } - static void ClickRightMouseButton() - { - INPUT mouseInput = new INPUT(); - - mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_RIGHTDOWN; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - //mouseInput.type = SendInputEventType.InputMouse; - mouseInput.mkhi.mi.dwFlags = MouseEventFlags.MOUSEEVENTF_RIGHTUP; - SendInput(1, ref mouseInput, Marshal.SizeOf(mouseInput)); - - } - - - static void getCursorPos() - { - POINT p; - if (GetCursorPos(out p)) - { - Console.WriteLine(Convert.ToString(p.X) + "x" + Convert.ToString(p.Y)); - } - else - { - Console.WriteLine("unknown"); - } - } - - static void ScrollCaller(string ammountStr,Boolean up) - { - try - { - int ammount = int.Parse(ammountStr); - if (ammount < 0) - { - Console.WriteLine("Scroll ammount must be positive number"); - System.Environment.Exit(3); - } - if (up) - { - ScrollUp(ammount); - } - else - { - ScrollDown(ammount); - } - } - catch (Exception) - { - Console.WriteLine("Number parsing error"); - System.Environment.Exit(2); - } - - } - - static int[] parser(String arg) { - string[] sDim= arg.Split('x'); - if (sDim.Length == 1) { - Console.WriteLine("Invalid arguments - dimmensions cannot be aquired"); - System.Environment.Exit(6); - } - try - { - int x = int.Parse(sDim[0]); - int y = int.Parse(sDim[1]); - return new int[]{x,y}; - } - catch (Exception e) { - Console.WriteLine("Error while parsing dimensions"); - System.Environment.Exit(7); - } - return null; - - } - - static void CheckArgs(String[] args) { - if (args.Length == 1) - { - Console.WriteLine("Not enough arguments"); - System.Environment.Exit(1); - } - } - - static void PrintHelp() { - String filename = Environment.GetCommandLineArgs()[0]; - filename = filename.Substring(0, filename.Length); - - Console.WriteLine(filename+" controls the mouse cursor through command line "); - Console.WriteLine("Usage:"); - Console.WriteLine(""); - Console.WriteLine(filename+" action [arguments]"); - Console.WriteLine("Actions:"); - Console.WriteLine("doubleClick - double clicks at the current position"); - Console.WriteLine("click - clicks at the current position"); - Console.WriteLine("rightClick - clicks with the right mouse button at the current position"); - Console.WriteLine("position - prints the mouse cursor position"); - Console.WriteLine("scrollUp N - scrolls up the mouse wheel.Requires a number for the scroll ammount"); - Console.WriteLine("scrollDown N - scrolls down the mouse wheel.Requires a number for the scroll ammount"); - Console.WriteLine("moveBy NxM - moves the mouse curosor to relative coordinates.Requires two numbers separated by low case 'x' ."); - Console.WriteLine("moveTo NxM - moves the mouse curosor to absolute coordinates.Requires two numbers separated by low case 'x' ."); - Console.WriteLine("dragBy NxM - drags the mouse curosor to relative coordinates.Requires two numbers separated by low case 'x' ."); - Console.WriteLine("dragTo NxM - drags the mouse curosor to absolute coordinates.Requires two numbers separated by low case 'x' ."); - Console.WriteLine(""); - Console.WriteLine("Consider using only " +filename+" (without extensions) to prevent print of the errormessages after the first start"); - Console.WriteLine(" in case you are using batch-wrapped script."); - - } - - public static void Main(String[] args) { - if (args.Length == 0) { - PrintHelp(); - System.Environment.Exit(0); - } - if (args[0].ToLower() == "-help" || args[0].ToLower() == "-h") { - PrintHelp(); - System.Environment.Exit(0); - } - - if (args[0].ToLower() == "doubleclick") - { - DoubleClick(); - } - else if (args[0].ToLower() == "click" || args[0].ToLower() == "leftclick") - { - ClickLeftMouseButton(); - } - else if (args[0].ToLower() == "position") - { - getCursorPos(); - } - else if (args[0].ToLower() == "rightclick") - { - ClickRightMouseButton(); - } - else if (args[0].ToLower() == "scrollup") - { - CheckArgs(args); - ScrollCaller(args[1], true); - - } - else if (args[0].ToLower() == "scrolldown") - { - CheckArgs(args); - ScrollCaller(args[1], false); - - } - else if (args[0].ToLower() == "moveto") - { - CheckArgs(args); - int[] xy = parser(args[1]); - MoveMouseTo(xy[0], xy[1]); - } - else if (args[0].ToLower() == "moveby") - { - CheckArgs(args); - int[] xy = parser(args[1]); - MoveMouseBy(xy[0], xy[1]); - } - else if (args[0].ToLower() == "dragto") - { - CheckArgs(args); - int[] xy = parser(args[1]); - DragMouseTo(xy[0], xy[1]); - } - else if (args[0].ToLower() == "dragby") - { - CheckArgs(args); - int[] xy = parser(args[1]); - DragMouseBy(xy[0], xy[1]); - } - else - { - Console.WriteLine("Invalid action : " + args[0]); - System.Environment.Exit(10); - } - } - - - } -} diff --git a/hybrids/.net/c/mouseSniffer.bat b/hybrids/.net/c/mouseSniffer.bat deleted file mode 100644 index 7db0523..0000000 --- a/hybrids/.net/c/mouseSniffer.bat +++ /dev/null @@ -1,301 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal -::del "%~n0.exe" /q -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using System.Threading; -//https://blogs.msdn.microsoft.com/toub/2006/05/03/low-level-mouse-hook-in-c/ - -namespace Purify -{ - class Program - { - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr FindWindow(string strClassName, string strWindowName); - [DllImport("user32.dll")] - public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle); - [DllImport("user32.dll")] - public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam); - [DllImport("kernel32.dll")] - static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode); - [DllImport("kernel32.dll")] - static extern bool GetConsoleMode(IntPtr hConsoleHandle, out int mode); - [DllImport("kernel32.dll")] - static extern IntPtr GetStdHandle(int handle); - [DllImport("kernel32.dll", SetLastError = true)] - private static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID); - [DllImport("kernel32.dll")] - private static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); - [DllImport("kernel32.dll")] - private static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe); - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern IntPtr SetWindowsHookEx(int idHook, - LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId); - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool UnhookWindowsHookEx(IntPtr hhk); - [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, - IntPtr wParam, IntPtr lParam); - [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] - private static extern IntPtr GetModuleHandle(string lpModuleName); - - public struct Rect - { - public int Left { get; set; } - public int Top { get; set; } - public int Right { get; set; } - public int Bottom { get; set; } - } - - public static Process ParentProcess(Process process) - { - int parentPid = 0; - int processPid = process.Id; - uint TH32CS_SNAPPROCESS = 2; - - // Take snapshot of processes - IntPtr hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - - if (hSnapshot == IntPtr.Zero) - { - return null; - } - - PROCESSENTRY32 procInfo = new PROCESSENTRY32(); - procInfo.dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32)); - // Read first - if (Process32First(hSnapshot, ref procInfo) == false) - { - return null; - } - // Loop through the snapshot - do - { - // If it's me, then ask for my parent. - if (processPid == procInfo.th32ProcessID) - { - parentPid = (int)procInfo.th32ParentProcessID; - } - } - while (parentPid == 0 && Process32Next(hSnapshot, ref procInfo)); // Read next - - if (parentPid > 0) - { - return Process.GetProcessById(parentPid); - } - else - { - return null; - } - } - - [StructLayout(LayoutKind.Sequential)] - private struct PROCESSENTRY32 - { - public uint dwSize; - public uint cntUsage; - public uint th32ProcessID; - public IntPtr th32DefaultHeapID; - public uint th32ModuleID; - public uint cntThreads; - public uint th32ParentProcessID; - public int pcPriClassBase; - public uint dwFlags; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] - public string szExeFile; - } - - static int top = 0; - static int bottom = 0; - static int right = 0; - static int left = 0; - - static void Main(string[] args) - { - disableQuickEdit(); - if (args.Length == 0) { - printHelp(); - Environment.Exit(0); - } - - if (args[0].ToLower() == "-h" || args[0].ToLower() == "-hlep") - { - printHelp(); - Environment.Exit(0); - } - - int seconds = -1; - try - { - seconds = int.Parse(args[0]); - } - catch (Exception e) { - Console.WriteLine("Error while parsing number : "+args[0]); - Environment.Exit(1); - } - - if (seconds > -1) - { - Sleeper sl = new Sleeper(seconds*1000); - Thread thr = new Thread(new ThreadStart(sl.sleep)); - thr.Start(); - } - - - _hookID = SetHook(_proc); - Application.Run(); - UnhookWindowsHookEx(_hookID); - Console.ReadKey(); - } - - static void printHelp() { - //clears the extension from the script name - String scriptName = Environment.GetCommandLineArgs()[0]; - scriptName = scriptName.Substring(0, scriptName.Length - 4); - - Console.WriteLine(scriptName + " sniffs the mouse and prints the left click coordinates, time stamp and if the click was inside the console"); - Console.WriteLine("Usage:"); - Console.WriteLine(""); - Console.WriteLine(scriptName + " [seconds to watch]"); - Console.WriteLine("If seconds are -1 will watch forvever"); - } - - class Sleeper - { - int sleepMs = 0; - public Sleeper(int ms) - { - sleepMs = ms; - } - public void sleep() - { - Thread.Sleep(this.sleepMs); - Environment.Exit(0); - } - } - static LowLevelMouseProc _proc = HookCallback; - static IntPtr _hookID = IntPtr.Zero; - static IntPtr SetHook(LowLevelMouseProc proc) - { - using (Process curProcess = Process.GetCurrentProcess()) - using (ProcessModule curModule = curProcess.MainModule) - { - return SetWindowsHookEx(WH_MOUSE_LL, proc, - GetModuleHandle(curModule.ModuleName), 0); - } - } - delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam); - private static IntPtr HookCallback( - int nCode, IntPtr wParam, IntPtr lParam) - { - if (nCode >= 0 && - MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam) - { - MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); - bool inside = false; - getProcRect(); - - if (hookStruct.pt.x > left && hookStruct.pt.x < right && - hookStruct.pt.y < bottom && hookStruct.pt.y > top) - { - - inside = true; - } - - - - Console.WriteLine("Click on: "+hookStruct.pt.x + ", " + hookStruct.pt.y + ";Time: " + hookStruct.time + ";Inside console: " + inside); - } - return CallNextHookEx(_hookID, nCode, wParam, lParam); - } - - private const int WH_MOUSE_LL = 14; - private enum MouseMessages - { - WM_LBUTTONDOWN = 0x0201, - WM_LBUTTONUP = 0x0202, - WM_MOUSEMOVE = 0x0200, - WM_MOUSEWHEEL = 0x020A, - WM_RBUTTONDOWN = 0x0204, - WM_RBUTTONUP = 0x0205 - } - [StructLayout(LayoutKind.Sequential)] - private struct POINT - { - public int x; - public int y; - } - [StructLayout(LayoutKind.Sequential)] - private struct MSLLHOOKSTRUCT - { - public POINT pt; - public uint mouseData; - public uint flags; - public uint time; - public IntPtr dwExtraInfo; - } - - [StructLayout(LayoutKind.Sequential)] - private struct MOUSEINPUT - { - public int dx; - public int dy; - public uint mouseData; - public uint dwFlags; - public uint time; - public IntPtr dwExtraInfo; - } - - static void disableQuickEdit() - { - int STD_INPUT_HANDLE = -10; - int DISABLE_QUICK_EDIT_MODE = 0x0080; - IntPtr handle = GetStdHandle(STD_INPUT_HANDLE); - SetConsoleMode(handle, DISABLE_QUICK_EDIT_MODE); - } - - static Rect getProcRect() - { - Process me = Process.GetCurrentProcess(); - //Rect dims = getProcRect(me); - Process parent = ParentProcess(me); - //Console.WriteLine(parent.ProcessName); - IntPtr ptr = parent.MainWindowHandle; - Rect rect = new Rect(); - GetWindowRect(ptr, ref rect); - Console.WriteLine("Console window position:" +rect.Left + "-" + rect.Right + "-" + rect.Top + "-" + rect.Bottom); - - top = rect.Top; - bottom = rect.Bottom; - right = rect.Right; - left = rect.Left; - - return rect; - } - } -} diff --git a/hybrids/.net/c/quickEdit.bat b/hybrids/.net/c/quickEdit.bat deleted file mode 100644 index 47ce634..0000000 --- a/hybrids/.net/c/quickEdit.bat +++ /dev/null @@ -1,111 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - -using System; -using System.Runtime.InteropServices; - - -class QE -{ - //https://msdn.microsoft.com/en-us/library/windows/desktop/ms686033(v=vs.85).aspx - //http://stackoverflow.com/questions/6828450/console-application-with-selectable-text - - [DllImport("kernel32.dll")] - static extern bool SetConsoleMode(IntPtr hConsoleHandle, int mode); - [DllImport("kernel32.dll")] - static extern bool GetConsoleMode(IntPtr hConsoleHandle, out int mode); - [DllImport("kernel32.dll")] - static extern IntPtr GetStdHandle(int handle); - - const int STD_INPUT_HANDLE = -10; - const int ENABLE_QUICK_EDIT_MODE = 0x40 | 0x80; - const int DISABLE_QUICK_EDIT_MODE = 0x0080; - const int CHECK_QUICK_EDIT = 0x0040; - - static void printHelp() - { - //clears the extension from the script name - String scriptName = Environment.GetCommandLineArgs()[0]; - scriptName = scriptName.Substring(0, scriptName.Length-4); - Console.WriteLine(scriptName + " enables or disables quick edit mode"); - Console.WriteLine(""); - Console.WriteLine("Enable:"); - Console.WriteLine(" " + scriptName + " 1"); - Console.WriteLine("Disable:"); - Console.WriteLine(" " + scriptName + " 2"); - Console.WriteLine("Get State:"); - Console.WriteLine(" " + scriptName + " 3"); - } - - static void Main(string[] args) - { - if (args.Length != 1) { - printHelp(); - Environment.Exit(1); - } - if (args[0].ToLower() == "-h") { - printHelp(); - Environment.Exit(0); - } - int sw; - try - { - int mode; - IntPtr handle = GetStdHandle(STD_INPUT_HANDLE); - GetConsoleMode(handle, out mode); - sw = int.Parse(args[0]); - switch (sw) { - case 1: - //enable - SetConsoleMode(handle, mode|(ENABLE_QUICK_EDIT_MODE)); - break; - case 2: - //disable - SetConsoleMode(handle, mode &= ~CHECK_QUICK_EDIT); - break; - case 3: - // get state - if (mode == (mode | ENABLE_QUICK_EDIT_MODE)) - { - Console.WriteLine("enabled"); - } - else { - Console.WriteLine("disabled"); - } - break; - default: - Console.WriteLine("Invalid argument: "+args[0]); - Environment.Exit(10); - break; - } - - } - catch (Exception e) { - Console.WriteLine("Problem while parsing state " + args[0]); - Environment.Exit(5); - } - - } -} diff --git a/hybrids/.net/c/screenCapture.bat b/hybrids/.net/c/screenCapture.bat deleted file mode 100644 index d59beb7..0000000 --- a/hybrids/.net/c/screenCapture.bat +++ /dev/null @@ -1,275 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /r:"Microsoft.VisualBasic.dll" /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - -// reference -// https://gallery.technet.microsoft.com/scriptcenter/eeff544a-f690-4f6b-a586-11eea6fc5eb8 - -using System; -using System.Runtime.InteropServices; -using System.Drawing; -using System.Drawing.Imaging; -using System.Collections.Generic; -using Microsoft.VisualBasic; - - -/// Provides functions to capture the entire screen, or a particular window, and save it to a file. - -public class ScreenCapture -{ - - /// Creates an Image object containing a screen shot the active window - - public Image CaptureActiveWindow() - { - return CaptureWindow(User32.GetForegroundWindow()); - } - - /// Creates an Image object containing a screen shot of the entire desktop - - public Image CaptureScreen() - { - return CaptureWindow(User32.GetDesktopWindow()); - } - - /// Creates an Image object containing a screen shot of a specific window - - private Image CaptureWindow(IntPtr handle) - { - // get te hDC of the target window - IntPtr hdcSrc = User32.GetWindowDC(handle); - // get the size - User32.RECT windowRect = new User32.RECT(); - User32.GetWindowRect(handle, ref windowRect); - int width = windowRect.right - windowRect.left; - int height = windowRect.bottom - windowRect.top; - // create a device context we can copy to - IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc); - // create a bitmap we can copy it to, - // using GetDeviceCaps to get the width/height - IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc, width, height); - // select the bitmap object - IntPtr hOld = GDI32.SelectObject(hdcDest, hBitmap); - // bitblt over - GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, GDI32.SRCCOPY); - // restore selection - GDI32.SelectObject(hdcDest, hOld); - // clean up - GDI32.DeleteDC(hdcDest); - User32.ReleaseDC(handle, hdcSrc); - // get a .NET image object for it - Image img = Image.FromHbitmap(hBitmap); - // free up the Bitmap object - GDI32.DeleteObject(hBitmap); - return img; - } - - public void CaptureActiveWindowToFile(string filename, ImageFormat format) - { - Image img = CaptureActiveWindow(); - img.Save(filename, format); - } - - public void CaptureScreenToFile(string filename, ImageFormat format) - { - Image img = CaptureScreen(); - img.Save(filename, format); - } - - static bool fullscreen = true; - static String file = "screenshot.bmp"; - static System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Bmp; - static String windowTitle = ""; - - static void parseArguments() - { - String[] arguments = Environment.GetCommandLineArgs(); - if (arguments.Length == 1) - { - printHelp(); - Environment.Exit(0); - } - if (arguments[1].ToLower().Equals("/h") || arguments[1].ToLower().Equals("/help")) - { - printHelp(); - Environment.Exit(0); - } - - file = arguments[1]; - Dictionary formats = - new Dictionary(); - - formats.Add("bmp", System.Drawing.Imaging.ImageFormat.Bmp); - formats.Add("emf", System.Drawing.Imaging.ImageFormat.Emf); - formats.Add("exif", System.Drawing.Imaging.ImageFormat.Exif); - formats.Add("jpg", System.Drawing.Imaging.ImageFormat.Jpeg); - formats.Add("jpeg", System.Drawing.Imaging.ImageFormat.Jpeg); - formats.Add("gif", System.Drawing.Imaging.ImageFormat.Gif); - formats.Add("png", System.Drawing.Imaging.ImageFormat.Png); - formats.Add("tiff", System.Drawing.Imaging.ImageFormat.Tiff); - formats.Add("wmf", System.Drawing.Imaging.ImageFormat.Wmf); - - - String ext = ""; - if (file.LastIndexOf('.') > -1) - { - ext = file.ToLower().Substring(file.LastIndexOf('.') + 1, file.Length - file.LastIndexOf('.') - 1); - } - else - { - Console.WriteLine("Invalid file name - no extension"); - Environment.Exit(7); - } - - try - { - format = formats[ext]; - } - catch (Exception e) - { - Console.WriteLine("Probably wrong file format:" + ext); - Console.WriteLine(e.ToString()); - Environment.Exit(8); - } - - - if (arguments.Length > 2) - { - windowTitle = arguments[2]; - fullscreen = false; - } - - } - - static void printHelp() - { - //clears the extension from the script name - String scriptName = Environment.GetCommandLineArgs()[0]; - scriptName = scriptName.Substring(0, scriptName.Length); - Console.WriteLine(scriptName + " captures the screen or the active window and saves it to a file."); - Console.WriteLine(""); - Console.WriteLine("Usage:"); - Console.WriteLine(" " + scriptName + " filename [WindowTitle]"); - Console.WriteLine(""); - Console.WriteLine("filename - the file where the screen capture will be saved"); - Console.WriteLine(" allowed file extensions are - Bmp,Emf,Exif,Gif,Icon,Jpeg,Png,Tiff,Wmf."); - Console.WriteLine("WindowTitle - instead of capture whole screen you can point to a window "); - Console.WriteLine(" with a title which will put on focus and captuted."); - Console.WriteLine(" For WindowTitle you can pass only the first few characters."); - Console.WriteLine(" If don't want to change the current active window pass only \"\""); - } - - public static void Main() - { - User32.SetProcessDPIAware(); - - parseArguments(); - ScreenCapture sc = new ScreenCapture(); - if (!fullscreen && !windowTitle.Equals("")) - { - try - { - - Interaction.AppActivate(windowTitle); - Console.WriteLine("setting " + windowTitle + " on focus"); - } - catch (Exception e) - { - Console.WriteLine("Probably there's no window like " + windowTitle); - Console.WriteLine(e.ToString()); - Environment.Exit(9); - } - - - } - try - { - if (fullscreen) - { - Console.WriteLine("Taking a capture of the whole screen to " + file); - sc.CaptureScreenToFile(file, format); - } - else - { - Console.WriteLine("Taking a capture of the active window to " + file); - sc.CaptureActiveWindowToFile(file, format); - } - } - catch (Exception e) - { - Console.WriteLine("Check if file path is valid " + file); - Console.WriteLine(e.ToString()); - } - } - - /// Helper class containing Gdi32 API functions - - private class GDI32 - { - - public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter - [DllImport("gdi32.dll")] - public static extern bool BitBlt(IntPtr hObject, int nXDest, int nYDest, - int nWidth, int nHeight, IntPtr hObjectSource, - int nXSrc, int nYSrc, int dwRop); - [DllImport("gdi32.dll")] - public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC, int nWidth, - int nHeight); - [DllImport("gdi32.dll")] - public static extern IntPtr CreateCompatibleDC(IntPtr hDC); - [DllImport("gdi32.dll")] - public static extern bool DeleteDC(IntPtr hDC); - [DllImport("gdi32.dll")] - public static extern bool DeleteObject(IntPtr hObject); - [DllImport("gdi32.dll")] - public static extern IntPtr SelectObject(IntPtr hDC, IntPtr hObject); - } - - - /// Helper class containing User32 API functions - - private class User32 - { - [StructLayout(LayoutKind.Sequential)] - public struct RECT - { - public int left; - public int top; - public int right; - public int bottom; - } - [DllImport("user32.dll")] - public static extern IntPtr GetDesktopWindow(); - [DllImport("user32.dll")] - public static extern IntPtr GetWindowDC(IntPtr hWnd); - [DllImport("user32.dll")] - public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC); - [DllImport("user32.dll")] - public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect); - [DllImport("user32.dll")] - public static extern IntPtr GetForegroundWindow(); - [DllImport("user32.dll")] - public static extern int SetProcessDPIAware(); - } -} diff --git a/hybrids/.net/c/taskbarHidder.bat b/hybrids/.net/c/taskbarHidder.bat deleted file mode 100644 index 7eeaacc..0000000 --- a/hybrids/.net/c/taskbarHidder.bat +++ /dev/null @@ -1,150 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal - -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - -// Credit: https://stackoverflow.com/a/19024531/388389 -using System; -using System.Runtime.InteropServices; - -public class Taskbar -{ - [DllImport("user32.dll")] - private static extern int FindWindow(string className, string windowText); - - [DllImport("user32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - static extern bool IsWindowVisible(IntPtr hWnd); - - [DllImport("user32.dll")] - private static extern int ShowWindow(int hwnd, int command); - - [DllImport("user32.dll")] - public static extern int FindWindowEx(int parentHandle, int childAfter, string className, int windowTitle); - - [DllImport("user32.dll")] - private static extern int GetDesktopWindow(); - - private const int SW_HIDE = 0; - private const int SW_SHOW = 1; - - protected static int Handle - { - get - { - return FindWindow("Shell_TrayWnd", ""); - } - } - - protected static int HandleOfStartButton - { - get - { - int handleOfDesktop = GetDesktopWindow(); - int handleOfStartButton = FindWindowEx(handleOfDesktop, 0, "button", 0); - return handleOfStartButton; - } - } - - private Taskbar() - { - // hide ctor - } - - public static void Show() - { - ShowWindow(Handle, SW_SHOW); - ShowWindow(HandleOfStartButton, SW_SHOW); - } - - public static void Hide() - { - ShowWindow(Handle, SW_HIDE); - ShowWindow(HandleOfStartButton, SW_HIDE); - } - - public static void GetStatus() - { - IntPtr xAsIntPtr = new IntPtr(Handle); - Console.WriteLine("TaskBar visible : " + IsWindowVisible(xAsIntPtr)); - xAsIntPtr = new IntPtr(HandleOfStartButton); - Console.WriteLine("StartButton visible : " + IsWindowVisible(xAsIntPtr)); - } - - static void printHelp() - { - //clears the extension from the script name - String scriptName = Environment.GetCommandLineArgs()[0]; - scriptName = scriptName.Substring(0, scriptName.Length-4); - Console.WriteLine(scriptName + " hides or shows the task bar"); - Console.WriteLine(""); - Console.WriteLine("Hide:"); - Console.WriteLine(" " + scriptName + " 1"); - Console.WriteLine("Show:"); - Console.WriteLine(" " + scriptName + " 2"); - Console.WriteLine("Get State:"); - Console.WriteLine(" " + scriptName + " 3"); - } - - static void Main(string[] args) - { - if (args.Length != 1) { - printHelp(); - Environment.Exit(1); - } - if (args[0].ToLower() == "-h") { - printHelp(); - Environment.Exit(0); - } - int sw; - try - { - int mode; - sw = int.Parse(args[0]); - switch (sw) { - case 1: - //hide - Taskbar.Hide(); - break; - case 2: - //show - Taskbar.Show(); - break; - case 3: - // get state - Taskbar.GetStatus(); - break; - default: - Console.WriteLine("Invalid argument: "+args[0]); - Environment.Exit(10); - break; - } - - } - catch (Exception e) { - Console.WriteLine("Problem while parsing state " + args[0]); - Environment.Exit(5); - } - - } -} diff --git a/hybrids/.net/c/windowMode.bat b/hybrids/.net/c/windowMode.bat deleted file mode 100644 index 8364ed8..0000000 --- a/hybrids/.net/c/windowMode.bat +++ /dev/null @@ -1,203 +0,0 @@ -// 2>nul||@goto :batch -/* -:batch -@echo off -setlocal -rem del /q /f "%~n0.exe" >nul 2>nul -:: find csc.exe -set "csc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do set "csc=%%#" - -if not exist "%csc%" ( - echo no .net framework installed - exit /b 10 -) - -if not exist "%~n0.exe" ( - call %csc% /nologo /warn:0 /out:"%~n0.exe" "%~dpsfnx0" || ( - exit /b %errorlevel% - ) -) -%~n0.exe %* -endlocal & exit /b %errorlevel% - -*/ - - -using System; -using System.Runtime.InteropServices; -using System.Diagnostics; -using System.Collections.Generic; - -class HadlerWrapper { - public System.IntPtr handler; - - public HadlerWrapper(System.IntPtr handler) { - this.handler = handler; - } -} - -public class ScreenCapture { - - static Int32 mode = 1; - static Dictionary < String, Int32 > modes = new Dictionary < String, Int32 > (); - - static String title = null; - static Int32 pid = -1; - - - - - - [DllImport("user32.dll")] - private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - - - public static void Main(String[] args) { - - modes.Add("hidden", 0); - modes.Add("normal", 1); - modes.Add("minimized", 2); - modes.Add("maximized", 3); - modes.Add("force_minimized", 11); - modes.Add("maximize_next", 6); - modes.Add("restore", 9); - modes.Add("show", 5); - modes.Add("show_default", 10); - modes.Add("no_active_minimized", 7); - modes.Add("no_active_show", 8); - modes.Add("no_active_normal", 4); - - - parseArgs(); - - if (!string.IsNullOrEmpty(title)) { - HadlerWrapper hw = windowByString(title); - if (hw != null) { - ShowWindowAsync(hw.handler, mode); - } else { - Console.WriteLine("Cannot find a window with title [" + title + "]"); - Environment.Exit(6); - } - } else if (pid != -1) { - HadlerWrapper hw = windowByPID(pid); - if (hw != null) { - ShowWindowAsync(hw.handler, mode); - } else { - Console.WriteLine("Cannot find a window with pid [" + pid + "]"); - Environment.Exit(7); - } - } else { - Console.WriteLine("Neither process id not title were passed to the script"); - printHelp(); - Environment.Exit(8); - } - - } - - static HadlerWrapper windowByString(String title) { - Process[] processlist = Process.GetProcesses(); - foreach(Process process in processlist) { - if (process.MainWindowTitle != null) { - if (process.MainWindowTitle.Equals(title)) { - return new HadlerWrapper(process.MainWindowHandle); - } - } - } - - foreach(Process process in processlist) { - if (!String.IsNullOrEmpty(process.MainWindowTitle)) { - if (process.MainWindowTitle.StartsWith(title)) { - return new HadlerWrapper(process.MainWindowHandle); - } - } - } - - return null; - } - - static HadlerWrapper windowByPID(Int32 pid) { - Process[] processlist = Process.GetProcesses(); - foreach(Process process in processlist) { - if (process.MainWindowHandle!= null) { - if (process.Id == pid) { - Console.WriteLine("process found with pid:" + pid); - return new HadlerWrapper(process.MainWindowHandle); - } - } else { - Console.WriteLine("main window handle is null for pid:" + pid); - } - } - return null; - } - - static void parseArgs() { - - String[] args = Environment.GetCommandLineArgs(); - if (args.Length == 1) { - printHelp(); - Environment.Exit(0); - } - if (args.Length % 2 == 0) { - Console.WriteLine("Wrong arguments"); - Environment.Exit(1); - } - for (int i = 1; i < args.Length - 1; i = i + 2) { - - switch (args[i].ToLower()) { - case "-help": - case "-h": - case "/h": - case "/help": - case "/?": - printHelp(); - Environment.Exit(5); - break; - case "-pid": - if (int.TryParse(args[i + 1], out pid)) {} else { - Console.WriteLine("Process id should be a number"); - Environment.Exit(2); - } - break; - case "-title": - title = args[i + 1]; - break; - case "-mode": - if (modes.TryGetValue(args[i + 1].ToLower(), out mode)) {} else { - Console.WriteLine("Invalid mode passed: " + args[i + 1]); - Environment.Exit(3); - } - break; - default: - Console.WriteLine("Wrong parameter " + args[i]); - Environment.Exit(4); - break; - - } - } - } - - public static void printHelp() { - String script = Environment.GetCommandLineArgs()[0]; - Console.WriteLine(script + " - changed the mode of a window by given process id or window title"); - Console.WriteLine(""); - Console.WriteLine("Usage:"); - Console.WriteLine(""); - Console.WriteLine(script + " {[-title \"Title\"]|[-pid PID_Number]} [-mode mode]"); - Console.WriteLine(""); - Console.WriteLine("Possible modes are hidden,normal,minimized,maximized,force_minimized,"); - Console.WriteLine(" force_minimized,maximize_next,restore,show,show_default,no_active_minimized,"); - Console.WriteLine(" no_active_show,no_active_normal."); - Console.WriteLine("If both title and pid are passed only the title will be taken into account"); - Console.WriteLine("If there's no title matching the given string a"); - Console.WriteLine(" title starting with it will be searched for"); - Console.WriteLine(""); - Console.WriteLine("Examples:"); - Console.WriteLine(""); - Console.WriteLine(" " + script + " -title \"Untitled - Notepad\" -mode normal"); - Console.WriteLine(" " + script + " -title \"Untitled\" -mode normal"); - Console.WriteLine(" " + script + " -pid 1313 -mode normal"); - - } - -} diff --git a/hybrids/.net/checkPortJS.bat b/hybrids/.net/checkPortJS.bat deleted file mode 100644 index 159313a..0000000 --- a/hybrids/.net/checkPortJS.bat +++ /dev/null @@ -1,44 +0,0 @@ -@if (@X)==(@Y) @end /* - @echo off - setlocal - del %~n0.exe /q /s >nul 2>nul - for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" - ) - if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" - ) - %~n0.exe %* - ::del /q /f %~n0.exe 1>nul 2>nul - endlocal & exit /b %errorlevel% -*/ - -import System; -import System.Net.Sockets; - -var arguments:String[] = Environment.GetCommandLineArgs(); -if (arguments.length<3){ - Console.WriteLine("not enough arguments"); - Environment.Exit(1); -} - -var host=arguments[1]; -try { - var port=Int32.Parse(arguments[2]); -} catch (err) { - Console.WriteLine("Cannot convert " + arguments[1] + " to number"); - Environment.Exit(2); -} - -Console.WriteLine("Checking host {0} and port {1}",host,port); - -var client = new TcpClient(); - -try { - client.Connect(host, port); -} catch(err) { - Console.WriteLine("Closed"); - Environment.Exit(0); -} -client.Close(); -Console.WriteLine("Open"); diff --git a/hybrids/.net/colorInput.bat b/hybrids/.net/colorInput.bat deleted file mode 100644 index 75bbdc4..0000000 --- a/hybrids/.net/colorInput.bat +++ /dev/null @@ -1,134 +0,0 @@ - -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -%~n0.exe %* - -endlocal & exit /b %errorlevel% - - -*/ -import System; -import System.IO; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -var foregroundColor = Console.ForegroundColor; -var backgroundColor = Console.BackgroundColor; - -var currentBackground=Console.BackgroundColor; -var currentForeground=Console.ForegroundColor; -var promptString:String=""; -var outFile=""; - -function printHelp( ) { - print( arguments[0] + " [-f foreground] [-b background] [-p prompt string] [-o out file]" ); - - print( " foreground Foreground color - a " ); - print( " number between 0 and 15." ); - print( " background Background color - a " ); - print( " number between 0 and 15." ); - print( "Colors :" ); - for ( var c = 0 ; c < 16 ; c++ ) { - - Console.BackgroundColor = c; - Console.Write( " " ); - Console.BackgroundColor=currentBackground; - Console.Write( "-"+c ); - Console.WriteLine( "" ); - } - Console.BackgroundColor=currentBackground; -} - -function errorChecker( e:Error ) { - if ( e.message == "Input string was not in a correct format." ) { - print( "the color parameters should be numbers between 0 and 15" ); - Environment.Exit( 1 ); - } else if (e.message == "Index was outside the bounds of the array.") { - print( "invalid arguments" ); - Environment.Exit( 2 ); - } else { - print ( "Error Message: " + e.message ); - print ( "Error Code: " + ( e.number & 0xFFFF ) ); - print ( "Error Name: " + e.name ); - Environment.Exit( 666 ); - } -} - -function numberChecker( i:Int32 ){ - if( i > 15 || i < 0 ) { - print("the color parameters should be numbers between 0 and 15"); - Environment.Exit(1); - } -} - - -function parseArgs(){ - if ( arguments.length == 1 || arguments[1].toLowerCase() == "-help" || arguments[1].toLowerCase() == "-help" ) { - printHelp(); - Environment.Exit(0); - } - - for (var i=1;i= 20 && (key.KeyChar.ToString().charCodeAt(0) <= 126) ) { - input=input+(key.KeyChar.ToString()); - Console.Error.Write(key.KeyChar.ToString()); - } -} while (key.Key != ConsoleKey.Enter); -Console.Error.WriteLine(); -Console.BackgroundColor = currentBackground; -Console.ForegroundColor = currentForeground; - -try { - if (outFile != ""){ - File.WriteAllText(outFile , input); - } -}catch(e){ - errorChecker(e); -} diff --git a/hybrids/.net/coloroutput.bat b/hybrids/.net/coloroutput.bat deleted file mode 100644 index 941e908..0000000 --- a/hybrids/.net/coloroutput.bat +++ /dev/null @@ -1,169 +0,0 @@ - -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -%~n0.exe %* - -endlocal & exit /b %errorlevel% - - -by Vasil "npocmaka" Arnaudov -most recent version can be found here -https://github.com/npocmaka/batch.scripts/edit/master/hybrids/.net/coloroutput.bat - -*/ - -import System; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -var newLine = false; -var output = ""; -var foregroundColor = Console.ForegroundColor; -var backgroundColor = Console.BackgroundColor; -var evaluate = false; -var currentBackground=Console.BackgroundColor; -var currentForeground=Console.ForegroundColor; - - -//http://stackoverflow.com/a/24294348/388389 -var jsEscapes = { - 'n': '\n', - 'r': '\r', - 't': '\t', - 'f': '\f', - 'v': '\v', - 'b': '\b' -}; - -function decodeJsEscape(_, hex0, hex1, octal, other) { - var hex = hex0 || hex1; - if (hex) { return String.fromCharCode(parseInt(hex, 16)); } - if (octal) { return String.fromCharCode(parseInt(octal, 8)); } - return jsEscapes[other] || other; -} - -function decodeJsString(s) { - return s.replace( - // Matches an escape sequence with UTF-16 in group 1, single byte hex in group 2, - // octal in group 3, and arbitrary other single-character escapes in group 4. - /\\(?:u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([0-3][0-7]{0,2}|[4-7][0-7]?)|(.))/g, - decodeJsEscape); -} - - -function printHelp( ) { - print( arguments[0] + " -s string [-f foreground] [-b background] [-n] [-e]" ); - print( " " ); - print( " string String to be printed" ); - print( " foreground Foreground color - a " ); - print( " number between 0 and 15." ); - print( " background Background color - a " ); - print( " number between 0 and 15." ); - print( " -n Indicates if a new line should" ); - print( " be written at the end of the "); - print( " string(by default - no)." ); - print( " -e Evaluates special character " ); - print( " sequences like \\n\\b\\r and etc "); - print( "" ); - print( "Colors :" ); - for ( var c = 0 ; c < 16 ; c++ ) { - - Console.BackgroundColor = c; - Console.Write( " " ); - Console.BackgroundColor=currentBackground; - Console.Write( "-"+c ); - Console.WriteLine( "" ); - } - Console.BackgroundColor=currentBackground; - - - -} - -function errorChecker( e:Error ) { - if ( e.message == "Input string was not in a correct format." ) { - print( "the color parameters should be numbers between 0 and 15" ); - Environment.Exit( 1 ); - } else if (e.message == "Index was outside the bounds of the array.") { - print( "invalid arguments" ); - Environment.Exit( 2 ); - } else { - print ( "Error Message: " + e.message ); - print ( "Error Code: " + ( e.number & 0xFFFF ) ); - print ( "Error Name: " + e.name ); - Environment.Exit( 666 ); - } -} - -function numberChecker( i:Int32 ){ - if( i > 15 || i < 0 ) { - print("the color parameters should be numbers between 0 and 15"); - Environment.Exit(1); - } -} - - -if ( arguments.length == 1 || arguments[1].toLowerCase() == "-help" || arguments[1].toLowerCase() == "-help" ) { - printHelp(); - Environment.Exit(0); -} - -for (var arg = 1; arg <= arguments.length-1; arg++ ) { - if ( arguments[arg].toLowerCase() == "-n" ) { - newLine=true; - } - - if ( arguments[arg].toLowerCase() == "-e" ) { - evaluate=true; - } - - if ( arguments[arg].toLowerCase() == "-s" ) { - output=arguments[arg+1]; - } - - - if ( arguments[arg].toLowerCase() == "-b" ) { - - try { - backgroundColor=Int32.Parse( arguments[arg+1] ); - } catch(e) { - errorChecker(e); - } - } - - if ( arguments[arg].toLowerCase() == "-f" ) { - try { - foregroundColor=Int32.Parse(arguments[arg+1]); - } catch(e) { - errorChecker(e); - } - } -} - -Console.BackgroundColor = backgroundColor ; -Console.ForegroundColor = foregroundColor ; - -if ( evaluate ) { - output=decodeJsString(output); -} - -if ( newLine ) { - Console.WriteLine(output); -} else { - Console.Write(output); - -} - -Console.BackgroundColor = currentBackground; -Console.ForegroundColor = currentForeground; - diff --git a/hybrids/.net/dirTimesNET.bat b/hybrids/.net/dirTimesNET.bat deleted file mode 100644 index 9ef84a7..0000000 --- a/hybrids/.net/dirTimesNET.bat +++ /dev/null @@ -1,88 +0,0 @@ -@if (@X)==(@Y) @end /****** silent line that start jscript comment ****** - -@echo off -:::::::::::::::::::::::::::::::::::: -::: compile the script :::: -:::::::::::::::::::::::::::::::::::: -setlocal -if exist "%~n0.exe" goto :skip_compilation - -setlocal - -:: find csc.exe -set "jsc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*jsc.exe") do set "jsc=%%#" - -if not exist "%jsc%" ( - echo no .net framework installed - exit /b 10 -) - -:break_loop - - -call %jsc% /nologo /out:"%~n0.exe" "%~f0" -:::::::::::::::::::::::::::::::::::: -::: end of compilation :::: -:::::::::::::::::::::::::::::::::::: -:skip_compilation - - - -for %%# in (/h /help -h -help) do ( - if "%~1" equ "%%#" ( - (echo() - echo %~nx0 - Displays LastModified,LastAccessed and DateCreated times of a given directory - echo in format YYYY-MM-DD hh:mm:ss , the thichs since 0:00:00 UTC on January 1, 0001 , day of the week - (echo() - echo example: - echo call %~nx0 C:\file.ext - ) -) - -if "%~1" equ "" ( - echo no directory passed - exit /b 1 -) - -if not exist "%~f1" ( - echo directory "%~f1" does not exist - exit /b 2 -) - -if exist "%~f1\" if not exist "%~f1" ( - echo "%~f1" is a file but not a directory - exit /b 3 -) - -(echo() -echo directory timestamps for %~f1 : -(echo() - - -"%~n0.exe" "%~f1" - -exit /b 0 - - -****** end of jscript comment ******/ -import System; -import System.IO; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -function printDateInfo(timeTag,dt){ - Console.WriteLine( timeTag + " : " + dt.ToString("yyyy-MM-dd hh:mm:ss")); - Console.WriteLine(timeTag + " thicks : " + dt.Ticks); - Console.WriteLine( timeTag + " day of the week : " + dt.DayOfWeek); - Console.WriteLine( timeTag + " day of the year : " + dt.DayOfYear); - Console.WriteLine(); -} - -var modified_date= Directory.GetLastWriteTime(Environment.GetCommandLineArgs()[1]); -var creation_date= Directory.GetCreationTime(Environment.GetCommandLineArgs()[1]); -var accessed_date= Directory.GetLastAccessTime(Environment.GetCommandLineArgs()[1]); - -printDateInfo("Modified",modified_date); -printDateInfo("Created",creation_date); -printDateInfo("Accessed",accessed_date); diff --git a/hybrids/.net/fileTimesNET.bat b/hybrids/.net/fileTimesNET.bat deleted file mode 100644 index 0de4261..0000000 --- a/hybrids/.net/fileTimesNET.bat +++ /dev/null @@ -1,87 +0,0 @@ -@if (@X)==(@Y) @end /****** silent line that start jscript comment ****** - -@echo off -:::::::::::::::::::::::::::::::::::: -::: compile the script :::: -:::::::::::::::::::::::::::::::::::: -setlocal -if exist "%~n0.exe" goto :skip_compilation - -setlocal - -:: find csc.exe -set "jsc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*jsc.exe") do set "jsc=%%#" - -if not exist "%jsc%" ( - echo no .net framework installed - exit /b 10 -) - -:break_loop - - -call %jsc% /nologo /out:"%~n0.exe" "%~f0" -:::::::::::::::::::::::::::::::::::: -::: end of compilation :::: -:::::::::::::::::::::::::::::::::::: -:skip_compilation - - - -for %%# in (/h /help -h -help) do ( - if "%~1" equ "%%#" ( - (echo() - echo %~nx0 - Displays LastModified,LastAccessed and DateCreated times of a given file - echo in format YYYY-MM-DD hh:mm:ss , the thichs since 0:00:00 UTC on January 1, 0001 , day of the week - (echo() - echo example: - echo call %~nx0 C:\file.ext - ) -) - -if "%~1" equ "" ( - echo no file passed - exit /b 1 -) - -if not exist "%~f1" ( - echo file "%~f1" does not exist - exit /b 2 -) - -if exist "%~f1\" ( - echo "%~f1" is a directory but not a file - exit /b 3 -) -(echo() -echo file timestamps for %~f1 : -(echo() - - -"%~n0.exe" "%~f1" - -exit /b 0 - - -****** end of jscript comment ******/ -import System; -import System.IO; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -function printDateInfo(timeTag,dt){ - Console.WriteLine( timeTag + " : " + dt.ToString("yyyy-MM-dd hh:mm:ss")); - Console.WriteLine(timeTag + " thicks : " + dt.Ticks); - Console.WriteLine( timeTag + " day of the week : " + dt.DayOfWeek); - Console.WriteLine( timeTag + " day of the year : " + dt.DayOfYear); - Console.WriteLine(); -} - -var modified_date= File.GetLastWriteTime(Environment.GetCommandLineArgs()[1]); -var creation_date= File.GetCreationTime(Environment.GetCommandLineArgs()[1]); -var accessed_date= File.GetLastAccessTime(Environment.GetCommandLineArgs()[1]); - -printDateInfo("Modified",modified_date); -printDateInfo("Created",creation_date); -printDateInfo("Accessed",accessed_date); diff --git a/hybrids/.net/getCmdPID.bat b/hybrids/.net/getCmdPID.bat deleted file mode 100644 index a8ac9cb..0000000 --- a/hybrids/.net/getCmdPID.bat +++ /dev/null @@ -1,39 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -%~n0.exe - -::pause -endlocal & exit /b %errorlevel% - -*/ - -//http://stackoverflow.com/questions/2531837/how-can-i-get-the-pid-of-the-parent-process-of-my-application -import System; -import System.Diagnostics; -import System.ComponentModel; -import System.Management; - -var myId = Process.GetCurrentProcess().Id; -var query = String.Format("SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {0}", myId); -var search = new ManagementObjectSearcher("root\\CIMV2", query); -var results = search.Get().GetEnumerator(); -if (!results.MoveNext()) { - Console.WriteLine("Error"); - Environment.Exit(-1); -} -var queryObj = results.Current; -var parentId = queryObj["ParentProcessId"]; -var parent = Process.GetProcessById(parentId); -Console.WriteLine(parent.Id); -Environment.Exit(parent.Id); diff --git a/hybrids/.net/gzipJS.bat b/hybrids/.net/gzipJS.bat deleted file mode 100644 index 692af2c..0000000 --- a/hybrids/.net/gzipJS.bat +++ /dev/null @@ -1,120 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" -) - - %~n0.exe %* - -endlocal & exit /b %errorlevel% - - -*/ - - -import System; -import System.Collections.Generic; -import System.IO; -import System.IO.Compression; - - - - function CompressFile(source,destination){ - var sourceFile=File.OpenRead(source); - var destinationFile=File.Create(destination); - var output = new GZipStream(destinationFile,CompressionMode.Compress); - Console.WriteLine("Compressing {0} to {1}.", sourceFile.Name,destinationFile.Name, false); - var byteR = sourceFile.ReadByte(); - while(byteR !=- 1){ - output.WriteByte(byteR); - byteR = sourceFile.ReadByte(); - } - sourceFile.Close(); - output.Flush(); - output.Close(); - destinationFile.Close(); - } - - function UncompressFile(source,destination){ - var sourceFile=File.OpenRead(source); - var destinationFile=File.Create(destination); - - var input = new GZipStream(sourceFile, - CompressionMode.Decompress, false); - Console.WriteLine("Decompressing {0} to {1}.", sourceFile.Name, - destinationFile.Name); - - var byteR=input.ReadByte(); - while(byteR !== -1){ - destinationFile.WriteByte(byteR); - byteR=input.ReadByte(); - } - destinationFile.Close(); - input.Close(); - - - } - - function isGzip(source,errorlevel){ - var sourceFile=File.OpenRead(source); - - var input = new GZipStream(sourceFile, - CompressionMode.Decompress, false); - var onSuccess; - try{ - onSuccess=Int32.Parse(errorlevel); - }catch(err){ - Console.WriteLine('Invalid Number passed'); - onSuccess=0; - } - try { - var b=input.ReadByte(); - input.Close(); - Console.WriteLine('valid'); - Environment.Exit(onSuccess); - }catch(err){ - Console.WriteLine('invalid'); - } - - } - -var arguments:String[] = Environment.GetCommandLineArgs(); - - function printHelp(){ - Console.WriteLine("Compress and uncompress gzip files:"); - Console.WriteLine("Compress:"); - Console.WriteLine(arguments[0]+" -c source destination"); - Console.WriteLine("Uncompress:"); - Console.WriteLine(arguments[0]+" -u source destination"); - Console.WriteLine("Check gzip file:"); - Console.WriteLine(arguments[0]+" -k source errorlevelOnSuccess"); - - } - -if (arguments.length!=4){ - Console.WriteLine("Wrong arguments"); - printHelp(); - Environment.Exit(1); -} - -switch (arguments[1]){ - case "-c": - CompressFile(arguments[2],arguments[3]); - break; - case "-u": - UncompressFile(arguments[2],arguments[3]); - break; - case "-k": - isGzip(arguments[2],arguments[3]); - break; - default: - Console.WriteLine("Wrong arguments"); - printHelp(); - Environment.Exit(1); -} diff --git a/hybrids/.net/keyStates.bat b/hybrids/.net/keyStates.bat deleted file mode 100644 index a8dee8f..0000000 --- a/hybrids/.net/keyStates.bat +++ /dev/null @@ -1,54 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -set "jsc=" -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*jsc.exe") do set "jsc=%%#" - -if not exist "%jsc%" ( - echo no .net framework installed - exit /b 10 -) - - -::if not exist "%~n0.exe" ( - call "%jsc%" /r:"System.Windows.Forms.dll" /nologo /out:"%~n0.exe" "%~dpsfnx0"||( - exit /b %errorlevel% - ) -::) - -"%~n0.exe" - -endlocal & exit /b %errorlevel% - -*/ - - import System; - import Accessibility; - import System.Windows.Forms; - import System.Drawing; - - var caps="CAPS LOCK : OFF"; - var num="NUM LOCK : OFF"; - var scroll="SCROLL LOCK : OFF" - - if (Control.IsKeyLocked(Keys.CapsLock)) { - caps="CAPS LOCK : ON"; - } - - if (Control.IsKeyLocked(Keys.NumLock)) { - caps="NUM LOCK : ON"; - } - - if (Control.IsKeyLocked(Keys.Scroll)) { - caps="SCROL LLOCK : ON"; - } - - - Console.WriteLine(caps); - Console.WriteLine(num); - Console.WriteLine(scroll); - - - - diff --git a/hybrids/.net/keyreader.bat b/hybrids/.net/keyreader.bat deleted file mode 100644 index a22d5bb..0000000 --- a/hybrids/.net/keyreader.bat +++ /dev/null @@ -1,92 +0,0 @@ -@if(@X) == (@Y) @end /* JScript comment -@echo off -:: reads a single key stroke and exits with its ascii code. -setlocal enableDelayedExpansion - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - rem del /q /f "%~n0.exe" >nul 2>&1 - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) -%~n0.exe %* -exit /b %errorlevel% - -*/ - -//http://stackoverflow.com/questions/57615/how-to-add-a-timeout-to-console-readline -import System; -import System.Threading; - - -class Reader { - static var inputThread; - static var getInput, gotInput; - static var input; - - function Reader() { - getInput = new AutoResetEvent(false); - gotInput = new AutoResetEvent(false); - inputThread = new Thread(ThreadStart(Reader.reader)); - inputThread.IsBackground = true; - inputThread.Start(); - } - - static function reader() { - while (true) { - try { - getInput.WaitOne(); - input = Console.ReadKey(); - gotInput.Set(); - } catch (err) { - var key = Console.Read(); - Environment.Exit(key); - } - } - } - - function ReadKey(timeOutMillisecs: int) { - getInput.Set(); - var success = gotInput.WaitOne(timeOutMillisecs); - if (success) { - Environment.Exit(input.KeyChar.ToString().charCodeAt(0)); - } else { - Environment.Exit(-2); - } - } -} - -var arguments: String[] = Environment.GetCommandLineArgs(); -if (arguments.length == 1) { - try { - var key = Console.ReadKey(true); - Environment.Exit(key.KeyChar.ToString().charCodeAt(0)); - } catch (err) { - var key = Console.Read(); - Environment.Exit(key); - } -} else { - if (arguments[1] == "/?" || arguments[1].toLowerCase().ToLower().Contains("help")) { - print("Usage:"); - print(" " + arguments[0] + " [timeout-in-milliseconds]"); - print(" reads a key and exits with its ascii code"); - print(" if a timeout is passed it will wait for input and if no key is pressed it will return -2"); - } else { - try { - var to = Int32.Parse(arguments[1]); - var rdr = new Reader(); - rdr.ReadKey(to); - } catch (err) { - try { - print("no valid number passed as timeout"); - var key = Console.ReadKey(true); - Environment.Exit(key.KeyChar.ToString().charCodeAt(0)); - } catch (err) { - var key = Console.Read(); - Environment.Exit(key); - } - } - } -} diff --git a/hybrids/.net/listEncodings.bat b/hybrids/.net/listEncodings.bat deleted file mode 100644 index 5260c29..0000000 --- a/hybrids/.net/listEncodings.bat +++ /dev/null @@ -1,64 +0,0 @@ -@if (@X)==(@Y) @end /****** jscript comment ****** - -@echo off -:::::::::::::::::::::::::::::::::::: -::: compile the script :::: -:::::::::::::::::::::::::::::::::::: -setlocal - -if exist "%~n0.exe" goto :skip_compilation - -:: searching the latest installed .net framework -for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do ( - if exist "%%v\jsc.exe" ( - rem :: the javascript.net compiler - set "jsc=%%~dpsnfxv\jsc.exe" - goto :break_loop - ) -) -echo jsc.exe not found && exit /b 0 -:break_loop - - -call %jsc% /nologo /out:"%~n0.exe" "%~nx0" -:::::::::::::::::::::::::::::::::::: -::: end of compilation :::: -:::::::::::::::::::::::::::::::::::: -:skip_compilation - -:: -:::::::::: -"%~n0.exe" -:::::::: -:: - -exit /b 0 - -## http://msdn.microsoft.com/en-us/library/system.text.encoding.getencodings.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2 -## -****** end of jscript comment ******/ - -import System; -import System.Text; - -Console.Write( "CodePage identifier and name " ); -Console.Write( "BrDisp BrSave " ); -Console.Write( "MNDisp MNSave " ); -Console.WriteLine( "1-Byte ReadOnly " ); - -var ei= new Object(); -var encs=new Enumerator(Encoding.GetEncodings()); - -while(!encs.atEnd()) { - var enc=encs.item(); - var e=enc.GetEncoding(); - - Console.Write( "{0,-6} {1,-25} ", enc.CodePage, enc.Name ); - Console.Write( "{0,-8} {1,-8} ", e.IsBrowserDisplay, e.IsBrowserSave ); - Console.Write( "{0,-8} {1,-8} ", e.IsMailNewsDisplay, e.IsMailNewsSave ); - Console.WriteLine( "{0,-8} {1,-8} ", e.IsSingleByte, e.IsReadOnly ); - - encs.moveNext(); -} - - diff --git a/hybrids/.net/msbuild/checkPort.bat b/hybrids/.net/msbuild/checkPort.bat deleted file mode 100644 index 5904729..0000000 --- a/hybrids/.net/msbuild/checkPort.bat +++ /dev/null @@ -1,74 +0,0 @@ - - - - - <_/> - - - - - - - - - - - diff --git a/hybrids/.net/passHidder.bat b/hybrids/.net/passHidder.bat deleted file mode 100644 index 49005e3..0000000 --- a/hybrids/.net/passHidder.bat +++ /dev/null @@ -1,50 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal enableDelayedExpansion - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -for /f "tokens=* delims=" %%p in ('"%~n0.exe"') do ( - set "pass=%%p" -) - -echo your password is !pass! - -endlocal & exit /b %errorlevel% - -*/ - - - -import System; - - - -var pwd = ""; -var key; - -Console.Error.Write("Enter password: "); - - do { - key = Console.ReadKey(true); - - if ( (key.KeyChar.ToString().charCodeAt(0)) >= 20 && (key.KeyChar.ToString().charCodeAt(0) <= 126) ) { - pwd=pwd+(key.KeyChar.ToString()); - Console.Error.Write("*"); - } - - if ( key.Key == ConsoleKey.Backspace && pwd.Length > 0 ) { - pwd=pwd.Remove(pwd.Length-1); - Console.Error.Write("\b \b"); - } - - - } while (key.Key != ConsoleKey.Enter); - Console.Error.WriteLine(); - Console.WriteLine(pwd); diff --git a/hybrids/.net/powershell/checkRemotePort.bat b/hybrids/.net/powershell/checkRemotePort.bat deleted file mode 100644 index 0416272..0000000 --- a/hybrids/.net/powershell/checkRemotePort.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off -setlocal -for %%h in (/h /help -help -h "") do ( - if /I "%~1" equ "%%~h" ( - goto :printHelp - ) - ) - - if "%~2" equ "" goto :printHelp - - set "HOST=%~1" - set /a PORT=%~2 - -set "host=google.com" -set /a port=443 - -for /f %%a in ('powershell "$t = New-Object Net.Sockets.TcpClient;try{$t.Connect("""%HOST%""", %PORT%)}catch{};$t.Connected"') do set "open=%%a" - -if "%open%" equ "true" ( - echo open - endlocal & exit /b 0 -) else ( - echo closed - endlocal & exit /b 1 -) - - -:printHelp - echo Checks if port is open on a remote server - echo( - echo Usage: - echo %~nx0 host port - echo( - echo If the port is not accessible an errorlevel 1 is set - endlocal & exit /b 0 diff --git a/hybrids/.net/powershell/enterNumber.bat b/hybrids/.net/powershell/enterNumber.bat deleted file mode 100644 index c63c788..0000000 --- a/hybrids/.net/powershell/enterNumber.bat +++ /dev/null @@ -1,21 +0,0 @@ -<# : batch portion -@echo off & setlocal - - for /f "tokens=*" %%a in ('powershell -noprofile "iex (${%~f0} | out-string)"') do set "number=%%a" - echo you've entered %number% - -endlocal -goto :EOF - -: end batch / begin powershell #> - -do { - [Console]::Error.Write("Enter a number:") - $inputString = read-host - $value = $inputString -as [Double] - $ok = $value -ne $NULL - if ( -not $ok ) {[Console]::Error.WriteLine("You must enter a numeric value") } -} -until ( $ok ) - -write-host "$value" diff --git a/hybrids/.net/selectFolder.bat b/hybrids/.net/selectFolder.bat deleted file mode 100644 index ec238c7..0000000 --- a/hybrids/.net/selectFolder.bat +++ /dev/null @@ -1,35 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off - -:: FolderSelectorJS.bat -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -for /f "tokens=* delims=" %%p in ('"%~n0.exe"') do ( - set "folder=%%p" -) -if not "%folder%" == "" ( - echo selected folder is %folder% -) - -endlocal & exit /b %errorlevel% - -*/ - -import System; -import System.Windows.Forms; - -var f=new FolderBrowserDialog(); -f.SelectedPath=System.Environment.CurrentDirectory; -f.Description="Please choose a folder."; -f.ShowNewFolderButton=true; -if( f.ShowDialog() == DialogResult.OK ){ - Console.Write(f.SelectedPath); -} diff --git a/hybrids/.net/setPrio.bat b/hybrids/.net/setPrio.bat deleted file mode 100644 index fbd99e3..0000000 --- a/hybrids/.net/setPrio.bat +++ /dev/null @@ -1,81 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off - -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -"%~n0.exe" %* -del "%~n0.exe" - -endlocal & exit /b %errorlevel% - -end of jscript comment*/ - -import System; -import System.Threading; -import System.Diagnostics; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -function printHelp( ) { - print(arguments[0] + " pid prio"); - -} - -if ( arguments.length == 1 || arguments[1].toLowerCase() == "-h" || arguments[1].toLowerCase() == "-help" ) { - printHelp(); - Environment.Exit(0); -} - -if ( arguments.length != 3) { - print("wrong number of arguments"); - Environment.Exit(1); -} - -try { - var pid= Int32.Parse(arguments[1]); -}catch(err){ - print("process must be a number"); - Environment.Exit(2); -} - -var prio=arguments[2].toLowerCase(); -var proc=""; -try{ - proc=Process.GetProcessById(pid); -}catch(err){ - print("process " + pid + " not found"); - Environment.Exit(3); -} - -switch(prio) { - case "abovenormal": - proc.PriorityClass = ProcessPriorityClass.AboveNormal; - break; - case "belownormal": - proc.PriorityClass = ProcessPriorityClass.AboveNormal; - break; - case "high": - proc.PriorityClass = ProcessPriorityClass.High; - break; - case "idle": - proc.PriorityClass = ProcessPriorityClass.Idle; - break; - case "normal": - proc.PriorityClass = ProcessPriorityClass.Normal; - break; - case "realTime": - proc.PriorityClass = ProcessPriorityClass.RealTime; - break; - default: - print("invalid prio: " + prio + " given"); - Environment.Exit(5); -} - diff --git a/hybrids/.net/split.net.bat b/hybrids/.net/split.net.bat deleted file mode 100644 index 2cfcb1a..0000000 --- a/hybrids/.net/split.net.bat +++ /dev/null @@ -1,72 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - - %~n0.exe %* - -endlocal & exit /b %errorlevel% - -*/ - -import System; -import System.IO; - -var arguments:String[] = Environment.GetCommandLineArgs(); - -if (arguments.length<3){ - Console.WriteLine("Wrong arguments"); - Console.WriteLine("usage:"); - Console.WriteLine(arguments[0]+"file_to_split size_in_bytes"); - Environment.Exit(1); -} - -var file=arguments[1]; -var max_size=parseInt(arguments[2]); - -if (max_size<=0){ - Console.WriteLine("size must be bigger than zero"); - Environment.Exit(2); -} - -if (!File.Exists(file)){ - Console.WriteLine("file"+file+" does not exist"); - Environment.Exit(3); -} - -function writeData(file,data:byte[]){ - Console.WriteLine(data.Length); - var writer = new BinaryWriter(File.Open(file, FileMode.Create)); - writer.Write(data); - writer.Close(); -} - -function chunker(inputFile, chunkSize){ - - var part=0; - var reader= new BinaryReader(File.Open(inputFile, FileMode.Open)); - var data:byte[]=reader.ReadBytes(chunkSize); - - while(reader.BaseStream.Position !== reader.BaseStream.Length) { - part++; - Console.WriteLine("Processing part " + part); - writeData(inputFile+".part."+part,data); - data=reader.ReadBytes(chunkSize); - - } - if (data.Length !== 0) { - part++; - Console.WriteLine("Processing part " + part) - writeData(inputFile+".part."+part,data); - } - reader.Close(); -} - -chunker(file,max_size); diff --git a/hybrids/.net/systemSounds.bat b/hybrids/.net/systemSounds.bat deleted file mode 100644 index ef015dd..0000000 --- a/hybrids/.net/systemSounds.bat +++ /dev/null @@ -1,76 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off - -setlocal - -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" -) - -"%~n0.exe" %* - - -endlocal & exit /b %errorlevel% - -end oj jscript comment*/ - -import System; -import System.Media; -import System.Threading; - - -var arguments:String[] = Environment.GetCommandLineArgs(); - -function printHelp( ) { - print(arguments[0] + " [beep] [asterisk] [hand] [beep] [question]"); - -} - -if ( arguments.length == 1 || arguments[1].toLowerCase() == "-h" || arguments[1].toLowerCase() == "-help" ) { - printHelp(); - Environment.Exit(0); -} - - - -for (var arg = 1; arg <= arguments.length-1; arg++ ) { - - if ( arguments[arg].toLowerCase() == "beep" ) { - SystemSounds.Beep.Play(); - System.Threading.Thread.Sleep(300); - } - - if ( arguments[arg].toLowerCase() == "asterisk" ) { - SystemSounds.Asterisk.Play(); - System.Threading.Thread.Sleep(300); - } - - if ( arguments[arg].toLowerCase() == "exclamation" ) { - SystemSounds.Exclamation.Play(); - System.Threading.Thread.Sleep(300); - } - - if ( arguments[arg].toLowerCase() == "hand" ) { - SystemSounds.Hand.Play(); - System.Threading.Thread.Sleep(300); - } - - if ( arguments[arg].toLowerCase() == "question" ) { - SystemSounds.Question.Play(); - System.Threading.Thread.Sleep(300); - } - -} - - -/* -Asterisk -Beep -Exclamation -Hand -Question -*/ diff --git a/hybrids/.net/waitMS.bat b/hybrids/.net/waitMS.bat deleted file mode 100644 index 3b3de6f..0000000 --- a/hybrids/.net/waitMS.bat +++ /dev/null @@ -1,50 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off -setlocal -::del %~n0.exe /q /f -:: -:: For precision better call this like -:: call waitMS 500 -:: in order to skip compilation in case there's already built .exe -:: as without pointed extension first the .exe will be called due to the ordering in PATEXT variable -:: -:: -for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( - set "jsc=%%v" -) - -if not exist "%~n0.exe" ( - "%jsc%" /nologo /w:0 /out:"%~n0.exe" "%~dpsfnx0" -) - - -%~n0.exe %* - -endlocal & exit /b %errorlevel% - - -*/ - - -import System; -import System.Threading; - -var arguments:String[] = Environment.GetCommandLineArgs(); -function printHelp(){ - Console.WriteLine(arguments[0]+" N"); - Console.WriteLine(" N - milliseconds to wait"); - Environment.Exit(0); -} - -if(arguments.length<2){ - printHelp(); -} - -try{ - var wait:Int32=Int32.Parse(arguments[1]); - System.Threading.Thread.Sleep(wait); -}catch(err){ - Console.WriteLine('Invalid Number passed'); - Environment.Exit(1); -} - diff --git a/hybrids/iexpress/OKPopup.bat b/hybrids/iexpress/OKPopup.bat deleted file mode 100644 index ff98cda..0000000 --- a/hybrids/iexpress/OKPopup.bat +++ /dev/null @@ -1,62 +0,0 @@ -;@echo off -;setlocal - -;set ppopup_executable=popupe.exe -;set "message2=click OK to continue" -; -;del /q /f %tmp%\yes >nul 2>&1 -; -;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1 - -;(echo(FinishMessage=%message2%)>>"%temp%\popup.sed"; -;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed"; -;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed" -; -;iexpress /n /q /m %temp%\popup.sed -;%ppopup_executable% -;rem del /q /f %ppopup_executable% >nul 2>&1 - -;pause - -;endlocal -;exit /b 0 - - -[Version] -Class=IEXPRESS -SEDVersion=3 -[Options] -PackagePurpose=InstallApp -ShowInstallProgramWindow=1 -HideExtractAnimation=1 -UseLongFileName=0 -InsideCompressed=0 -CAB_FixedSize=0 -CAB_ResvCodeSigning=0 -RebootMode=N -InstallPrompt=%InstallPrompt% -DisplayLicense=%DisplayLicense% -FinishMessage=%FinishMessage% -TargetName=%TargetName% -FriendlyName=%FriendlyName% -AppLaunched=%AppLaunched% -PostInstallCmd=%PostInstallCmd% -AdminQuietInstCmd=%AdminQuietInstCmd% -UserQuietInstCmd=%UserQuietInstCmd% -SourceFiles=SourceFiles -[SourceFiles] -SourceFiles0=C:\Windows\System32\ -[SourceFiles0] -%FILE0%= - - -[Strings] -AppLaunched=subst.exe -PostInstallCmd= -AdminQuietInstCmd= -UserQuietInstCmd= -FILE0="subst.exe" -DisplayLicense= -InstallPrompt= - - diff --git a/hybrids/iexpress/bat2exeIEXP.bat b/hybrids/iexpress/bat2exeIEXP.bat deleted file mode 100644 index 71da3cb..0000000 --- a/hybrids/iexpress/bat2exeIEXP.bat +++ /dev/null @@ -1,59 +0,0 @@ - ;@echo off -; rem https://github.com/npocmaka/batch.scripts/edit/master/hybrids/iexpress/bat2exeIEXP.bat -;if "%~2" equ "" ( -; echo usage: %~nx0 batFile.bat target.Exe -;) -;set "target.exe=%__cd__%%~2" -;set "batch_file=%~f1" -;set "bat_name=%~nx1" -;set "bat_dir=%~dp1" - -;copy /y "%~f0" "%temp%\2exe.sed" >nul - -;(echo()>>"%temp%\2exe.sed" -;(echo(AppLaunched=cmd.exe /c "%bat_name%")>>"%temp%\2exe.sed" -;(echo(TargetName=%target.exe%)>>"%temp%\2exe.sed" -;(echo(FILE0="%bat_name%")>>"%temp%\2exe.sed" -;(echo([SourceFiles])>>"%temp%\2exe.sed" -;(echo(SourceFiles0=%bat_dir%)>>"%temp%\2exe.sed" -;(echo([SourceFiles0])>>"%temp%\2exe.sed" -;(echo(%%FILE0%%=)>>"%temp%\2exe.sed" - - -;iexpress /n /q /m %temp%\2exe.sed - -;rem del /q /f "%temp%\2exe.sed" -; exit /b 0 - -[Version] -Class=IEXPRESS -SEDVersion=3 -[Options] -PackagePurpose=InstallApp -ShowInstallProgramWindow=0 -HideExtractAnimation=1 -UseLongFileName=1 -InsideCompressed=0 -CAB_FixedSize=0 -CAB_ResvCodeSigning=0 -RebootMode=N -InstallPrompt=%InstallPrompt% -DisplayLicense=%DisplayLicense% -FinishMessage=%FinishMessage% -TargetName=%TargetName% -FriendlyName=%FriendlyName% -AppLaunched=%AppLaunched% -PostInstallCmd=%PostInstallCmd% -AdminQuietInstCmd=%AdminQuietInstCmd% -UserQuietInstCmd=%UserQuietInstCmd% -SourceFiles=SourceFiles - -[Strings] -InstallPrompt= -DisplayLicense= -FinishMessage= -FriendlyName=- -PostInstallCmd= -AdminQuietInstCmd= -UserQuietInstCmd= -; diff --git a/hybrids/iexpress/hidder.bat b/hybrids/iexpress/hidder.bat deleted file mode 100644 index ca6fc5f..0000000 --- a/hybrids/iexpress/hidder.bat +++ /dev/null @@ -1,70 +0,0 @@ -;:: uses AppLaunched and ShowInstallProgramWindow options in iexpress sed files -;:: to start a hidden process -;:: could require admin privileges -;::http://www.dostips.com/forum/viewtopic.php?f=3&t=5901 - - -;@echo off -;setlocal -; rem https://github.com/npocmaka/batch.scripts/edit/master/hybrids/iexpress/bat2exeIEXP.bat -;if "%~2" equ "" ( -; echo usage: %~nx0 batFile.bat target.Exe -;) -;set "target.exe=%__cd__%%~2" -;set "app_file=%~f1" -;set "app_name=%~nx1" -;set "app_dir=%~dp1" - -;copy /y "%~f0" "%temp%\2exe.sed" >nul - -;(echo()>>"%temp%\2exe.sed" -;if "%app_name:~-4%" equ ".bat" ( -;(echo(AppLaunched=cmd.exe /c "%app_name%")>>"%temp%\2exe.sed" -;) else ( -;echo(AppLaunched="%app_name%")>>"%temp%\2exe.sed" -;) -;(echo(TargetName=%target.exe%)>>"%temp%\2exe.sed" -;(echo(FILE0="%app_name%")>>"%temp%\2exe.sed" -;(echo([SourceFiles])>>"%temp%\2exe.sed" -;(echo(SourceFiles0=%app_dir%)>>"%temp%\2exe.sed" -;(echo([SourceFiles0])>>"%temp%\2exe.sed" -;(echo(%%FILE0%%=)>>"%temp%\2exe.sed" - - -;iexpress /n /q /m %temp%\2exe.sed - -;rem del /q /f "%temp%\2exe.sed" -; exit /b 0 - -[Version] -Class=IEXPRESS -SEDVersion=3 -[Options] -PackagePurpose=InstallApp -ShowInstallProgramWindow=1 -HideExtractAnimation=1 -UseLongFileName=1 -InsideCompressed=1 -CAB_FixedSize=0 -CAB_ResvCodeSigning=0 -RebootMode=N -InstallPrompt=%InstallPrompt% -DisplayLicense=%DisplayLicense% -FinishMessage=%FinishMessage% -TargetName=%TargetName% -FriendlyName=%FriendlyName% -AppLaunched=%AppLaunched% -PostInstallCmd=%PostInstallCmd% -AdminQuietInstCmd=%AdminQuietInstCmd% -UserQuietInstCmd=%UserQuietInstCmd% -SourceFiles=SourceFiles - -[Strings] -InstallPrompt= -DisplayLicense= -FinishMessage= -FriendlyName=- -PostInstallCmd= -AdminQuietInstCmd= -UserQuietInstCmd= -; diff --git a/hybrids/iexpress/iexpYNButton.bat b/hybrids/iexpress/iexpYNButton.bat deleted file mode 100644 index e07436c..0000000 --- a/hybrids/iexpress/iexpYNButton.bat +++ /dev/null @@ -1,86 +0,0 @@ -;@echo off -; -;::Creates an .exe file that produces a pop-up with yes/no buttoms -;:: the execution halts the script execution (unlike msg.exe) and prints the result of the user action -;:: has no 'toxic' output.Works on every machine since WindowsXP -;:: (ab)uses iexpress command line options - check read.me file -; -;setlocal -;:::::::::::::::: USER OPTIONS :::::::::::::::: -;:: -;:::: the message of in the pop-up body -;set "message1=yes/no" -;::::: title of the pop-up -;set "message1_title=Are you agree?" -;:::: name of the produced executable -;set ppopup_executable=popupe.exe -; -;::does not accept a command line options at the moment -;::may be in a later version -; -;:: -;::::::::::::::::: END OF CHANGABLE OPTIONS :::: -; -;del /q /f %tmp%\yes >nul 2>&1 -; -;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1 -;(echo(InstallPrompt=%message1%)>>"%temp%\popup.sed" -;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed"; -;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed" -; -;iexpress /n /q /m %temp%\popup.sed -;%ppopup_executable% -;del /q /f %ppopup_executable% >nul 2>&1 -;if exist "%tmp%\yes" (set ans=yes) else (set ans=no) -;echo %ans% -;pause -;rem del %ppopup_executable% -;endlocal -;exit /b 0 - - -[Version] -Class=IEXPRESS -SEDVersion=3 -[Options] -PackagePurpose=InstallApp -ShowInstallProgramWindow=1 -HideExtractAnimation=1 -UseLongFileName=0 -InsideCompressed=0 -CAB_FixedSize=0 -CAB_ResvCodeSigning=0 -RebootMode=N -InstallPrompt=%InstallPrompt% -DisplayLicense=%DisplayLicense% -FinishMessage=%FinishMessage% -TargetName=%TargetName% -FriendlyName=%FriendlyName% -AppLaunched=%AppLaunched% -PostInstallCmd=%PostInstallCmd% -AdminQuietInstCmd=%AdminQuietInstCmd% -UserQuietInstCmd=%UserQuietInstCmd% -SourceFiles=SourceFiles -[SourceFiles] -SourceFiles0=C:\Windows\System32\ -[SourceFiles0] -%FILE0%= - - -[Strings] -AppLaunched=cmd.exe /c "break>%tmp%\yes" -PostInstallCmd= -AdminQuietInstCmd= -UserQuietInstCmd= -FILE0="subst.exe" -DisplayLicense= -FinishMessage= - - -;InstallPrompt=messagee1 -;DisplayLicense=F:\scriptests\sysinf -;FinishMessage=message2 -;TargetName=F:\scriptests\popup1.exe -;FriendlyName=popuppkg -; - diff --git a/hybrids/iexpress/licenseAgreement.bat b/hybrids/iexpress/licenseAgreement.bat deleted file mode 100644 index 39af878..0000000 --- a/hybrids/iexpress/licenseAgreement.bat +++ /dev/null @@ -1,71 +0,0 @@ -;::Uses DisplayLicense option in express sed file -;:: It requires a path to the text file with the license agreement which will -;:: be built-in produced exe file and later can be deleted if -;:: the .exe will be reused - - -;@echo off -;setlocal - -;set "message1_title=Are you agree?" -;set "license_file=%windir%\win.ini" -;set ppopup_executable=popupe.exe - -; -;del /q /f %tmp%\yes >nul 2>&1 -; -;copy /y "%~f0" "%temp%\popup.sed" >nul 2>&1 -;(echo(DisplayLicense=%license_file%)>>"%temp%\popup.sed" -;(echo(TargetName=%cd%\%ppopup_executable%)>>"%temp%\popup.sed"; -;(echo(FriendlyName=%message1_title%)>>"%temp%\popup.sed" -; -;iexpress /n /q /m %temp%\popup.sed -;%ppopup_executable% -;del /q /f %ppopup_executable% >nul 2>&1 - -;if exist "%tmp%\yes" (set ans=yes) else (set ans=no) -;echo %ans% -;pause - -;endlocal -;exit /b 0 - - -[Version] -Class=IEXPRESS -SEDVersion=3 -[Options] -PackagePurpose=InstallApp -ShowInstallProgramWindow=1 -HideExtractAnimation=1 -UseLongFileName=0 -InsideCompressed=0 -CAB_FixedSize=0 -CAB_ResvCodeSigning=0 -RebootMode=N -InstallPrompt=%InstallPrompt% -DisplayLicense=%DisplayLicense% -FinishMessage=%FinishMessage% -TargetName=%TargetName% -FriendlyName=%FriendlyName% -AppLaunched=%AppLaunched% -PostInstallCmd=%PostInstallCmd% -AdminQuietInstCmd=%AdminQuietInstCmd% -UserQuietInstCmd=%UserQuietInstCmd% -SourceFiles=SourceFiles -[SourceFiles] -SourceFiles0=C:\Windows\System32\ -[SourceFiles0] -%FILE0%= - - -[Strings] -AppLaunched=cmd.exe /c "break>%tmp%\yes" -PostInstallCmd= -AdminQuietInstCmd= -UserQuietInstCmd= -FILE0="subst.exe" -InstallPrompt= -FinishMessage= - - diff --git a/hybrids/iexpress/read.me b/hybrids/iexpress/read.me deleted file mode 100644 index 89a29f8..0000000 --- a/hybrids/iexpress/read.me +++ /dev/null @@ -1,18 +0,0 @@ -IExpress is tool intended for self-extracting packages and is built-in every Winows system. -So scripts based on this are maximum possible compatible. -Despite its UI wizard it can be used also from command line if it's suplied with SED file - -basically an ini file.As ";" is a standard delimiter in batch files and is a remark for ini -files so makes makes IExpress perfect for hybridization with batch scripts. -It's options allows running a command in background,Yes/No pop-up,Licensce agreement message -and a single button pop-up (functionlity not possible with simple batch commands) - -In all examples here the script copies itself in %temp% directory as sed file , appends parametrized -inforrmation at the end and creates an exe with IExpress. -Iexpress requires an exe file to be executed at the end otherwise the it will not create .exe -but .cab file.So I've put there subst.exe from system32 - which executed without parameterswont do anything. -As the post install command won't touch the extracted elements they will be deleted by the created .exe file. - -The produced exe can be deleted or reused.Depends on the user needs. - -First published here: -http://www.dostips.com/forum/viewforum.php?f=3 diff --git a/hybrids/jscript/FileTimeFilterJS.bat b/hybrids/jscript/FileTimeFilterJS.bat deleted file mode 100644 index 3ccf885..0000000 --- a/hybrids/jscript/FileTimeFilterJS.bat +++ /dev/null @@ -1,251 +0,0 @@ -@if (@x)==(@y) @end /***** jscript comment ****** - @echo off - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - exit /b %errorlevel% - - @if (@x)==(@y) @end ****** end comment *********/ - -var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); - -var ARGS = WScript.Arguments; -var scriptName=ARGS.Item(0); - -//var arguments:String[] = Environment.GetCommandLineArgs(); - -var directory="."; -//var filter="creation"; -var max_date=(new Date()).getTime(); -var min_date=(new Date(0)).getTime(); - -var DD=0; -var hh=0; -var mm=0; -var ss=0; - -var recursive=true; -var show_dirs=false; -var show_files=true; -var direction="after"; - -//var show_files=true; -//var show_dirs=false; -var getFunct=getDateCreated; -function printHelp(){ - WScript.Echo(scriptName + " filters files/directories by date or time"); - WScript.Echo(""); - WScript.Echo("Usage:"); - WScript.Echo(scriptName + " directory [options]"); - WScript.Echo("Options:"); - WScript.Echo("-beginDate dd-MM-yy#hh:mm:ss -endDate dd-MM-yy#hh:mm:ss"); - WScript.Echo(" will show files/directories between the two dates.Date formats "); - WScript.Echo(" Short dates can use either a '/' or '-' date separator, but must follow the month/day/year format, for example '7/20/96'"); - WScript.Echo(" Long dates of the form 'July 10 1995' can be given with the year, month, and day in any order, and the year in 2-digit or 4-digit form. If you use the 2-digit form, the year must be greater than or equal to 70."); - WScript.Echo(" Any text inside parentheses is treated as a comment. These parentheses may be nested."); - WScript.Echo(" Both commas and spaces are treated as delimiters. Multiple delimiters are permitted."); - WScript.Echo(" Month and day names must have two or more characters. Two character names that are not unique are resolved as the last match. For example, 'Ju' is resolved as July, not June."); - WScript.Echo(" The stated day of the week is ignored if it is incorrect given the remainder of the supplied date. For example, 'Tuesday November 9 1996' is accepted and parsed even though that date actually falls on a Friday. The resulting Date object contains 'Friday November 9 1996'."); - WScript.Echo(" JScript handles all standard time zones, as well as Universal Coordinated Time (UTC) and Greenwich Mean Time (GMT)."); - WScript.Echo(" Hours, minutes, and seconds are separated by colons, although all need not be specified. '10:', '10:11', and '10:11:12' are all valid."); - WScript.Echo(" If the 24-hour clock is used, it is an error to specify 'PM' for times later than 12 noon. For example, '23:15 PM' is an error."); - WScript.Echo(" A string containing an invalid date is an error. For example, a string containing two years or two months is an error."); - WScript.Echo("-direction before|after "); - WScript.Echo(" will search for files/directories before or after given date.Default is after"); - WScript.Echo("-hh Number"); - WScript.Echo(" Will add/subtract(if number is negative) hours to given dates"); - WScript.Echo(" Default is 0"); - WScript.Echo("-mm Number"); - WScript.Echo(" Will add/subtract(if number is negative) minutes to given dates"); - WScript.Echo(" Default is 0"); - WScript.Echo("-dd Number"); - WScript.Echo(" Will add/subtract(if number is negative) days to given dates"); - WScript.Echo(" Default is 0"); - WScript.Echo("-ss Number"); - WScript.Echo(" Will add/subtract(if number is negative) seconds to given dates"); - WScript.Echo(" Default is 0"); - WScript.Echo("-recursive yes|no"); - WScript.Echo(" Will search be recursive or not"); - WScript.Echo(" Default is yes"); - WScript.Echo("-show dirs|files|all"); - WScript.Echo(" Will search files or directories"); - WScript.Echo(" Default is files"); - WScript.Echo(""); - WScript.Echo("-show dirs|files|all"); - WScript.Echo(" Will search files or directories by passed time property "); - WScript.Echo(" Default is files"); - WScript.Echo("-filetime created|accessed|modified"); - WScript.Echo(" Will compare dates by creation,modification or accessing time"); - WScript.Echo(" Default is created"); - WScript.Echo(""); - WScript.Echo("Examples:"); - WScript.Echo(""); - WScript.Echo("Will show files older than 5 hours"); - WScript.Echo(scriptName + ' "." -hh -5'); - WScript.Echo(""); - WScript.Echo("Will show files between the begin and end date"); - WScript.Echo(scriptName + ' "." -beginDate "September 1, 2014 10:15 AM" -endDate "November 1, 2014 10:15 PM" '); - WScript.Echo("Will show files newer than 5 hours starting from given date"); - WScript.Echo(scriptName + ' "." -hh 5 -beginDate -beginDate "September 1, 2014 10:15 AM"'); - WScript.Echo(""); - WScript.Echo("Will show files older than 5 hours starting from given date"); - WScript.Echo(scriptName + ' "." -hh 5 -beginDate -beginDate "September 1, 2014 10:15 AM" -direction before'); - WScript.Echo(""); - -} - - - - -function getLastModified(obj){ - return obj.DateLastModified; -} - -function getDateCreated(obj){ - return obj.DateCreated; -} - -function getLastAccessed(obj){ - return obj.DateLastAccessed; -} - -function check(enumObj,filterFunction){ - for (; !enumObj.atEnd(); enumObj.moveNext()){ - var dateObj=new Date(filterFunction(enumObj.item())); - if ((dateObj.getTime() <= max_date) && - (dateObj.getTime() >= min_date)){ - WScript.Echo(enumObj.item()); - } - } -} - -function parseDate(string){ - //https://msdn.microsoft.com/en-us/library/k4w173wk(v=vs.84).aspx - try { - return Date.parse(string); - } catch (err){ - WScript.Echo("Wrong date format"); - WScript.Echo(err.message); - WScript.Quit(4); - } -} - -function list(directory,filterFunction){ - var folder=FileSystemObj.GetFolder(directory); - if (show_files){ - var file_enum = new Enumerator(folder.files); - check(file_enum,filterFunction); - } - if (show_dirs){ - var folder_enum = new Enumerator(folder.SubFolders ); - check(folder_enum,filterFunction); - } - if(recursive){ - var folder_enum = new Enumerator(folder.SubFolders ); - for (;!folder_enum.atEnd(); folder_enum.moveNext()){ - list(folder_enum.item(),filterFunction); - } - } -} - -function parseArgs(){ - if (ARGS.length<2){ - WScript.Echo("Wrong arguments"); - printHelp(); - WScript.Quit(1); - } - - if (ARGS.Item(1) == "-h" || ARGS.Item(1) == "-help"){ - printHelp(); - } - - if (ARGS.length%2 != 0){ - WScript.Echo("Wrong number of arguments"); - printHelp(); - WScript.Quit(2); - } - - directory=ARGS.Item(1); - - for (var i=2;i max_date) { - min_date=min_date^max_date; - max_date=min_date^max_date; - min_date=min_date^max_date; -} - -list(directory,getFunct); diff --git a/hybrids/jscript/ShellRunJS.bat b/hybrids/jscript/ShellRunJS.bat deleted file mode 100644 index 02e48de..0000000 --- a/hybrids/jscript/ShellRunJS.bat +++ /dev/null @@ -1,87 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -var ARGS = WScript.Arguments; -var scriptName=ARGS.Item(0); -var command=0; -var style=1; -var wait=true; -var shell = new ActiveXObject("WScript.Shell"); - -function printHelp(){ - WScript.Echo(scriptName + " - WScript.Shell wrapper that can start process in certain mode"); - WScript.Echo("usage:"); - WScript.Echo(scriptName + " command [-style {0-10}] [-wait yes|no]"); - WScript.Echo("command - the command to execute"); - WScript.Echo("wait - to wait or not for command to finish.Default is yes"); - WScript.Echo("style - number of 1 to 10 that defines the window style of executed command"); - WScript.Echo(""); - WScript.Echo("Info about styles"); - WScript.Echo(""); - WScript.Echo("https://msdn.microsoft.com/en-us/library/d5fk67ky(v=vs.84).aspx"); - WScript.Echo(""); - WScript.Echo("0 - Hides the window and activates another window."); - WScript.Echo("1 - [Default]Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position.\r\n An application should specify this flag when displaying the window for the first time."); - WScript.Echo("2 - Activates the window and displays it as a minimized window."); - WScript.Echo("3 - Activates the window and displays it as a maximized window."); - WScript.Echo("4 - Displays a window in its most recent size and position. The active window remains active."); - WScript.Echo("5 - Activates the window and displays it in its current size and position."); - WScript.Echo("6 - Minimizes the specified window and activates the next top-level window in the Z order."); - WScript.Echo("7 - Displays the window as a minimized window. The active window remains active."); - WScript.Echo("8 - Displays the window in its current state. The active window remains active."); - WScript.Echo("9 - Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position.\r\n An application should specify this flag when restoring a minimized window."); - WScript.Echo("10 - Sets the show-state based on the state of the program that started the application."); - -} - -function parseArguments(){ - if (WScript.Arguments.Length==1 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(1); - } - - if (WScript.Arguments.Length % 2 == 1 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - command=ARGS.Item(1); - - for (var i=2;i10){ - WScript.Echo("style must be a number between 0 and 10"); - WScript.Quit(3); - } - -} - -parseArguments(); -shell.Run(command,style,wait); diff --git a/hybrids/jscript/UIautoLogin.bat b/hybrids/jscript/UIautoLogin.bat deleted file mode 100644 index ab1435c..0000000 --- a/hybrids/jscript/UIautoLogin.bat +++ /dev/null @@ -1,217 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - for /f "tokens=2" %%a in ("%cmdcmdline%") do set "switch=%%a" - - rem determine if the command is clicked or called from command line - if /i "%switch%" == "/c" ( - mode 15,1 - prompt #auto-login# - title #auto-login# - ) - - rem check if arguments are passed to the script - if "%~1" == "" ( - mode 15,1 - prompt #auto-login# - title #auto-login# - ) - - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - -// -// written by Vasil "npocmaka" Arnaudov -// - -//ActiveX objects -var sh=new ActiveXObject("WScript.Shell"); -var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); - -var ARGS = WScript.Arguments; -var scriptName=ARGS.Item(0); - -//variables -var user=""; -var pass=""; -var stopOnLogon=false; - - -var popupString={ - IE : "Windows Security", - FireFox : "Authentication Required" - // Opera and Chrome use pop-ups without title and cant be handled by appActivate function - // IDK about Safari , but I don't care. -} - -var act=popupString.FireFox; - -function readPropFile(fileName){ - //check existence - if (!FileSystemObj.FileExists(fileName)){ - WScript.Echo("(headers)file " + fileName + " does not exist!"); - WScript.Quit(15); - } - if (FileSystemObj.GetFile(fileName).Size === 0){ - return; - } - var fileR=FileSystemObj.OpenTextFile(fileName,1); - var line=""; - - var lineN=0; - var index=0; - var key=""; - var value=""; - try { - WScript.Echo("parsing "+fileName+" property file "); - while(!fileR.AtEndOfStream){ - line=fileR.ReadLine(); - lineN++; - index=line.indexOf("="); - if(line.indexOf("#") === 0 || trim(line)==="") { - continue; - } - if(index=== -1 || index === line.length-1 || index === 0) { - WScript.Echo("Invalid line "+ lineN); - WScript.Quit(93); - } - key=trim(line.substring(0,index)).toLowerCase(); - value=trim(line.substring(index+1,line.length)); - switch(key) { - case "browser": - popupString=selectBrowser(value); - break; - case "user": - user=value; - break; - case "pass": - case "password": - pass=value; - break; - case "stoponlogon": - if (value.toLowerCase() === "yes") { - stopOnLogon=true; - } - - } - } - fileR.Close(); - }catch (err){ - WScript.Echo("Error while reading file: "+fileName); - WScript.Echo(err.message); - return; - } -} - -function trim(str){ - return str.replace(/^\s+/,'').replace(/\s+$/,''); -} -function printHelp(){ - WScript.Echo(scriptName + " - Autolgin for Firefox/InternetExplorer authentication pop-up aimed to help for protractor/selenium tests"); - WScript.Echo("Usage:"); - WScript.Echo(scriptName + " [-browser ie|firefox] [-user username] [-pass password] [-file file] [-stoponlogon yes|no]"); - WScript.Echo("-browser default is firefox"); - WScript.Echo("-file path to file that contains a property file with user and password key/value"); - WScript.Echo("if no user/password are provided default.props will searched ") - WScript.Echo("or -user/-pass or -file arguments must be passed"); - WScript.Echo("-stoponlogon whether or not the script will stop after first fulfil of the authentication pop-up"); - WScript.Echo("default is no"); -} -function selectBrowser(str){ - switch (str.toLowerCase()){ - case "ie": - case "internetexplorer": - act=popupString.IE; - break; - case "ff": - case "firefox": - act=popupString.firefox; - break; - } -} - -//--------------------------- -function parseArgs(){ - // - if (ARGS.Length < 3) { - WScript.Echo("insufficient arguments"); - printHelp(); - WScript.Quit(43); - } - - if(ARGS.Length % 2 != 1) { - WScript.Echo("illegal arguments"); - printHelp(); - WScript.Quit(44); - } - - for (var i=2;i https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"); - WScript.Quit(status); - } - writeFile(file,WinHTTPObj.ResponseBody); -} - -function main(){ - parseArgs(); - download(url,saveTo); -} - -main(); diff --git a/hybrids/jscript/XMLHTTPDownloadJS.bat b/hybrids/jscript/XMLHTTPDownloadJS.bat deleted file mode 100644 index afec508..0000000 --- a/hybrids/jscript/XMLHTTPDownloadJS.bat +++ /dev/null @@ -1,232 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -// used resources -//http://www.codeproject.com/Tips/506439/Downloading-files-with-VBScript -//http://blogs.msdn.com/b/xmlteam/archive/2006/10/23/using-the-right-version-of-msxml-in-internet-explorer.aspx -//https://msdn.microsoft.com/en-us/library/ie/ms535874(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/aa923283.aspx -//https://msdn.microsoft.com/en-us/library/ms759148(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/ms759148(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/ms760236(v=vs.85).aspx -//http://stackoverflow.com/questions/20712635/providing-authentication-info-via-msxml2-serverxmlhttp -//https://msdn.microsoft.com/en-us/library/ms763680(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/ms757849(v=vs.85).aspx -//http://fm4dd.com/programming/shell/microsoft-vbs-http-download.htm -//http://stackoverflow.com/questions/11573022/vba-serverxmlhttp-https-request-with-self-signed-certificate -//http://www.qtcentre.org/threads/44629-Using-XMLHttpRequest-for-HTTPS-Post-to-server-with-SSL-certificate - -// global variables and constants -var ARGS = WScript.Arguments; -var scriptName=ARGS.Item(0); - -var url=""; -var saveTo=""; - -var user=0; -var pass=0; - -var proxy=0; -var bypass=""; -var proxy_user=0; -var proxy_pass=0; - -var certificate=0; - -var force=true; - -//ActiveX objects -//Use the right version of MSXML -/*var progIDs = [ 'Msxml2.DOMDocument.6.0', 'Msxml2.DOMDocument.5.0', 'Msxml2.DOMDocument.4.0', 'Msxml2.DOMDocument.3.0', 'Msxml2.DOMDocument' ] -for (var i = 0; i < progIDs.length; i++) { - try { - var XMLHTTPObj = new ActiveXObject(progIDs[i]); - }catch (ex) { - } -} - -if typeof XMLHTTPObj === 'undefined'{ - WScript.Echo ("You are using too ancient windows or you have no installed IE"); - WScript.Quit(1); -}*/ - -var XMLHTTPObj = new ActiveXObject("MSXML2.XMLHTTP"); -var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); -var AdoDBObj = new ActiveXObject("ADODB.Stream"); - - -function printHelp(){ - WScript.Echo(scriptName + " - downloads a file through HTTP"); - WScript.Echo(scriptName + " url localfile [-force yse|no] [-user username -password password] [-proxy proxyserver:port -bypass bypass_list]"); - WScript.Echo(" [-proxyuser proxy_username -proxypassword proxy_password] [-certificate certificateString]"); - WScript.Echo("-force - decide to not or to overwrite if the local exists"); - WScript.Echo("proxyserver:port - the proxy server"); - WScript.Echo("bypass- bypass list can be \"\" if you don't need it"); - WScript.Echo("proxy_user , proxy_password - credentials for proxy server"); - WScript.Echo("user , password - credentials for the server"); - WScript.Echo("certificate - location of SSL certificate"); - WScript.Echo("Example:"); - WScript.Echo(scriptName +" http://somelink.com/somefile.zip c:\\somefile.zip -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\""); -} - -function parseArgs(){ - // - if (ARGS.Length < 3) { - WScript.Echo("insufficient arguments"); - printHelp(); - WScript.Quit(43); - } - url=ARGS.Item(1); - saveTo=ARGS.Item(2); - - if(ARGS.Length % 2 != 1) { - WScript.Echo("illegal arguments"); - printHelp(); - WScript.Quit(44); - } - - for (var i=3;i https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"); - WScript.Quit(status); - } - writeFile(file,XMLHTTPObj.ResponseBody); -} - -function main(){ - parseArgs(); - download(url,saveTo); -} -main(); diff --git a/hybrids/jscript/base64.bat b/hybrids/jscript/base64.bat deleted file mode 100644 index c7262fd..0000000 --- a/hybrids/jscript/base64.bat +++ /dev/null @@ -1,267 +0,0 @@ - -@if (@X)==(@Y) @end /* JScript comment - @echo off - - - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - - -var toCall=null; -var input=null; -var ev=false; - -function parseArgs(){ - var args=WScript.Arguments; - if(args.Length==0){ - printHelp(); - WScript.Quit(0); - } - - var help = [ - "-h", - "-help", - "-?", - "/h", - "/help", - "/?" - ]; - - for(var i=0;i> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - - } - - return output; -}, - -// public method for decoding -decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - - } - - output = Base64._utf8_decode(output); - - return output; - -}, - -// private method for UTF-8 encoding -_utf8_encode : function (string) { - string = string.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - - return utftext; -}, - -// private method for UTF-8 decoding -_utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while ( i < utftext.length ) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; -} - -} - -parseArgs(); - -if(ev && toCall==Base64.encode) { - input=decodeJsString(input); -} -//Why is this not working? -//WScript.Echo(toCall(input)); - -if(toCall==Base64.encode){ - WScript.Echo(Base64.encode(input)); -} else { - WScript.Echo(Base64.decode(input)); -} diff --git a/hybrids/jscript/calcjs.bat b/hybrids/jscript/calcjs.bat deleted file mode 100644 index 83a00e1..0000000 --- a/hybrids/jscript/calcjs.bat +++ /dev/null @@ -1,4 +0,0 @@ -@if (@X) == (@Y) @end /* -@cscript //E:JScript //nologo "%~f0" "%*" -@exit /b %errorlevel% -*/WScript.StdOut.WriteLine(eval(WScript.Arguments.Item(0))); diff --git a/hybrids/jscript/deleteJS.bat b/hybrids/jscript/deleteJS.bat deleted file mode 100644 index c88faa8..0000000 --- a/hybrids/jscript/deleteJS.bat +++ /dev/null @@ -1,78 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - - -////// -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS = WScript.Arguments; -if (ARGS.Length < 1 ) { - WScript.Echo("No file passed"); - WScript.Echo("Usage:"); - WScript.Echo("Puts file or folder in the recycle bin."); - WScript.Echo(WScript.ScriptName + " file|folder"); - WScript.Quit(1); -} -var filename=ARGS.Item(0); -var objShell=new ActiveXObject("Shell.Application"); - -///// - - -//fso -ExistsItem = function (path) { - return FSOObj.FolderExists(path)||FSOObj.FileExists(path); -} - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} -// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s'); -var JSON = htmlfile.parentWindow.JSON; - -//needs file existence checks -var jsloc=WScript.Arguments.Item(0); -var jsonPath=WScript.Arguments.Item(1); -var newValue=WScript.Arguments.Item(2); - - -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var txtFile=FSOObj.OpenTextFile(jsloc,1); -var json=txtFile.ReadAll(); - -try { - var jParsed=JSON.parse(json); -}catch(err) { - WScript.Echo("Failed to parse the json content"); - htmlfile.close(); - txtFile.close(); - WScript.Exit(1); - //WScript.Echo(err.message); -} -eval("jParsed."+jsonPath+"=newValue"); -WScript.Echo(eval("JSON.stringify(jParsed)")); - - -htmlfile.close(); -txtFile.close(); diff --git a/hybrids/jscript/ejectjs.bat b/hybrids/jscript/ejectjs.bat deleted file mode 100644 index e45bff0..0000000 --- a/hybrids/jscript/ejectjs.bat +++ /dev/null @@ -1,107 +0,0 @@ - -@if (@X)==(@Y) @end /* JScript comment - @echo off - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - -function printHelp(){ - - WScript.Echo( WScript.ScriptName + " - ejects a device"); - WScript.Echo(" "); - WScript.Echo(WScript.ScriptName + " {LETTER|*}"); - WScript.Echo(" * will eject all ejectable drives"); -} - -if (WScript.Arguments.Length < 1 ) { - printHelp(); - WScript.Quit(0); -} - -if (WScript.Arguments.Item(0).length>1) { - WScript.Echo("You need to pass an a drive letter or *"); - WScript.Quit(1); -} - - -var ShellObj=new ActiveXObject("Shell.Application"); -var myComputer=ShellObj.NameSpace(17);//https://docs.microsoft.com/en-us/windows/win32/api/shldisp/ne-shldisp-shellspecialfolderconstants -var myComputerItems = myComputer.Items(); - -var usbType="USB Drive"; -var cdType="CD Drive"; - -var usbVerbFB=6; -var cdVerbFB=4; - -var toEject=WScript.Arguments.Item(0); - - -function callVerbFromBottom(item,indexFromBottom){ - var itemVerbs=item.Verbs(); - var verb=itemVerbs.Item(itemVerbs.Count-indexFromBottom); - verb.DoIt(); - item.InvokeVerb(verb.Name.replace("&","")); -} - -function ejectAll(){ - for (var i=0;i milliseconds){ - break; - } - } -} - -var counter=0; -while (IE.Busy && counter<60*60*10) { - //WScript.Echo(IE.Busy); - sleep(1000); - counter++; -} - -if(IE.Busy){ - WScript.Echo("Cant wait 4ever"); - WScript.Quit(10); -} - -function writeContent(file,content) { - var ado = WScript.CreateObject("ADODB.Stream"); - ado.Type = 2; // adTypeText = 2 - ado.CharSet = "iso-8859-1"; // right code page for output (no adjustments) - //ado.Mode=2; - ado.Open(); - - ado.WriteText(content); - ado.SaveToFile(file, 2); - ado.Close(); -} - -var innerText=IE.document.body.innerText; -IE.Quit(); -writeContent(saveTo,innerText) diff --git a/hybrids/jscript/guid.bat b/hybrids/jscript/guid.bat deleted file mode 100644 index 1d95f73..0000000 --- a/hybrids/jscript/guid.bat +++ /dev/null @@ -1,4 +0,0 @@ -@if (@X)==(@Y) @end /* -@cscript //E:JScript //nologo "%~f0" %* -@exit /b %errorlevel% -@*/WScript.Echo((new ActiveXObject("Scriptlet.TypeLib")).Guid) diff --git a/hybrids/jscript/imageProcessing/convImg.bat b/hybrids/jscript/imageProcessing/convImg.bat deleted file mode 100644 index b8a5dec..0000000 --- a/hybrids/jscript/imageProcessing/convImg.bat +++ /dev/null @@ -1,148 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - - -/* -https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx#SharedSample007 -https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx -https://msdn.microsoft.com/en-us/library/windows/desktop/ms630829(v=vs.85).aspx -*/ - -//////////////////////////// -//// // -/**/ var QUALITY=100; // -//// // -//////////////////////////// - -function printHelp(){ - WScript.Echo( WScript.ScriptName + " converts image from one format to another.Supported formats are BPM,JPG,PNG,GIF,TIFF"); - WScript.Echo( ""); - WScript.Echo( WScript.ScriptName + " source.file target.format [force]"); - WScript.Echo( ""); - WScript.Echo("source.file path to the file to be converted"); - WScript.Echo("target.format path to the fresult file.The extension of the file will be taken as the needed format in the result."); - WScript.Echo("force - if argument given the target file will be overwritten if exists."); -} - -if (WScript.Arguments.Length==0){ - printHelp(); -} - -if (WScript.Arguments.Length<2){ - WScript.Echo("Invalid arguments"); - printHelp(); - Wscript.Quit(1); -} - -var force=false; -var source=WScript.Arguments.Item(0); -var target=WScript.Arguments.Item(1); -if(WScript.Arguments.Length==3){ - force=true; -} - - -var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase(); - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -if(existsFile(target) && !force){ - WScript.Echo("Target image: " + target +" already exists"); - WScript.Quit(45); -} - -if(existsFolder(target)){ - WScript.Echo("There's existing folder with the target file (" + target +") name"); - WScript.Quit(46); -} - -if(existsFile(target) && force){ - deleteFile(target); -} - -//WScript.Echo(imageProcess.FilterInfos.Count); -//var count=imageProcess.FilterInfos.Count; - - - -function ID2Format(id){ - var ids={}; - ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM"; - ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG"; - ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF"; - ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG"; - ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF"; - - return ids[id]; -} - -function format2ID(format){ - formats={}; - formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"; - formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; - formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"; - formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; - formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"; - - return formats[format]; -} - -function loadImage(image,imageFile){ - try{ - image.LoadFile(imageFile); - }catch(err){ - WScript.Echo("Probably "+imageFile+" is not a valid image file"); - WScript.Quit(3); - } -} - -function convert(image,format){ - var filterFormat=format2ID(format); - if(filterFormat==null){ - WScript.Echo("not supported target format "+format); - WScript.Quit(9); - } - - imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID); - imageProcess.Filters(1).Properties("FormatID").Value = filterFormat; - imageProcess.Filters(1).Properties("Quality").Value = QUALITY; - - return imageProcess.Apply(image); -} - -loadImage(imageFile,source); -var sourceFormat=ID2Format(imageFile.FormatID); -if(sourceFormat!== targetFormat) { - var converted=convert(imageFile,targetFormat); - converted.SaveFile(target); -} else { - fileSystem.CopyFile(source,target,force); -} diff --git a/hybrids/jscript/imageProcessing/crop.bat b/hybrids/jscript/imageProcessing/crop.bat deleted file mode 100644 index 3c63cbd..0000000 --- a/hybrids/jscript/imageProcessing/crop.bat +++ /dev/null @@ -1,323 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - -//https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS=WScript.Arguments; - -//default values - -var top=0; -var right=0; -var bottom=0; -var left=0; - -var frameIndex=0; - -//image dimensions -var height=0 -var width=0; - -var percentage=false; -var force=false; - -var source=""; -var target=""; - -//////////////////////////// -//// // -/**/ var QUALITY=100; // -//// // -//////////////////////////// - - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - -function loadImage(image,imageFile){ - try{ - image.LoadFile(imageFile); - }catch(err){ - WScript.Echo("Probably "+imageFile+" is not a valid image file"); - WScript.Echo(err.message); - WScript.Quit(30); - } - height=image.Height; - width=image.Width; -} - -function ID2Format(id){ - var ids={}; - ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM"; - ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG"; - ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF"; - ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG"; - ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF"; - - return ids[id]; -} - -function format2ID(format){ - formats={}; - formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"; - formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; - formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"; - formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; - formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"; - - return formats[format]; -} - -function convert(image,format){ - var ic=imageProcess.Filters.Count; - var filterFormat=format2ID(format); - if(filterFormat==null){ - WScript.Echo("not supported target format "+format); - WScript.Quit(90); - } - imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID); - imageProcess.Filters(ic+1).Properties("FormatID").Value = filterFormat; - imageProcess.Filters(ic+1).Properties("Quality").Value = QUALITY; -} - -/* -The description of the Crop filter: - -Left - Set the Left property to the left margin (in pixels) - if you wish to crop along the left, otherwise 0 [the default] -Top - Set the Top property to the top margin (in pixels) - if you wish to crop along the top, otherwise 0 [the default] -Right - Set the Right property to the right margin (in pixels) - if you wish to crop along the right, otherwise 0 [the default] -Bottom - Set the Bottom property to the bottom margin (in pixels) - if you wish to crop along the bottom, otherwise 0 [the default] -FrameIndex - Set the FrameIndex property to the index of a frame if you - wish to modify a frame other than the ActiveFrame, - otherwise 0 [the default] -*/ - -function fromPerc(){ - if(left>=100){ - WScript.Echo("Left percentage ("+left+") cannot be bigger or equal to 100"); - WScript.Quit(31); - } - if(top>=100){ - WScript.Echo("Top percentage ("+top+") cannot be bigger or equal to 100"); - WScript.Quit(35); - } - if(right>=100){ - WScript.Echo("Right percentage ("+right+") cannot be bigger or equal to 100"); - WScript.Quit(40); - } - if(bottom>=100){ - WScript.Echo("Bottom percentage ("+bottom+") cannot be bigger or equal to 100"); - WScript.Quit(45); - } - - left=Math.round((width*left)/100); - right=Math.round((width*right)/100); - top=Math.round((height*top)/100); - bottom=Math.round((height*bottom)/100); - -} - -function crop(left,top,right,bottom,height,width){ - if(top<0 || bottom <0 || left<0 || right<0){ - WScript.Echo("Crop margins cannot be negative"); - WScript.Quit(9); - } - - if((left+right)>=width){ - WScript.Echo("Crop from left combined with right("+left+";"+right +") can't be bigger than the width: "+width); - WScript.Quit(10); - } - - if((top+bottom)>=height){ - WScript.Echo("Crop from top combined with bottom ("+top+";"+bottom +") can't be bigger than the height: "+height); - WScript.Quit(20); - } - - - var ic=imageProcess.Filters.Count; - imageProcess.Filters.Add(imageProcess.FilterInfos("Crop").FilterID); - - imageProcess.Filters(ic+1).Properties("Left") = left; - imageProcess.Filters(ic+1).Properties("Right") = right; - imageProcess.Filters(ic+1).Properties("Top") = top; - imageProcess.Filters(ic+1).Properties("Bottom") = bottom; - imageProcess.Filters(ic+1).Properties("FrameIndex") =frameIndex; -} - -function printHelp(){ - - WScript.Echo( WScript.ScriptName + " - crops image"); - WScript.Echo(" "); - WScript.Echo( WScript.ScriptName + "-source source.file -target file.format [-percentage yes|no] [-top number] [-left number] [-right number] [-bottom number] [-force yes|no] [-frame-index -0.5..1] "); - WScript.Echo("-source - the image that will flipped or rotated."); - WScript.Echo("-target - the file where the transformations will be saved in.If the file extension format is different than the source it will be converted to the pointed one "); - WScript.Echo("-percentage - whether the crop margins will be calculated in pixels or in percentages.If yes percentages will be used"); - WScript.Echo("-top - how much will be cropped from the top.Default is 0.Combined with -bottom cannot overexceed the height of the source"); - WScript.Echo("-bottom - how much will be cropped from the bottom.Default is 0.Combined with -top cannot overexceed the height of the source"); - WScript.Echo("-right - how much will be cropped from the right.Default is 0.Combined with -left cannot overexceed the wifth of the source"); - WScript.Echo("-left - how much will be cropped from the left.Default is 0.Combined with -right cannot overexceed the wifth of the source"); - WScript.Echo("-force - If yes and the target file already exists , it will be overwritten"); - WScript.Echo("-frame-index - Have no idea what this is used for , but it is pressented in the rotation filter capabilities.Images with this and without looks the same.Accepted values are from -0.5 to 1"); - -} - -function parseArguments(){ - if (WScript.Arguments.Length<4 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); - } - - if (WScript.Arguments.Length % 2 == 1 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - //ARGS - for(var arg = 0 ; arg 1){ - WScript.Echo("Wrong argument - frame index should be between -0.5 and 1"); - WScript.Quit(25); - } - - } catch (err){ - WScript.Echo("Wrong argument:"); - WScript.Echo(err.message); - WScript.Quit(20); - } - } - } - - if (target==""){ - WScript.Echo("Target file not passed"); - WScript.Quit(5); - } - - if(source==""){ - WScript.Echo("Source file not passed"); - WScript.Quit(6); - } -} - -parseArguments(); - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -if(existsFile(target) && !force){ - WScript.Echo("Target image: " + target +" already exists"); - WScript.Quit(45); -} - -if(existsFolder(target)){ - WScript.Echo("There's existing folder with the target file (" + target +") name"); - WScript.Quit(46); -} - -if(existsFile(target) && force){ - deleteFile(target); -} - -var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase(); -loadImage(imageFile,source); -var sourceFormat=ID2Format(imageFile.FormatID); - -if(percentage){ - fromPerc(); -} -/////---- -crop(left,top,right,bottom,height,width); -/////--- - -if (sourceFormat !== targetFormat ){ - convert(resImg,targetFormat); -} - -var resImg=imageProcess.Apply(imageFile); -resImg.SaveFile(target); diff --git a/hybrids/jscript/imageProcessing/rotateFlip.bat b/hybrids/jscript/imageProcessing/rotateFlip.bat deleted file mode 100644 index 7572c4a..0000000 --- a/hybrids/jscript/imageProcessing/rotateFlip.bat +++ /dev/null @@ -1,234 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -//https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS=WScript.Arguments; - - - -var flipVertical=false; -var flipHorizontal=false; -var frameIndex=0; -var rotation=0; - -var force=false; - -var source=""; -var target=""; -imageProcess.Filters.Add(imageProcess.FilterInfos("RotateFlip").FilterID); - -/* -Rotates, in 90 degree increments, and Flips, horizontally or vertically. - -RotationAngle - Set the RotationAngle property to 90, 180, or 270 if you wish - to rotate, otherwise 0 [the default] -FlipHorizontal - Set the FlipHorizontal property to True if you wish to flip - the image horizontally, otherwise False [the default] -FlipVertical - Set the FlipVertical property to True if you wish to flip - the image vertically, otherwise False [the default] -FrameIndex - Set the FrameIndex property to the index of a frame if you - wish to modify a frame other than the ActiveFrame, - otherwise 0 [the default] - - -*/ - - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - -function printHelp(){ - - WScript.Echo( WScript.ScriptName + " rotates or flips image"); - WScript.Echo(" "); - WScript.Echo( WScript.ScriptName + " -source source.file -target target.file [-flip-vertical yes|no] [-flip-horizontal yes|no] [-force yes|no] [-rotation-angle 0|90|180|270] [-frame-index -0.5 - 1]"); - WScript.Echo(" "); - WScript.Echo("-source - the image that will flipped or rotated."); - WScript.Echo("-target - the file where the transformations will be saved in.If the file extension format is different than the source it will be converted to the pointed one "); - WScript.Echo("-flip-vertical - Will the image be flipped vertically.Default is no."); - WScript.Echo("-flip-horizontal - Will the image be flipped horizontally.Default is no."); - WScript.Echo("-rotation-angle - The angle image will be rotated with.Default is 0.Accpeted values are 0,90,180,270."); - WScript.Echo("-force - If yes and the target file already exists , it will be overwritten"); - WScript.Echo("-frame-index - Have no idea what this is used for , but it is pressented in the rotation filter capabilities.Images with this and without looks the same.Accepted values are from -0.5 to 1"); - -} - -function parseArguments(){ - if (WScript.Arguments.Length<4 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); - } - - if (WScript.Arguments.Length % 2 == 1 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - //ARGS - for(var arg = 0 ; arg 1){ - WScript.Echo("Wrong argument - frame index should be between -0.5 and 1"); - WScript.Quit(25); - } - - } catch (err){ - WScript.Echo("Wrong argument:"); - WScript.Echo(err.message); - WScript.Quit(20); - } - - } - } - - if (target==""){ - WScript.Echo("Target file not passed"); - WScript.Quit(5); - } - - if(source==""){ - WScript.Echo("Source file not passed"); - WScript.Quit(6); - } -} - -function loadImage(image,imageFile){ - try{ - image.LoadFile(imageFile); - }catch(err){ - WScript.Echo("Probably "+imageFile+" is not a valid image file"); - WScript.Quit(30); - } -} - -function ID2Format(id){ - var ids={}; - ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM"; - ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG"; - ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF"; - ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG"; - ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF"; - - return ids[id]; -} - -function format2ID(format){ - formats={}; - formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"; - formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; - formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"; - formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; - formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"; - - return formats[format]; -} - -function convert(image,format){ - var ic=imageProcess.Filters.Count; - var filterFormat=format2ID(format); - if(filterFormat==null){ - WScript.Echo("not supported target format "+format); - WScript.Quit(90); - } - imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID); - imageProcess.Filters(ic+1).Properties("FormatID").Value = filterFormat; - imageProcess.Filters(ic+1).Properties("Quality").Value = 100; - - //return imageProcess.Apply(image); -} - -// -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ -parseArguments(); -var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase(); - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -if(existsFile(target) && !force){ - WScript.Echo("Target image: " + target +" already exists"); - WScript.Quit(45); -} - -if(existsFolder(target)){ - WScript.Echo("There's existing folder with the target file (" + target +") name"); - WScript.Quit(46); -} - -if(existsFile(target) && force){ - deleteFile(target); -} - -loadImage(imageFile,source); -var sourceFormat=ID2Format(imageFile.FormatID); - - -imageProcess.Filters(1).Properties("RotationAngle") = rotation; -imageProcess.Filters(1).Properties("FlipHorizontal") = flipHorizontal; -imageProcess.Filters(1).Properties("FlipVertical") = flipVertical; -imageProcess.Filters(1).Properties("FrameIndex") = frameIndex; - - -if (sourceFormat !== targetFormat ){ - convert(resImg,targetFormat); -} -var resImg=imageProcess.Apply(imageFile); -resImg.SaveFile(target); -// -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ diff --git a/hybrids/jscript/imageProcessing/scale.bat b/hybrids/jscript/imageProcessing/scale.bat deleted file mode 100644 index 0c29148..0000000 --- a/hybrids/jscript/imageProcessing/scale.bat +++ /dev/null @@ -1,310 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - -//https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS=WScript.Arguments; - -/****** -Scale filter description: - -Scales image to the specified Maximum Width and Maximum Height preserving -Aspect Ratio if necessary. - - -MaximumWidth - Set the MaximumWidth property to the width (in pixels) - that you wish to scale the image to. -MaximumHeight - Set the MaximumHeight property to the height (in pixels) - that you wish to scale the image to. -PreserveAspectRatio - Set the PreserveAspectRatio property to True - [the default] if you wish to maintain the current aspect - ration of the image, otherwise False and the image will - be stretched to the MaximumWidth and MaximumHeight -FrameIndex - Set the FrameIndex property to the index of a frame if - you wish to modify a frame other than the ActiveFrame, - otherwise 0 [the default] - - -******/ - -//defaults - -var maxWidth=0; -var maxHeight=0; - -var pRatio=true; -var frameIndex=0; - -var source=""; -var target=""; - -var force=false; - -var height=0; -var width=0; - -var percentage=false; - -//////////////////////////// -//// // -/**/ var QUALITY=100; // -//// // -//////////////////////////// - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - -function loadImage(image,imageFile){ - try{ - image.LoadFile(imageFile); - }catch(err){ - WScript.Echo("Probably "+imageFile+" is not a valid image file"); - WScript.Echo(err.message); - WScript.Quit(30); - } - height=image.Height; - width=image.Width; -} - -function ID2Format(id){ - var ids={}; - ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM"; - ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG"; - ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF"; - ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG"; - ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF"; - - return ids[id]; -} - -function format2ID(format){ - formats={}; - formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"; - formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; - formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"; - formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; - formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"; - - return formats[format]; -} - -function convert(image,format){ - var ic=imageProcess.Filters.Count; - var filterFormat=format2ID(format); - if(filterFormat==null){ - WScript.Echo("not supported target format "+format); - WScript.Quit(90); - } - imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID); - imageProcess.Filters(ic+1).Properties("FormatID").Value = filterFormat; - imageProcess.Filters(ic+1).Properties("Quality").Value = QUALITY; -} - -function scale(){ - if(maxHeight<=0){ - WScript.Echo("MaximumHeight ("+maxHeight+") should be bigger than 0"); - WScript.Quit(80); - } - - if(maxWidth<=0){ - WScript.Echo("MaximumHeight ("+maxWidth+") should be bigger than 0"); - WScript.Quit(81); - } - - var ic=imageProcess.Filters.Count; - //var filterFormat=format2ID(format); - imageProcess.Filters.Add(imageProcess.FilterInfos("Scale").FilterID); - - imageProcess.Filters(ic+1).Properties("MaximumWidth").Value = maxWidth; - imageProcess.Filters(ic+1).Properties("MaximumHeight").Value = maxHeight; - //WScript.Echo(pRatio+"::"+maxWidth+"::"+maxHeight+">>"+width+"++"+height); - imageProcess.Filters(ic+1).Properties("PreserveAspectRatio").Value = pRatio; - imageProcess.Filters(ic+1).Properties("FrameIndex").Value = frameIndex; -} - -function fromPerc(){ - maxWidth=Math.round((width*maxWidth)/100); - maxHeight=Math.round((height*maxHeight)/100); - if(maxHeight==0) - maxHeight=1; - if(maxWidth==0) - maxWidth=1; -} - - -function printHelp(){ - - WScript.Echo( WScript.ScriptName + " - resizes an image"); - WScript.Echo(" "); - WScript.Echo(WScript.ScriptName + "-source source.file -target file.format [-max-height height] [-max-width width] [-percentage yes|no] [-keep-ratio yes|no] [-frame-index -0.5..1] "); - WScript.Echo("-source - the image that will flipped or rotated."); - WScript.Echo("-target - the file where the transformations will be saved in.If the file extension format is different than the source it will be converted to the pointed one.Supported formats are BMp,JPG,GIF,TIFF,PNG"); - WScript.Echo("-percentage - whether the rescale will be calculated in pixels or in percentages.If yes percentages will be used.Default is no."); - WScript.Echo("-force - If yes and the target file already exists , it will be overwritten"); - WScript.Echo("-max-height - max height of the image"); - WScript.Echo("-max-width - max width of the image"); - WScript.Echo("-keep-ratio - if dimensions ratio will be preserved.Default is yes"); - WScript.Echo("-frame-index - Have no idea what this is used for , but it is pressented in the rotation filter capabilities.Images with this and without looks the same.Accepted values are from -0.5 to 1"); - -} - -function parseArguments(){ - if (WScript.Arguments.Length<4 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); - } - - if (WScript.Arguments.Length % 2 == 1 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - //ARGS - for(var arg = 0 ; arg 1){ - WScript.Echo("Wrong argument - frame index should be between -0.5 and 1"); - WScript.Quit(25); - } - - } catch (err){ - WScript.Echo("Wrong argument:"); - WScript.Echo(err.message); - WScript.Quit(20); - } - } - } - - if (target==""){ - WScript.Echo("Target file not passed"); - WScript.Quit(5); - } - - if(source==""){ - WScript.Echo("Source file not passed"); - WScript.Quit(6); - } -} - -parseArguments(); - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -if(existsFile(target) && !force){ - WScript.Echo("Target image: " + target +" already exists"); - WScript.Quit(45); -} - -if(existsFolder(target)){ - WScript.Echo("There's existing folder with the target file (" + target +") name"); - WScript.Quit(46); -} - -if(existsFile(target) && force){ - deleteFile(target); -} - -var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase(); -loadImage(imageFile,source); -var sourceFormat=ID2Format(imageFile.FormatID); - - -if(maxWidth==0 && !percentage){ - maxWidth=width; -} - -if(maxHeight==0 && !percentage){ - maxHeight=height; -} - -if(maxWidth==0 && percentage){ - maxWidth=100; -} - -if(maxHeight==0 && percentage){ - maxHeight=100; -} - - -if(percentage){ - fromPerc(); -} - - - -/// -scale(); -/// - -if (sourceFormat !== targetFormat ){ - convert(resImg,targetFormat); -} - -var resImg=imageProcess.Apply(imageFile); -resImg.SaveFile(target); diff --git a/hybrids/jscript/imageProcessing/shRotate.bat b/hybrids/jscript/imageProcessing/shRotate.bat deleted file mode 100644 index ac1d434..0000000 --- a/hybrids/jscript/imageProcessing/shRotate.bat +++ /dev/null @@ -1,145 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - - -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS = WScript.Arguments; -if (ARGS.Length < 2 ) { - WScript.Echo("insufficient arguments:"); - WScript.Quit(1); -} -var filename=ARGS.Item(0); -var action=ARGS.Item(1).toLowerCase(); -var objShell=new ActiveXObject("Shell.Application"); - -////// -// -var useLanguageDependantVervs=false; -// -///// - - - - -//fso -ExistsItem = function (path) { - return FSOObj.FolderExists(path)||FSOObj.FileExists(path); -} - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} -// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s -1 ){ - WScript.Echo('Rotating "'+fullFilename+'" left'); - verbs.Item(i).DoIt(); - return; - } - - if( action=='rotateright' && - replaceAll("&","",verbs.Item(i).Name).indexOf("Rotate right") > -1 ){ - WScript.Echo('Rotating "'+fullFilename+'" right'); - verbs.Item(i).DoIt(); - return; - } - - if( action=='setwallpaper' && - replaceAll("&","",verbs.Item(i).Name).indexOf("desktop background") > -1 ){ - WScript.Echo('Setting "'+fullFilename+'" as wallpaper'); - verbs.Item(i).DoIt(); - return; - } - } - } - -} -main(); - -function replaceAll(find, replace, str) { - return str.replace(new RegExp(find, 'g'), replace); -} diff --git a/hybrids/jscript/imageProcessing/stamp.bat b/hybrids/jscript/imageProcessing/stamp.bat deleted file mode 100644 index 9409d58..0000000 --- a/hybrids/jscript/imageProcessing/stamp.bat +++ /dev/null @@ -1,305 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - cscript //E:JScript //nologo "%~f0" %* - ::pause - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - -//https://msdn.microsoft.com/en-us/library/windows/desktop/ms630819(v=vs.85).aspx - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageFileStamp = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS=WScript.Arguments; - -/**** -Stamp filter description - -Stamps the specified ImageFile at the specified Left and Top coordinates. - -ImageFile - Set the ImageFile property to the ImageFile object that you wish - to stamp -Left - Set the Left property to the offset from the left (in pixels) - that you wish to stamp the ImageFile at [default is 0] -Top - Set the Top property to the offset from the top (in pixels) that - you wish to stamp the ImageFile at [default is 0] -FrameIndex - Set the FrameIndex property to the index of a frame if you wish to - modify a frame other than the ActiveFrame, otherwise 0 - [the default] -****/ - -//defaults - -var maxWidth=0; -var maxHeight=0; - -var pRatio=true; -var frameIndex=0; - -var source=""; -var target=""; -var stamp=""; - -var force=false; - -var height=0; -var width=0; - -var top=0; -var left=0; - -percentage=false; -//////////////////////////// -//// // -/**/ var QUALITY=100; // -//// // -//////////////////////////// - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - -function loadImage(image,imageFile,isSource){ - try{ - image.LoadFile(imageFile); - }catch(err){ - WScript.Echo("Probably "+imageFile+" is not a valid image file"); - WScript.Echo(err.message); - WScript.Quit(30); - } - if(isSource){ - height=image.Height; - width=image.Width; - } -} - -function ID2Format(id){ - var ids={}; - ids["{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"]="BPM"; - ids["{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"]="PNG"; - ids["{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"]="GIF"; - ids["{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"]="JPG"; - ids["{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"]="TIFF"; - - return ids[id]; -} - -function format2ID(format){ - var formats={}; - formats["BMP"]="{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}"; - formats["PNG"]="{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"; - formats["GIF"]="{B96B3CB0-0728-11D3-9D7B-0000F81EF32E}"; - formats["JPG"]="{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}"; - formats["TIFF"]="{B96B3CB1-0728-11D3-9D7B-0000F81EF32E}"; - - return formats[format]; -} - -function convert(image,format){ - var ic=imageProcess.Filters.Count; - var filterFormat=format2ID(format); - if(filterFormat==null){ - WScript.Echo("not supported target format "+format); - WScript.Quit(90); - } - imageProcess.Filters.Add(imageProcess.FilterInfos("Convert").FilterID); - imageProcess.Filters(ic+1).Properties("FormatID").Value = filterFormat; - imageProcess.Filters(ic+1).Properties("Quality").Value = QUALITY; -} - -function stamping(stampImage) { - var ic=imageProcess.Filters.Count; - imageProcess.Filters.Add(imageProcess.FilterInfos("Stamp").FilterID); - imageProcess.Filters(ic+1).Properties("ImageFile")=stampImage; - imageProcess.Filters(ic+1).Properties("Left")=left; - imageProcess.Filters(ic+1).Properties("Top")=top; - imageProcess.Filters(ic+1).Properties("FrameIndex")=frameIndex; -} - - -function fromPerc(){ - top=Math.round((height*top)/100); - left=Math.round((width*left)/100); - if(left==0) - left=1; - if(top==0) - top=1; -} - -function printHelp(){ - - WScript.Echo( WScript.ScriptName + " - samps image over another with a given offset"); - WScript.Echo(" "); - WScript.Echo(WScript.ScriptName + "-source source.file -stamp stamp.file -target file.format [-top top] \n\r" + - "[-left left] [-percentage yes|no] [-frame-index -0.5..1] "); - WScript.Echo("-source - the image that will flipped or rotated."); - WScript.Echo("-target - the file where the transformations will be saved in.If the file extension format is different than the source it will be converted to the pointed one.Supported formats are BMp,JPG,GIF,TIFF,PNG"); - WScript.Echo("-stamp - path to image that will be stamped over the source image"); - WScript.Echo("-percentage - whether the rescale will be calculated in pixels or in percentages.If yes percentages will be used.Default is no."); - WScript.Echo("-force - If yes and the target file already exists , it will be overwritten"); - WScript.Echo("-top - offset from the top.Cannot be bigger than the source height.Default is 0."); - WScript.Echo("-left - offset from the left.Cannot be bigger than the source width.Default is 0."); - WScript.Echo("-frame-index - Have no idea what this is used for , but it is pressented in the rotation filter capabilities.Images with this and without looks the same.Accepted values are from -0.5 to 1"); - -} - - -//-- -(function parseArguments(){ - if (WScript.Arguments.Length<6 || ARGS.Item(1).toLowerCase() == "-help" || ARGS.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); - } - - if (WScript.Arguments.Length % 2 == 1 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - //ARGS - for(var arg = 0 ; arg 1){ - WScript.Echo("Wrong argument - frame index should be between -0.5 and 1"); - WScript.Quit(25); - } - - } catch (err){ - WScript.Echo("Wrong argument:"); - WScript.Echo(err.message); - WScript.Quit(20); - } - } - } - - if (target==""){ - WScript.Echo("Target file not passed"); - WScript.Quit(5); - } - - if(source==""){ - WScript.Echo("Source file not passed"); - WScript.Quit(6); - } - - if(stamp==""){ - WScript.Echo("Stamp file not passed"); - WScript.Quit(7); - } -}()); -//-- - - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -if(!existsFile(stamp)){ - WScript.Echo("Stamp image: " + stamp +" does not exists"); - WScript.Quit(41); -} - -if(existsFile(target) && !force){ - WScript.Echo("Target image: " + target +" already exists"); - WScript.Quit(45); -} - -if(existsFolder(target)){ - WScript.Echo("There's existing folder with the target file (" + target +") name"); - WScript.Quit(46); -} - -if(existsFile(target) && force){ - deleteFile(target); -} - -loadImage(imageFile,source,true); -loadImage(imageFileStamp,stamp,false); - -if(percentage){ - fromPerc(); -} - - -if(top>height){ - WScript.Echo("Top offset cannot be bigger than image height"); - WScript.Quit(50); -} - -if(left>height){ - WScript.Echo("Left offset cannot be bigger than image width"); - WScript.Quit(55); -} - - -var targetFormat=target.split(".")[target.split(".").length-1].toUpperCase(); -var sourceFormat=ID2Format(imageFile.FormatID); - - - -stamping(imageFileStamp); - -if (sourceFormat !== targetFormat ){ - convert(resImg,targetFormat); -} - -var resImg=imageProcess.Apply(imageFile); -resImg.SaveFile(target); diff --git a/hybrids/jscript/imageProcessing/tiff.bat b/hybrids/jscript/imageProcessing/tiff.bat deleted file mode 100644 index fdd149b..0000000 --- a/hybrids/jscript/imageProcessing/tiff.bat +++ /dev/null @@ -1,181 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -var imageFile = new ActiveXObject("WIA.ImageFile"); -var imageProcess = new ActiveXObject("WIA.ImageProcess"); -var fileSystem = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS=WScript.Arguments; - -var imageList=""; -//var images; -var files=[]; - -var source=""; -var target=""; - -//////////////////////////// -//// // -/**/ var QUALITY=100; // -//// // -//////////////////////////// - -function existsFile(path){ - if (fileSystem.FileExists(path)) - return true; -} - -function existsFolder(path){ - if (fileSystem.FolderExists(path)) - return true; -} - -function deleteFile(path){ - fileSystem.DeleteFile(path); -} - -var force=false; -var frameIndex=0; - -function createImageFiles(){ - for(var i=0;i 1){ - WScript.Echo("Wrong argument - frame index should be between -0.5 and 1"); - WScript.Quit(25); - } - - } catch (err){ - WScript.Echo("Wrong argument:"); - WScript.Echo(err.message); - WScript.Quit(20); - } - } - } - - if (target==""){ - WScript.Echo("Target file not passed"); - WScript.Quit(5); - } - - if(source==""){ - WScript.Echo("Source file not passed"); - WScript.Quit(6); - } - - if(imageList==""){ - WScript.Echo("Page files not passed"); - WScript.Quit(7); - } - files=imageList.split(";"); - -}()); - - -if(!existsFile(source)){ - WScript.Echo("Source image: " + source +" does not exists"); - WScript.Quit(40); -} - -for(var i=0;i'); -var JSON = htmlfile.parentWindow.JSON; - -//needs file existence checks -var jsloc=WScript.Arguments.Item(0); -var jsonPath=WScript.Arguments.Item(1); - - -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var txtFile=FSOObj.OpenTextFile(jsloc,1); -var json=txtFile.ReadAll(); - -try { - var jParsed=JSON.parse(json); -}catch(err) { - WScript.Echo("Failed to parse the json content"); - htmlfile.close(); - txtFile.close(); - WScript.Exit(1); - //WScript.Echo(err.message); -} - - -WScript.Echo(eval("JSON.stringify(jParsed."+jsonPath+")")); - - -htmlfile.close(); -txtFile.close(); diff --git a/hybrids/jscript/jspopup.bat b/hybrids/jscript/jspopup.bat deleted file mode 100644 index 3b4a76e..0000000 --- a/hybrids/jscript/jspopup.bat +++ /dev/null @@ -1,81 +0,0 @@ - @if (@x)==(@y) @end /***** jscript comment ****** - @echo off - - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - exit /b 0 - - @if (@x)==(@y) @end ****** end comment *********/ - - -var wshShell = WScript.CreateObject("WScript.Shell"); -var args=WScript.Arguments; -var title=args.Item(0); - -var timeout=-1; -var pressed_message="button pressed"; -var timeout_message="timedout"; -var message=""; - -function printHelp() { - WScript.Echo(title + "[-title Title] [-timeout m] [-tom \"Time-out message\"] [-pbm \"Pressed button message\"] [-message \"pop-up message\"]"); -} - -if (WScript.Arguments.Length==1){ - runPopup(); - WScript.Quit(0); -} - -if (args.Item(1).toLowerCase() == "-help" || args.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); -} - -if (WScript.Arguments.Length % 2 == 0 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); -} - -for (var arg = 1 ; arg1) && (ARGS.Item(1).toLowerCase()=="-help")) { - WScript.Echo(ARGS.Item(0)+" [oneDriveLocation|OneDriveShortcut]"); - WScript.Echo("If location not defined default will be taken"); - WScript.Quit(0); -} - - - -if ( ARGS.Length > 1 && ARGS.Item(1).toLowerCase!=="-help") { - var filename=ARGS.Item(1); -} else { - var wshShell = new ActiveXObject( "WScript.Shell" ); - var up=wshShell.ExpandEnvironmentStrings( "%USERPROFILE%" ); - var filename=up+"\\"+"OneDrive"; - - //WScript.Echo(oneD); - if(!ExistsItem(filename)){ - try { - filename=wshShell.RegRead( "HKCU\\Software\\Microsoft\\SkyDrive\\UserFolder"); - }catch (err){ - WScript.Echo("OneDrive probably not installed"); - WScript.Echo(err.message); - WScript.Quit(5); - } - - if((!ExistsItem(filename))) { - WScript.Echo("OneDrive not found where it should be"); - WScript.Quit(6); - } - } -} - -///// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s -1) { - return; - } - - - var elements=tempString.split("/"); - for (i = 0;i < elements.length;i++) { - - if (elements[i].toLowerCase().indexOf("count") > -1) { - pages=elements[i].split(" ")[1]; - - } - } - } - - function getPages(fPath) { - var fChars = getChars(fPath); - - for (i=0;i" && - fChars[i+1] == ">" ) { - - inTag = false; - checkTag(tempString); - if (pages != "" ) { - return; - } - - tempString=""; - - } - - if (inTag) { - if (fChars[i] != '\n' && fChars[i] != '\r') { - tempString += fChars[i]; - } - } - - } - - } - - getPages(filename); - if (pages == "") { - WScript.Echo("1"); - } else { - WScript.Echo(pages); - } - diff --git a/hybrids/jscript/phisycalDrives.bat b/hybrids/jscript/phisycalDrives.bat deleted file mode 100644 index 1f89627..0000000 --- a/hybrids/jscript/phisycalDrives.bat +++ /dev/null @@ -1,56 +0,0 @@ -@if (@X)==(@Y) @end /* JSCRIPT COMMENT ** - - -@echo off -cscript //E:JScript //nologo "%~f0" -exit /b - -// Sources of wisdom: -//http://social.msdn.microsoft.com/Forums/vstudio/en-US/659030c8-bcf5-4542-bbc6-eaf9679e090a/cannot-create-object-wmi-in-javascript -//http://blogs.technet.com/b/heyscriptingguy/archive/2005/05/23/how-can-i-correlate-logical-drives-and-physical-disks.aspx -//http://stackoverflow.com/a/1144788/388389 - -************** end of JSCRIPT COMMENT **/ - - -String.prototype.replaceAll = function (find, replace) { - var str = this; - return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace); -}; - - -var winmgmts= GetObject("winmgmts:\\\\.\\root\\cimv2") -var drives = winmgmts.ExecQuery( "SELECT * FROM Win32_DiskDrive", null, 48 ); -//WScript.Echo(drives); - -var drvs = new Enumerator(drives); -for (;!drvs.atEnd();drvs.moveNext()) { - var drive=drvs.item(); - - WScript.Echo( "Physical Disk: " + drive.Caption + " -- " + drive.DeviceID ); - var deviceID = drive.DeviceID.replaceAll( "\\" ,"\\\\"); - var colPartitions = winmgmts.ExecQuery( "ASSOCIATORS OF {Win32_DiskDrive.DeviceID=\"" + - deviceID + "\"} WHERE AssocClass = Win32_DiskDriveToDiskPartition" , null, 48 ); - - var colParts = new Enumerator(colPartitions); - for (;!colParts.atEnd();colParts.moveNext()) { - - var partition=colParts.item(); - - //WScript.Echo( "Disk Partition: " + partition.DeviceID ); - var colLogicalDisks = winmgmts.ExecQuery( "ASSOCIATORS OF {Win32_DiskPartition.DeviceID=\"" + - partition.DeviceID + "\"} WHERE AssocClass = Win32_LogicalDiskToPartition" , null, 48); - var colLD = new Enumerator(colLogicalDisks); - - if (typeof colLD.item() != "undefined") { - for (;!colLD.atEnd();colLD.moveNext()) { - var logicalDisk=colLD.item(); - WScript.Echo( " Logical Disk: " + logicalDisk.DeviceID + " Disk Partition: harddisk" + partition.DeviceID.split("#")[1].split(",")[0] + "\\partition" + partition.DeviceID.split("#")[2] ); - } - } else { - WScript.Echo( " Disk Partition: harddisk" + partition.DeviceID.split("#")[1].split(",")[0] + "\\partition" + partition.DeviceID.split("#")[2] ); - } - - } - -} diff --git a/hybrids/jscript/pinnerJS.bat b/hybrids/jscript/pinnerJS.bat deleted file mode 100644 index 1213995..0000000 --- a/hybrids/jscript/pinnerJS.bat +++ /dev/null @@ -1,174 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -//gets an information that normally is acquired by right click-details -// can get image dimensions , media file play time and etc. - -// Thanks to help by Alexis Viala now it supports pin to start screen - -////// -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS = WScript.Arguments; -if (ARGS.Length < 1 ) { - WScript.Echo("No file passed"); - WScript.Echo("Usage(pins/unpins items to/from startmenu/taskbar):"); - WScript.Echo(WScript.ScriptName + " file [taskbar|startmenu|untaskbar|unstartmenu]"); - WScript.Echo("default is taskbar"); - WScript.Quit(1); -} -var filename=ARGS.Item(0); -var objShell=new ActiveXObject("Shell.Application"); - -var verb="taskbar"; -if (ARGS.Length > 1) { - verb=ARGS.Item(1).toLowerCase(); - switch(verb){ - case "taskbar": - verb="taskbar"; - break; - case "startmenu": - verb="startmenu"; - break; - case "untaskbar": - verb="untaskbar"; - break; - case "unstartmenu": - verb="unstartmenu"; - break; - default: - WScript.Echo("invalid verb "+verb); - WScript.Quit(5); - } -} -///// - - -//fso -ExistsItem = function (path) { - return FSOObj.FolderExists(path)||FSOObj.FileExists(path); -} - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} -// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s619999){ - startVerb1="pintostartscreen"; -} - - -function main(){ - if (!ExistsItem(filename)) { - WScript.Echo(filename + " does not exist"); - WScript.Quit(2); - } - var fullFilename=getFullPath(filename); - var namespace=getParent(fullFilename); - var name=getName(fullFilename); - var objFolder=objShell.NameSpace(namespace); - var objItem=objFolder.ParseName(name); - //https://msdn.microsoft.com/en-us/library/windows/desktop/bb787870(v=vs.85).aspx - //https://msdn.microsoft.com/en-us/library/windows/desktop/bb774170(v=vs.85).aspx - //WScript.Echo(fullFilename + " : "); - //WScript.Echo(objFolder.GetDetailsOf(objItem,-1)); - - var verbs=objItem.Verbs(); - /* - verbs persisten handlers are {90AA3A4E-1CBA-4233-B8BB-535773D48449} and - {a2a9545d-a0c2-42b4-9708-a0b2badd77c8} and verbs language independent names can be seen in - HKEY_CLASSES_ROOT\CLSID\ - - - the language dependable version is commented out along with replaceAll function. - To use it you need to add the && conditions in if statements and use DoIt() function instead of - invokeVerb. - - The good thing in it is that it checks if the verbs are supported by the passed file. - Though it will not work properly on not english language settings. - - */ - if (verbs != null) { - - for (var i=0;i -1 ) { - WScript.Echo("pinning " + name + " to taskbar "); - objItem.InvokeVerb("TaskbarPin"); - //verbs.Item(i).DoIt(); - return; - } - - if ( verb === "startmenu" ) { - // && replaceAll("&","",verbs.Item(i).Name).indexOf("Pin to Start") > -1) { - WScript.Echo("pinning " + name + " to start menu "); - objItem.InvokeVerb(startVerb1); - //verbs.Item(i).DoIt(); - return; - } - if ( verb === "unstartmenu"){ - // && replaceAll("&","",verbs.Item(i).Name).indexOf("Unpin from Start") > -1) { - WScript.Echo("unpinning " + name + " from start menu "); - objItem.InvokeVerb("startunpin"); - //verbs.Item(i).DoIt(); - return; - } - if ( verb === "untaskbar" ) { - //&& replaceAll("&","",verbs.Item(i).Name).indexOf("Unpin from Taskbar") > -1 ) { - WScript.Echo("unpinning " + name + " from taskbar "); - objItem.InvokeVerb("TaskbarUnPin"); - //verbs.Item(i).DoIt(); - return; - } - } - - WScript.Echo("the item " + filename + "does not support selected action("+verb+")"); - return; - } -} -main(); - -//function replaceAll(find, replace, str) { -// return str.replace(new RegExp(find, 'g'), replace); -//} diff --git a/hybrids/jscript/ppt2pdf.bat b/hybrids/jscript/ppt2pdf.bat deleted file mode 100644 index 5679cd9..0000000 --- a/hybrids/jscript/ppt2pdf.bat +++ /dev/null @@ -1,47 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -function printHelp(){ - WScript.Echo(WScript.ScriptName + " - converts power point presentation to pdf.Requires installed MS Office."); - WScript.Echo("Usage:"); - WScript.Echo("[call] " + WScript.ScriptName + " pptFile pdfFile"); -} - -if(WScript.Arguments.Item(0).toLowerCase()=="-h" || WScript.Arguments.Item(0).toLowerCase()=="-help" || WScript.Arguments.Item(0).toLowerCase()=="-?") { - printHelp(); -} - -if(WScript.Arguments.Length < 2) { - printHelp(); - WScript.Quit(1); -} - -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); - -var source=WScript.Arguments.Item(0); -var target=WScript.Arguments.Item(1); - -// no checks for directories. -if(!FSOObj.FileExists(source)){ - WScript.Echo("File " + source + "does not exists"); - WScript.Quit(2); -} - -if(FSOObj.FileExists(target)){ - WScript.Echo("File " + target + "already exists"); - WScript.Quit(3); -} - -PP = new ActiveXObject("PowerPoint.Application"); -PRSNT = PP.presentations.Open(source,0,0,0) -//PRSNT.SaveCopyAs(target,32); -//https://msdn.microsoft.com/en-us/vba/powerpoint-vba/articles/ppsaveasfiletype-enumeration-powerpoint -PRSNT.SaveAs(target,32); -PRSNT.Close(); -PP.Quit(); diff --git a/hybrids/jscript/printJS.bat b/hybrids/jscript/printJS.bat deleted file mode 100644 index ec1f534..0000000 --- a/hybrids/jscript/printJS.bat +++ /dev/null @@ -1,98 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -//gets an information that normally is acquired by right click-details -// can get image dimensions , media file play time and etc. - -////// -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS = WScript.Arguments; -if (ARGS.Length < 1 ) { - WScript.Echo("No file passed"); - WScript.Echo("Usage (prints with default printer a file if possible)"); - WScript.Echo(WScript.ScriptName + " file"); - WScript.Quit(1); -} -var filename=ARGS.Item(0); -var objShell=new ActiveXObject("Shell.Application"); - -///// - - -//fso -ExistsItem = function (path) { - return FSOObj.FolderExists(path)||FSOObj.FileExists(path); -} - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} -// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s 255 ) { - chars[indx] = String.fromCharCode(128 + adjustment.indexOf(chars[indx])); - } - } - return chars.join(""); - } - - function writeContent(file,content) { - var ado = WScript.CreateObject("ADODB.Stream"); - ado.Type = 2; // adTypeText = 2 - ado.CharSet = "iso-8859-1"; // right code page for output (no adjustments) - //ado.Mode=2; - ado.Open(); - - ado.WriteText(content); - ado.SaveToFile(file, 2); - ado.Close(); - } - - if (typeof String.prototype.startsWith != 'function') { - // see below for better implementation! - String.prototype.startsWith = function (str){ - return this.indexOf(str) === 0; - }; - } - - - var evaluate=false; - var filename=ARGS.Item(0); - if(filename.toLowerCase().startsWith("e?")) { - filename=filename.substring(2,filename.length); - evaluate=true; - } - var content=getContent(filename); - var newContent=content; - var find=""; - var replace=""; - - for (var i=1;i http://social.technet.microsoft.com/wiki/contents/articles/5169.vbscript-sendkeys-method.aspx"); -} - -function parseArgs(){ - - if (ARGS.Length < 3) { - WScript.Echo("insufficient arguments"); - printHelp(); - WScript.Quit(43); - } - - title=ARGS.Item(1); - keys=ARGS.Item(2); -} - - -function escapeRegExp(str) { - return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); -} - -function replaceAll(str, find, replace) { - return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); -} - -parseArgs(); -//in case the script is called with CALL command the carets will be doubled -keys=replaceAll(keys,"^^","^"); - -if (title === "") { - sh.SendKeys(keys); - WScript.Quit(0); -} -if (sh.AppActivate(title)){ - sh.SendKeys(keys); - WScript.Quit(0); -} else { - WScript.Echo("Failed to find application with title " + title); - WScript.Quit(1); -} diff --git a/hybrids/jscript/shellCopy.bat b/hybrids/jscript/shellCopy.bat deleted file mode 100644 index 8208ae2..0000000 --- a/hybrids/jscript/shellCopy.bat +++ /dev/null @@ -1,62 +0,0 @@ -@if (@x)==(@y) @end /***** jscript comment ****** - @echo off - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - exit /b %errorlevel% - -***** end comment *********/ - -var FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ShellObj=new ActiveXObject("Shell.Application"); - -var ARGS = WScript.Arguments; -var scriptName=ARGS.Item(0); -var move = false; - -if (ARGS.Length == 0 ) { - WScript.Echo("Uses shell.application to move/copy files. Usage:"); - WScript.Echo(scriptName + "source destinationDirectory [move]"); - WScript.Echo("Example:"); - WScript.Echo("call " + scriptName + "\"C:\\file.txt\" \"D:\\folder\" "); - WScript.Echo("To move files:"); - WScript.Echo("call " + scriptName + "\"C:\\*.txt\" \"D:\\folder\" yes"); - WScript.Quit(0); -} - -if (ARGS.Length < 3 ) { - WScript.Echo("ERROR: not enough arguments"); - WScript.Quit(1); -} - - -if (ARGS.Length > 3 ) { - if (ARGS.Item(3).toLowerCase() == "true") { - move = true; - } -} - -var source = ARGS.Item(1); -var destination = ARGS.Item(2); - -//options values -var YES_TO_ALL=16; -var YESTA_NEW_NAMES=312 - - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} - -destination = getFullPath(destination); - -if (!FSOObj.FolderExists(destination)) { - WScript.Echo("ERROR: directory " + destination + " does not exists"); - WScript.Quit(1); -} - -var folder = ShellObj.NameSpace(destination); - -if (move) { - folder.MoveHere(source,YESTA_NEW_NAMES); -} else { - folder.CopyHere(source,YESTA_NEW_NAMES); -} diff --git a/hybrids/jscript/shortcutJS.bat b/hybrids/jscript/shortcutJS.bat deleted file mode 100644 index 1cb7396..0000000 --- a/hybrids/jscript/shortcutJS.bat +++ /dev/null @@ -1,216 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment -@echo off - -cscript //E:JScript //nologo "%~f0" "%~nx0" %* - -exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ - - - var args=WScript.Arguments; - var scriptName=args.Item(0); - //var adminPermissions= false; - var edit= false; - - function printHelp() { - WScript.Echo(scriptName + " -linkfile link -target target [-linkarguments linkarguments] "+ - " [-description description] [-iconlocation iconlocation] [-hotkey hotkey] "+ - " [-windowstyle 1|3|7] [-workingdirectory workingdirectory] [-adminpermissions yes|no]"); - WScript.Echo(); - WScript.Echo(scriptName + " -edit link [-target target] [-linkarguments linkarguments] "+ - " [-description description] [-iconlocation iconlocation] [-hotkey hotkey] "+ - " [-windowstyle 1|3|7] [-workingdirectory workingdirectory] [-adminpermissions yes|no]"); - WScript.Echo(); - WScript.Echo(scriptName + " -examine link"); - WScript.Echo(); - WScript.Echo(" More info: http://msdn.microsoft.com/en-us/library/xk6kst2k%28v=vs.84%29.aspx "); - - - - } - - // reads the given .lnk file as a char array - function getlnkChars(lnkPath) { - // :: http://www.dostips.com/forum/viewtopic.php?f=3&t=3855&start=15&p=28898 :: - var ado = WScript.CreateObject("ADODB.Stream"); - ado.Type = 2; // adTypeText = 2 - - ado.CharSet = "iso-8859-1"; // code page with minimum adjustments for input - ado.Open(); - ado.LoadFromFile(lnkPath); - - var adjustment = "\u20AC\u0081\u201A\u0192\u201E\u2026\u2020\u2021" + - "\u02C6\u2030\u0160\u2039\u0152\u008D\u017D\u008F" + - "\u0090\u2018\u2019\u201C\u201D\u2022\u2013\u2014" + - "\u02DC\u2122\u0161\u203A\u0153\u009D\u017E\u0178" ; - - - var fs = new ActiveXObject("Scripting.FileSystemObject"); - var size = (fs.getFile(lnkPath)).size; - - var lnkBytes = ado.ReadText(size); - ado.Close(); - var lnkChars=lnkBytes.split(''); - for (var indx=0;indx 255 ) { - lnkChars[indx] = String.fromCharCode(128 + adjustment.indexOf(lnkChars[indx])); - } - } - return lnkChars; - - } - - - function hasAdminPermissions(lnkPath) { - return (getlnkChars(lnkPath))[21].charCodeAt(0) == 32 ; - } - - - function setAdminPermissions(lnkPath , flag) { - lnkChars=getlnkChars(lnkPath); - var ado = WScript.CreateObject("ADODB.Stream"); - ado.Type = 2; // adTypeText = 2 - ado.CharSet = "iso-8859-1"; // right code page for output (no adjustments) - //ado.Mode=2; - ado.Open(); - // setting the 22th byte to 32 - if (flag) { - lnkChars[21]=String.fromCharCode(32); - } else { - lnkChars[21]=String.fromCharCode(0); - } - ado.WriteText(lnkChars.join("")); - ado.SaveToFile(lnkPath, 2); - ado.Close(); - - } - - function examine(lnkPath) { - - var fs = new ActiveXObject("Scripting.FileSystemObject"); - if (!fs.FileExists(lnkPath)) { - WScript.Echo("File " + lnkPath + " does not exist"); - WScript.Quit(2); - } - - var oWS = new ActiveXObject("WScript.Shell"); - var oLink = oWS.CreateShortcut(lnkPath); - - WScript.Echo(""); - WScript.Echo(lnkPath + " properties:"); - WScript.Echo(""); - WScript.Echo("Target:" + oLink.TargetPath); - WScript.Echo("Icon Location:" + oLink.IconLocation); - WScript.Echo("Description:" + oLink.Description); - WScript.Echo("Hotkey:" + oLink.HotKey ); - WScript.Echo("Working Directory:" + oLink.WorkingDirectory); - WScript.Echo("Window style:" + oLink.WindowStyle); - WScript.Echo("Admin Permissions:" + hasAdminPermissions(lnkPath)); - - WScript.Quit(0); - } - - - if (WScript.Arguments.Length==1 || args.Item(1).toLowerCase() == "-help" || args.Item(1).toLowerCase() == "-h" ) { - printHelp(); - WScript.Quit(0); - } - - if (WScript.Arguments.Length % 2 == 0 ) { - WScript.Echo("Illegal arguments "); - printHelp(); - WScript.Quit(1); - } - - if ( args.Item(1).toLowerCase() == "-examine" ) { - - var linkfile = args.Item(2); - examine(linkfile); - } - - if ( args.Item(1).toLowerCase() == "-edit" ) { - var linkfile = args.Item(2); - edit=true; - } - - if(!edit) { - for (var arg = 1;arg<5;arg=arg+2) { - - if ( args.Item(arg).toLowerCase() == "-linkfile" ) { - var linkfile = args.Item(arg+1); - } - - if (args.Item(arg).toLowerCase() == "-target") { - var target = args.Item(arg+1); - } - } - } - - if (typeof linkfile === 'undefined') { - WScript.Echo("Link file not defined"); - printHelp(); - WScript.Quit(2); - } - - if (typeof target === 'undefined' && !edit) { - WScript.Echo("Target not defined"); - printHelp(); - WScript.Quit(3); - } - - - var oWS = new ActiveXObject("WScript.Shell"); - var oLink = oWS.CreateShortcut(linkfile); - - - if(typeof target === 'undefined') { - var startIndex=3; - } else { - var startIndex=5; - oLink.TargetPath = target; - } - - - for (var arg = startIndex ; arg\&]/gim , function(s) { - return "&#" + s.charCodeAt(0) + ";"; - }); - }; - - -function printToConsole(fileContent){ - //WScript.Echo(fileContent); - WScript.Echo(fileContent.toHtmlEntities()); -} - -function printToFile(fileContent,file){ - writeContent(fileContent.toHtmlEntities(),file); - -} - -if (WScript.Arguments.Length > 1) { - var outputFile=WScript.Arguments.Item(1); - printToFile(outputFile,getFileContent(inputFile)); -} else { - printToConsole(getFileContent(inputFile)); -} diff --git a/hybrids/jscript/tooltipInfo.bat b/hybrids/jscript/tooltipInfo.bat deleted file mode 100644 index 0ce5d07..0000000 --- a/hybrids/jscript/tooltipInfo.bat +++ /dev/null @@ -1,385 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -//gets an information that normally is acquired by right click-details -// can get image dimensions , media file play time and etc. - -////// -FSOObj = new ActiveXObject("Scripting.FileSystemObject"); -var ARGS = WScript.Arguments; -if (ARGS.Length < 1 ) { - WScript.Echo("No file passed"); - WScript.Echo("Usage:"); - WScript.Echo(" Item [magic_number]"); - WScript.Echo(" for number meanings open the script with text editor"); - WScript.Quit(1); -} -var filename=ARGS.Item(0); -var objShell=new ActiveXObject("Shell.Application"); -var number=-1; -///// -try{ - if (ARGS.Length > 1) { - number=parseInt(ARGS.Item(1)); - } -}catch(err){ - WScript.Echo(err.message); - WScript.Echo("parsing failed"); - WScript.Quit(1); -} - - -if (number<-1 || number >288 ) { - WScript.Echo("Out of range number [-1 - 288]"); - WScript.Quit(2); -} - - -//fso -ExistsItem = function (path) { - return FSOObj.FolderExists(path)||FSOObj.FileExists(path); -} - -getFullPath = function (path) { - return FSOObj.GetAbsolutePathName(path); -} -// - -//paths -getParent = function(path){ - var splitted=path.split("\\"); - var result=""; - for (var s=0;s> a/4 // 8 to 11 - ).toString(16) // in hexadecimal - : ( // or otherwise a concatenated string: - [1e7] + // 10000000 + - -1e3 + // -1000 + - -4e3 + // -4000 + - -8e3 + // -80000000 + - -1e11 // -100000000000, - ).replace( // replacing - /[018]/g, // zeroes, ones, and eights with - b // random hex digits - ) -} - -WScript.Echo(UUIDv4()); diff --git a/hybrids/jscript/winhttpjs.bat b/hybrids/jscript/winhttpjs.bat deleted file mode 100644 index fed98c5..0000000 --- a/hybrids/jscript/winhttpjs.bat +++ /dev/null @@ -1,598 +0,0 @@ -@if (@X) == (@Y) @end /* JScript comment - @echo off - - rem :: the first argument is the script name as it will be used for proper help message - cscript //E:JScript //nologo "%~f0" "%~nx0" %* - - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -// used resources - -// update 12.10.15 -// osvikvi(https://github.com/osvikvi) has nodited that the -password option is not set , so this is fixed - -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384058(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384055(v=vs.85).aspx -//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx - -// global variables and constants - - -// ---------------------------------- -// -- asynch requests not included -- -// ---------------------------------- - - -//todo - save responceStream instead of responceBody !! -//todo - set all winthttp options ->//https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx -//todo - log all options -//todo - improve help message . eventual verbose option - - -var ARGS = WScript.Arguments; -var scriptName = ARGS.Item(0); - -var url = ""; -var saveTo = ""; - -var user = 0; -var pass = 0; - -var proxy = 0; -var bypass = 0; -var proxy_user = 0; -var proxy_pass = 0; - -var certificate = 0; - -var force = true; -var ignoreCertError = false; - -var body = ""; - -//ActiveX objects -var WinHTTPObj = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); -var FileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); -var AdoDBObj = new ActiveXObject("ADODB.Stream"); - -// HttpRequest SetCredentials flags. -var proxy_settings = 0; - -// -HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0; -HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1; - -//timeouts and their default values -var RESOLVE_TIMEOUT = 0; -var CONNECT_TIMEOUT = 90000; -var SEND_TIMEOUT = 90000; -var RECEIVE_TIMEOUT = 90000; - -//HttpRequestMethod -var http_method = 'GET'; - -//header -var header_file = ""; - -//report -var reportfile = ""; - -//test-this: -var use_stream = false; - -//autologon policy -var autologon_policy = 1; //0,1,2 - - -//headers will be stored as multi-dimensional array -var headers = []; - -//user-agent -var ua = ""; - -//escape URL -var escape = false; - -function printHelp() { - WScript.Echo(scriptName + " - sends HTTP request and saves the request body as a file and/or a report of the sent request"); - WScript.Echo(scriptName + " url [-force yes|no] [-user username -password password] [-proxy proxyserver:port] [-bypass bypass_list]"); - WScript.Echo(" [-proxyuser proxy_username -proxypassword proxy_password] [-certificate certificateString]"); - WScript.Echo(" [-method GET|POST|PATCH|DELETE|HEAD|OPTIONS|CONNECT]"); - WScript.Echo(" [-saveTo file] - to print response to console use con"); - - WScript.Echo(" [-sendTimeout int(milliseconds)]"); - WScript.Echo(" [-resolveTimeout int(milliseconds)]"); - WScript.Echo(" [-connectTimeout int(milliseconds)]"); - WScript.Echo(" [-receiveTimeout int(milliseconds)]"); - - WScript.Echo(" [-autologonPolicy 1|2|3]"); - WScript.Echo(" [-proxySettings 1|2|3] (https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059(v=vs.85).aspx)"); - - //header - WScript.Echo(" [-headers-file header_file]"); - //reportfile - WScript.Echo(" [-reportfile reportfile]"); - WScript.Echo(" [-ua user-agent]"); - WScript.Echo(" [-ua-file user-agent-file]"); - - WScript.Echo(" [-escape yes|no]"); - - WScript.Echo(" [-body body-string]"); - WScript.Echo(" [-body-file body-file]"); - WScript.Echo(" [-ignoreCertError yes|no]"); - - WScript.Echo("-force - decide to not or to overwrite if the local files exists"); - WScript.Echo("-ignoreCertError - ignore certificate error"); - - WScript.Echo("proxyserver:port - the proxy server"); - WScript.Echo("bypass- bypass list"); - WScript.Echo("proxy_user , proxy_password - credentials for proxy server"); - WScript.Echo("user , password - credentials for the server"); - WScript.Echo("certificate - location of SSL certificate"); - WScript.Echo("method - what HTTP method will be used.Default is GET"); - WScript.Echo("saveTo - save the responce as binary file"); - WScript.Echo(" "); - WScript.Echo("Header file should contain key:value pairs.Lines starting with \"#\" will be ignored."); - WScript.Echo("value should NOT be enclosed with quotes"); - WScript.Echo(" "); - WScript.Echo("Examples:"); - - WScript.Echo(scriptName + " http://somelink.com/somefile.zip -saveTo c:\\somefile.zip -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\""); - WScript.Echo(scriptName + " http://somelink.com/something.html -method POST -certificate \"LOCAL_MACHINE\\Personal\\My Middle-Tier Certificate\" -header c:\\header_file -reportfile c:\\reportfile.txt"); - WScript.Echo(scriptName + "\"http://somelink\" -method POST -header hdrs.txt -reportfile reportfile2.txt -saveTo responsefile2 -ua \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36\" -body-file some.json"); - -} - -function parseArgs() { - // - if (ARGS.Length < 2) { - WScript.Echo("insufficient arguments"); - printHelp(); - WScript.Quit(43); - } - // !!! - url = ARGS.Item(1); - // !!! - if (ARGS.Length % 2 != 0) { - WScript.Echo("illegal arguments"); - printHelp(); - WScript.Quit(44); - } - - for (var i = 2; i < ARGS.Length - 1; i = i + 2) { - var arg = ARGS.Item(i).toLowerCase(); - var next = ARGS.Item(i + 1); - - - try { - switch (arg) { // the try-catch is set mainly because of the parseInts - case "-force": - if (next == "no") { - force = false; - } - break; - case "-ignorecerterror": - if (next == "yes") { - ignoreCertError = true; - } - break; - case "-escape": - if (next == "yes") { - escape = true; - } - break; - case "-saveto": - saveTo = next; - break; - case "-user": - case "-u": - user = next; - break; - case "-pass": - case "-password": - case "-p": - pass = next; - break; - case "-proxy": - proxy = next; - break; - case "-bypass": - bypass = next; - break; - case "-proxyuser": - case "-pu": - proxy_user = next; - break; - case "-proxypassword": - case "-pp": - proxy_pass = next; - break; - case "-ua": - ua = next; - break; - case "-ua-file": - ua = readFile(next); - break; - case "-body": - body = next; - break; - case "-usestream": - //WScript.Echo("~~"); - if (next.toLowerCase() === "yes") { - use_stream = true - }; - break; - case "-body-file": - body = readFile(next); - break; - case "-certificate": - certificate = next; - break; - case "-method": - switch (next.toLowerCase()) { - case "post": - http_method = 'POST'; - break; - case "get": - http_method = 'GET'; - break; - case "head": - http_method = 'HEAD'; - break; - case "put": - http_method = 'PUT'; - break; - case "options": - http_method = 'OPTIONS'; - break; - case "connect": - http_method = 'CONNECT'; - break; - case "patch": - http_method = 'PATCH'; - break; - case "delete": - http_method = 'DELETE'; - break; - default: - WScript.Echo("Invalid http method passed " + next); - WScript.Echo("possible values are GET,POST,DELETE,PUT,CONNECT,PATCH,HEAD,OPTIONS"); - WScript.Quit(1326); - break; - } - break; - case "-headers-file": - case "-header": - headers = readPropFile(next); - break; - case "-reportfile": - reportfile = next; - break; - //timeouts - case "-sendtimeout": - SEND_TIMEOUT = parseInt(next); - break; - case "-connecttimeout": - CONNECT_TIMEOUT = parseint(next); - break; - case "-resolvetimeout": - RESOLVE_TIMEOUT = parseInt(next); - break; - case "-receivetimeout": - RECEIVE_TIMEOUT = parseInt(next); - break; - - case "-autologonpolicy": - autologon_policy = parseInt(next); - if (autologon_policy > 2 || autologon_policy < 0) { - WScript.Echo("out of autologon policy range"); - WScript.Quit(87); - }; - break; - case "-proxysettings": - proxy_settings = parseInt(next); - if (proxy_settings > 2 || proxy_settings < 0) { - WScript.Echo("out of proxy settings range"); - WScript.Quit(87); - }; - break; - default: - WScript.Echo("Invalid command line switch: " + arg); - WScript.Quit(1405); - break; - } - } catch (err) { - WScript.Echo(err.message); - WScript.Quit(1348); - } - } -} - -stripTrailingSlash = function(path) { - while (path.substr(path.length - 1, path.length) == '\\') { - path = path.substr(0, path.length - 1); - } - return path; -} - -function existsItem(path) { - return FileSystemObj.FolderExists(path) || FileSystemObj.FileExists(path); -} - -function deleteItem(path) { - if (FileSystemObj.FileExists(path)) { - FileSystemObj.DeleteFile(path); - return true; - } else if (FileSystemObj.FolderExists(path)) { - FileSystemObj.DeleteFolder(stripTrailingSlash(path)); - return true; - } else { - return false; - } -} - -//------------------------------- -//---------------------- -//---------- -//----- -//-- -function request(url) { - - try { - - WinHTTPObj.Open(http_method, url, false); - if (proxy != 0 && bypass != 0) { - WinHTTPObj.SetProxy(proxy_settings, proxy, bypass); - } - - if (proxy != 0) { - WinHTTPObj.SetProxy(proxy_settings, proxy); - } - - if (user != 0 && pass != 0) { - WinHTTPObj.SetCredentials(user, pass, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER); - } - - if (proxy_user != 0 && proxy_pass != 0) { - WinHTTPObj.SetCredentials(proxy_user, proxy_pass, HTTPREQUEST_SETCREDENTIALS_FOR_PROXY); - } - - if (certificate != 0) { - WinHTTPObj.SetClientCertificate(certificate); - } - - if (ignoreCertError) { - // https://stackoverflow.com/questions/20261520/microsoft-jscript-bypassing-certificate-error - WScript.Echo("ignore cert error..."); - WinHTTPObj.Option(4) = 0x3300; // SslErrorIgnoreFlags = IgnoreAll; - } - - //set autologin policy - WinHTTPObj.SetAutoLogonPolicy(autologon_policy); - //set timeouts - WinHTTPObj.SetTimeouts(RESOLVE_TIMEOUT, CONNECT_TIMEOUT, SEND_TIMEOUT, RECEIVE_TIMEOUT); - - if (headers.length !== 0) { - WScript.Echo("Sending with headers:"); - for (var i = 0; i < headers.length; i++) { - WinHTTPObj.SetRequestHeader(headers[i][0], headers[i][1]); - WScript.Echo(headers[i][0] + ":" + headers[i][1]); - } - WScript.Echo(""); - } - - if (ua !== "") { - //user-agent option from: - //WinHttpRequestOption enumeration - // other options can be added like bellow - //https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx - WinHTTPObj.Option(0) = ua; - } - if (escape) { - WinHTTPObj.Option(3) = true; - } - if (trim(body) === "") { - WinHTTPObj.Send(); - } else { - WinHTTPObj.Send(body); - } - - var status = WinHTTPObj.Status - } catch (err) { - WScript.Echo(err.message); - WScript.Quit(666); - } - - //////////////////////// - // report // - //////////////////////// - - if (reportfile != "") { - - //var report_string=""; - var n = "\r\n"; - var report_string = "Status:" + n; - report_string = report_string + " " + WinHTTPObj.Status; - report_string = report_string + " " + WinHTTPObj.StatusText + n; - report_string = report_string + " " + n; - report_string = report_string + "Response:" + n; - report_string = report_string + WinHTTPObj.ResponseText + n; - report_string = report_string + " " + n; - report_string = report_string + "Headers:" + n; - report_string = report_string + WinHTTPObj.GetAllResponseHeaders() + n; - - WinHttpRequestOption_UserAgentString = 0; // Name of the user agent - WinHttpRequestOption_URL = 1; // Current URL - WinHttpRequestOption_URLCodePage = 2; // Code page - WinHttpRequestOption_EscapePercentInURL = 3; // Convert percents - // in the URL - // rest of the options can be seen and eventually added using this as reference - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa384108(v=vs.85).aspx - - report_string = report_string + "URL:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URL) + n; - - report_string = report_string + "URL Code Page:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_URLCodePage) + n; - - report_string = report_string + "User Agent:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_UserAgentString) + n; - - report_string = report_string + "Escapped URL:" + n; - report_string = report_string + WinHTTPObj.Option(WinHttpRequestOption_EscapePercentInURL) + n; - - prepareateFile(force, reportfile); - - WScript.Echo("Writing report to " + reportfile); - - writeFile(reportfile, report_string); - - } - - switch (status) { - case 200: - WScript.Echo("Status: 200 OK"); - break; - default: - WScript.Echo("Status: " + status); - WScript.Echo("Status was not OK. More info -> https://en.wikipedia.org/wiki/List_of_HTTP_status_codes"); - } - - //if as binary - if (saveTo.toLowerCase() === "con") { - WScript.Echo(WinHTTPObj.ResponseText); - } - if (saveTo !== "" && saveTo.toLowerCase() !== "con") { - prepareateFile(force, saveTo); - try { - - if (use_stream) { - writeBinFile(saveTo, WinHTTPObj.ResponseStream); - } else { - writeBinFile(saveTo, WinHTTPObj.ResponseBody); - } - - } catch (err) { - WScript.Echo("Failed to save the file as binary.Attempt to save it as text"); - AdoDBObj.Close(); - prepareateFile(true, saveTo); - writeFile(saveTo, WinHTTPObj.ResponseText); - } - } - WScript.Quit(status); -} - -//-- -//----- -//---------- -//---------------------- -//------------------------------- - -function prepareateFile(force, file) { - if (force && existsItem(file)) { - if (!deleteItem(file)) { - WScript.Echo("Unable to delete " + file); - WScript.Quit(8); - } - } else if (existsItem(file)) { - WScript.Echo("Item " + file + " already exist"); - WScript.Quit(9); - } -} - -function writeBinFile(fileName, data) { - AdoDBObj.Type = 1; - AdoDBObj.Open(); - AdoDBObj.Position = 0; - AdoDBObj.Write(data); - AdoDBObj.SaveToFile(fileName, 2); - AdoDBObj.Close(); -} - -function writeFile(fileName, data) { - AdoDBObj.Type = 2; - AdoDBObj.CharSet = "iso-8859-1"; - AdoDBObj.Open(); - AdoDBObj.Position = 0; - AdoDBObj.WriteText(data); - AdoDBObj.SaveToFile(fileName, 2); - AdoDBObj.Close(); -} - - -function readFile(fileName) { - //check existence - try { - if (!FileSystemObj.FileExists(fileName)) { - WScript.Echo("file " + fileName + " does not exist!"); - WScript.Quit(13); - } - if (FileSystemObj.GetFile(fileName).Size === 0) { - return ""; - } - var fileR = FileSystemObj.OpenTextFile(fileName, 1); - var content = fileR.ReadAll(); - fileR.Close(); - return content; - } catch (err) { - WScript.Echo("Error while reading file: " + fileName); - WScript.Echo(err.message); - WScript.Echo("Will return empty string"); - return ""; - } -} - -function readPropFile(fileName) { - //check existence - resultArray = []; - if (!FileSystemObj.FileExists(fileName)) { - WScript.Echo("(headers)file " + fileName + " does not exist!"); - WScript.Quit(15); - } - if (FileSystemObj.GetFile(fileName).Size === 0) { - return resultArray; - } - var fileR = FileSystemObj.OpenTextFile(fileName, 1); - var line = ""; - var k = ""; - var v = ""; - var lineN = 0; - var index = 0; - try { - WScript.Echo("parsing headers form " + fileName + " property file "); - while (!fileR.AtEndOfStream) { - line = fileR.ReadLine(); - lineN++; - index = line.indexOf(":"); - if (line.indexOf("#") === 0 || trim(line) === "") { - continue; - } - if (index === -1 || index === line.length - 1 || index === 0) { - WScript.Echo("Invalid line " + lineN); - WScript.Quit(93); - } - k = trim(line.substring(0, index)); - v = trim(line.substring(index + 1, line.length)); - resultArray.push([k, v]); - } - fileR.Close(); - return resultArray; - } catch (err) { - WScript.Echo("Error while reading headers file: " + fileName); - WScript.Echo(err.message); - WScript.Echo("Will return empty array"); - return resultArray; - } -} - -function trim(str) { - return str.replace(/^\s+/, '').replace(/\s+$/, ''); -} - -function main() { - parseArgs(); - request(url); -} -main(); diff --git a/hybrids/jscript/write.bat b/hybrids/jscript/write.bat deleted file mode 100644 index 3c6e821..0000000 --- a/hybrids/jscript/write.bat +++ /dev/null @@ -1,7 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - cscript //E:JScript //nologo "%~nx0" %* - exit /b %errorlevel% -@if (@X)==(@Y) @end JScript comment */ -// writes a string to the console without a new line at the end -if(WScript.Arguments.Count()>0) WScript.StdOut.Write(WScript.Arguments.Item(0)); diff --git a/hybrids/jscript/xpath.bat b/hybrids/jscript/xpath.bat deleted file mode 100644 index 934644d..0000000 --- a/hybrids/jscript/xpath.bat +++ /dev/null @@ -1,106 +0,0 @@ -@if (@X)==(@Y) @end /* JScript comment - @echo off - - set "file=%~f1" - set "xpath=%~2" - set "option=%~3" - - if "%~2" equ "" ( - goto :printHelp - ) - - for %%# in ("-h" "-help" "/h" "/help" "") do ( - if /i "%~1" equ %%# ( - goto :printHelp - ) - ) - - if exist "%file%\" ( - echo file "%~1" does not exist - exit /b 3 - ) - if not exist "%file%" ( - echo file "%~1" does not exist - exit /b 4 - ) - - - cscript //E:JScript //nologo "%~f0" /file:"%file%" /xpath:"%xpath%" /option:"%option%" - - exit /b %errorlevel% - - :printHelp - echo %~nx0 prints the value (or list of values) - echo of xml attribute/node in xml by given xpath expression - echo( - echo Usage: - echo( - echo call %~nx0 "filePath" "xpathExpression" - exit /b %errorlevel% - -@if (@X)==(@Y) @end JScript comment */ - -if (WScript.Arguments.length<2) -{ - WScript.Echo("Not enough arguments"); - WScript.Quit(3); -} - - -function escapeRegExp(str) { - return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); -} - -function replaceAll(str, find, replace) { - return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); -} - -var xp=WScript.Arguments.Named.Item("xpath"); -xp=replaceAll(xp,"'",'"'); - -var option=WScript.Arguments.Named.Item("option"); - -var objDoc; -var objNodes; -var loaded; - -try { - objDoc = WScript.CreateObject("MSXML.DOMDocument"); - loaded=objDoc.load(WScript.Arguments.Named.Item("file")); -} catch (err){ - WScript.Echo("Error while parsing the xml"); - WScript.Echo(err.message); - WScript.Quit(1); -} - -if(!loaded){ - WScript.Echo("Error while parsing the xml"); - WScript.Echo(""); - WScript.Echo("Error Code:"+objDoc.parseError.errorCode); - WScript.Echo(""); - WScript.Echo("Line:"+objDoc.parseError.line+" Posotion:"+objDoc.parseError.filepos); - WScript.Echo(""); - WScript.Echo("Reason:"+objDoc.parseError.reason); - WScript.Echo(""); - WScript.Echo("URL:"+objDoc.parseError.url); - WScript.Echo(""); - WScript.Echo(objDoc.parseError.srcText); - WScript.Quit(5); -} - -try { - var objNodes = objDoc.selectNodes(xp); -} catch (err){ - WScript.Echo("invalid xpath expression"); - WScript.Echo(err.message); - WScript.Quit(2); -} - -for (var i=0;i=objNodes.length){ - WScript.Echo("Out of nodes range"); - WScript.Echo("Nodes length is: "+objNodes.length); - WScript.Quit(35); - } - if(option.toLowerCase()=="xml"){ - WScript.Echo(objNodes.item(node_n).xml); - } else { - WScript.Echo(objNodes.item(node_n).text); - } -} else { - for (var i=0;i"%tmp%\makecab.dir.ddf" -; -;setlocal enableDelayedExpansion -;for /d /r "%dir_to_cab%" %%a in (*) do ( -; -; set "_dir=%%~pna" -; set "destdir=%dir_name%!_dir:%path_to_dir%=!" -; (echo(.Set DestinationDir=!destdir!>>"%tmp%\makecab.dir.ddf") -; for %%# in ("%%a\*") do ( -; (echo("%%~f#" /inf=no>>"%tmp%\makecab.dir.ddf") -; ) -;) -;(echo(.Set DestinationDir=!dir_name!>>"%tmp%\makecab.dir.ddf") -; for %%# in ("%~f1\*") do ( -; -; (echo("%%~f#" /inf=no>>"%tmp%\makecab.dir.ddf") -; ) - -;makecab /F "%~f0" /f "%tmp%\makecab.dir.ddf" /d DiskDirectory1=%cd% /d CabinetNameTemplate=%cab_file%.cab -;del /q /f "%tmp%\makecab.dir.ddf" -;exit /b %errorlevel% - -;; -;;;; rem end of the batch part ;;;;; - -;;;; directives part ;;;;; -;; -.New Cabinet -.set GenerateInf=OFF -.Set Cabinet=ON -.Set Compress=ON -.Set UniqueFiles=ON -.Set MaxDiskSize=1215751680; - -.set RptFileName=nul -.set InfFileName=nul - -.set MaxErrors=1 -;; -;;;; end of directives part ;;;;; diff --git a/hybrids/makecab/fileinf.bat b/hybrids/makecab/fileinf.bat deleted file mode 100644 index f4178bf..0000000 --- a/hybrids/makecab/fileinf.bat +++ /dev/null @@ -1,79 +0,0 @@ -; @echo off -;;goto :end_help -;:fileinf -;;setlocal DsiableDelayedExpansion -;;; -;;; -;;; fileinf /l list of full file paths separated with ; and surrounded with quotes -;;; fileinf /f text file with a list of files to be processed ( one on each line ) -;;; fileinf /? prints the help -;;; -;;; Batch/MakeCab hybrid file that gets property information about binary files -;;; by Vasil "npocmaka" Arnaudov -;;; -;; the ;s are standard delimtiers in batch and remark symbols for makecab -;; directive files which allows to combine them both in one file -;; http://stackoverflow.com/questions/20535473/how-can-i-determined-the-version-of-windows-installer-in-a-bat-file -;; http://stackoverflow.com/questions/1706892/how-do-i-retrieve-the-version-of-a-file-from-a-batch-file-on-windows-vista -;; alternative of FILEVER from windows 2003 res tool kit -;;:end_help - -; REM Creating a Newline variable (the two blank lines are required!) -; set NLM=^ - - -; set NL=^^^%NLM%%NLM%^%NLM%%NLM% -; if "%~1" equ "/?" type "%~f0" | find ";;;" | find /v "find" && exit /b 0 -; if "%~2" equ "" type "%~f0" | find ";;;" | find /v "find" && exit /b 0 -; setlocal enableDelayedExpansion -; if "%~1" equ "/l" ( -; set "_files=%~2" -; echo !_files:;=%NL%! -; echo !_files:;=%NL%!>"%TEMP%\file.paths" -; set _process_file="%TEMP%\file.paths" -; goto :get_info -; ) - -; if "%~1" equ "/f" if exist "%~2" ( -; set _process_file="%~2" -; goto :get_info -; ) - -; echo incorect parameters & exit /b 1 -; :get_info -; set "file_info=" - -; rem :: check if all passed files exist -; for /f "useback tokens=* delims=" %%f in ("%TEMP%\file.paths") do ( -; if not exist "%%~f" ( -; echo file %%~f does not exist -; exit /b 5 -; ) -;) - -; makecab /d InfFileName=%TEMP%\file.inf /d "DiskDirectory1=%TEMP%" /f "%~f0" /f %_process_file% /v0>nul -; for /f "usebackq skip=4 delims=" %%f in ("%TEMP%\file.inf") do ( -; set "file_info=%%f" -; echo !file_info:,=%nl%! -; ) - -; endlocal -;endlocal -; del /q /f %TEMP%\file.inf 2>nul -; del /q /f %TEMP%\file.path 2>nul -; exit /b 0 - -.set DoNotCopyFiles=on -.set DestinationDir=; -.set RptFileName=nul -.set InfFooter=; -.set InfHeader=; -.Set ChecksumWidth=8 -.Set InfDiskLineFormat=; -.Set Cabinet=off -.Set Compress=off -.Set GenerateInf=ON -.Set InfDiskHeader=; -.Set InfFileHeader=; -.set InfCabinetHeader=; -.Set InfFileLineFormat=",file:*file*,date:*date*,size:*size*,csum:*csum*,time:*time*,vern:*ver*,vers:*vers*,lang:*lang*" diff --git a/hybrids/mshta/OpticalDrivesCount.bat b/hybrids/mshta/OpticalDrivesCount.bat deleted file mode 100644 index ede2ae4..0000000 --- a/hybrids/mshta/OpticalDrivesCount.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -for /f "usebackq" %%a in (`mshta ^"javascript^:code^(close^(new ActiveXObject^(^'Scripting.FileSystemObject^'^).GetStandardStream^(1^).Write^(new ActiveXObject^(^'IMAPI2.MsftDiscMaster2.1^'^).Count^)^)^); ^"`) do set OptDrives=%%a -echo %OptDrives% diff --git a/hybrids/mshta/atob.bat b/hybrids/mshta/atob.bat deleted file mode 100644 index d712fab..0000000 --- a/hybrids/mshta/atob.bat +++ /dev/null @@ -1,58 +0,0 @@ -@echo off - -setlocal - -if "%~1" equ "" ( - echo %~nx1 - decodes string to base 64 - echo example: - echo %~nx1 string [rtrnVar] - echo( - echo rtrnVar - variable where where the result will be stored. - echo if not defined the result will be printed in console - exit /b 0 -) - -set "string=%~1" - - - -for /f "delims=" %%# in ('echo %string%^|mshta.exe "%~f0"') do ( - set dec=%%# -) - -if "%~2" neq "" ( - endlocal & ( - set "%~2=%dec%" - exit /b %errorlevel% - ) -) else ( - endlocal & ( - echo %dec% - exit /b %errorlevel% - ) -) - -exit /b %errorlevel% - - - - diff --git a/hybrids/mshta/btoa.bat b/hybrids/mshta/btoa.bat deleted file mode 100644 index 6d1f207..0000000 --- a/hybrids/mshta/btoa.bat +++ /dev/null @@ -1,58 +0,0 @@ -@echo off - -setlocal - -if "%~1" equ "" ( - echo %~nx1 - encodes string to base 64 - echo example: - echo %~nx1 string [rtrnVar] - echo( - echo rtrnVar - variable where where the result will be stored. - echo if not defined the result will be printed in console - exit /b 0 -) - -set "string=%~1" - - - -for /f "delims=" %%# in ('echo %string%^|mshta.exe "%~f0"') do ( - set b64=%%# -) - -if "%~2" neq "" ( - endlocal & ( - set "%~2=%b64%" - exit /b %errorlevel% - ) -) else ( - endlocal & ( - echo %b64% - exit /b %errorlevel% - ) -) - -exit /b %errorlevel% - - - - diff --git a/hybrids/mshta/freeMem.bat b/hybrids/mshta/freeMem.bat deleted file mode 100644 index 854f0ac..0000000 --- a/hybrids/mshta/freeMem.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -for /f "usebackq" %%a in (`mshta ^"javascript^:code^(close^(new ActiveXObject^(^'Scripting.FileSystemObject^'^).GetStandardStream^(1^).Write^(GetObject^(^'winmgmts:^'^).ExecQuery^(^'Select * from Win32_PerfFormattedData_PerfOS_Memory^'^).ItemIndex^(0^).AvailableMBytes^)^)^); ^"`) do set free_mem=%%a -echo %free_mem% diff --git a/hybrids/mshta/printClip.bat b/hybrids/mshta/printClip.bat deleted file mode 100644 index 134075b..0000000 --- a/hybrids/mshta/printClip.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -:printclip -:: prints clipboard data -for /f "usebackq tokens=* delims=" %%i in ( - `mshta "javascript:Code(close(new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(clipboardData.getData('Text'))));"` -) do ( - (echo(%%i) -) -exit /b %errorlevel% diff --git a/hybrids/mshta/say.bat b/hybrids/mshta/say.bat deleted file mode 100644 index c82f34f..0000000 --- a/hybrids/mshta/say.bat +++ /dev/null @@ -1,6 +0,0 @@ -:speak -@echo off -setlocal enableDelayedExpansion -set "toSay=%~1" -mshta "javascript:code(close((v=new ActiveXObject('SAPI.SpVoice')).GetVoices()&&v.Speak('!toSay!')))" -endLocal diff --git a/hybrids/mshta/soundPlayer.bat b/hybrids/mshta/soundPlayer.bat deleted file mode 100644 index f7b9888..0000000 --- a/hybrids/mshta/soundPlayer.bat +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/hybrids/mshta/start.bckgrnd.bat b/hybrids/mshta/start.bckgrnd.bat deleted file mode 100644 index 35d83a3..0000000 --- a/hybrids/mshta/start.bckgrnd.bat +++ /dev/null @@ -1,85 +0,0 @@ -@echo off -setlocal - - rem ::: check if help need to be called ::: - rem : - - for /f "usebackq tokens=1,2,3,4,5,6,7 delims= " %%A in ('-h -help /help /h "" /? -?') do ( - for %%# in (%%A %%B %%C %%D "%%~E" ) do if /i "%~1" equ "%%~#" goto :help - - if "%~1" equ "%%~F" goto :help - if "%~1" equ "%%~G" goto :help - ) - - rem : - rem ::: end help checks ::: - - - rem ::: arg parsing and checking ::: - rem : - set /A shifter=1 - set "workdir=." - set "commandline= " - set "exec=" - - - :arg_parser - - - if "%~1" equ "-exec" set "exec=%~2" - if "%~1" equ "-commandline" set "commandline=%~2" - if "%~1" equ "-workdir" set "workdir=%~2" - - shift & shift - set /A shifter=shifter + 1 - - if %shifter% EQU 4 goto :end_arg_parser - if "%~1" EQU "" goto :end_arg_parser - goto :arg_parser - - - :end_arg_parser - rem : - rem ::: end of arg parsing ::: - - rem ::: validate arguments ::: - rem : - - set "exec_path=" - if not defined exec echo executable not defined && exit /b 1 - if exist "%exec%" for /f "usebackq" %%E in ("%exec%") do set "exec_path=%%~dpfsnxE" - if not defined exec_path for %%E in ("%exec%") do set "exec_path=%%~dpfsnx$PATH:E" - if not defined exec_path echo executable "%exec%" does not exist && exit /b 2 - for %%W in ("%workdir%") do set "workdir=%%~dpW" - if not exist "%workdir%" echo target directory "%workdir%" not exist && exit /b 3 - echo %commandline% | find """" >nul 2>&1 && ( echo command line contains quotes and you don't want this & exit /b 4) - - rem : - rem ::: end of validation ::: - - rem ::: construct mshta command ::: - rem : - set "vbs_w32process=vbscript:execute("set w32ps=GetObject(""winmgmts:"").Get(""Win32_ProcessStartup"").SpawnInstance_():w32ps.ShowWindow=0:" - set "vbs_stream_writer=CreateObject(""Scripting.FileSystemObject"").GetStandardStream(1).Write(""Rerurn code: ""&" - set "vbs_start_process=GetObject(""winmgmts:"").Get(""Win32_Process"").Create(""%exec_path% %commandline%"",""%workdir%"",w32ps,pid)&vbCrLf&""PID: ""&pid)" - set "vbs_end=:Close")" - - rem : - rem ::: end construct mshta command ::: - - rem ::: call mshta ::: - rem : - mshta %vbs_w32process%%vbs_stream_writer%%vbs_start_process%%vbs_end%| findstr "^" - rem : - rem ::: end mshta call ::: - - -endlocal -exit /b 0 - -:help -echo %~nx0 starts a background/invisible process and return its PID -echo %~nx0 -exec executable [-commandline commandLine] [-workdir workdir] -echo uses mshta/vbscript and does not require enabled WSH -echo by Vasil "npocmaka" Arnaudov -exit /b 0 diff --git a/hybrids/mshta/ui.extensions/buttons.bat b/hybrids/mshta/ui.extensions/buttons.bat deleted file mode 100644 index 2732e26..0000000 --- a/hybrids/mshta/ui.extensions/buttons.bat +++ /dev/null @@ -1,71 +0,0 @@ -@if (@X)==(@Y) @end /*JScript comment -@echo off -echo -- %~f0 -- -if "%~1" equ "" ( - echo usage: - echo %~nx0 [button_name [button_name[..]]] - exit /b 0 -) - -( - echo %* -)|( - mshta "about:buttonsChoose:
" -)|( - for /f "tokens=* delims=" %%R in ('more') do @( - @(@echo(%%R) - ) -) - -rem echo %result% -exit /b 0 - -**/ - -var argline; -var errmessage; -var elements = new Array(); -var textnode; - - -function clckd(a){ - var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1); - close(fso.Write(a)); -} - -function prepare(){ - window.resizeTo(400,250); - try { - var fso2= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0); - argline=fso2.ReadLine(); - var args=argline.split(" "); - } catch (err) { - errmessage = "cannot get the input"; - var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1); - fso.Write(errmessage); - } - - var br_element = document.createElement('br');; - - var i; - var temp_element; - for (i = 0; i < args.length; i++) { - temp_element = document.createElement("input"); - temp_element.setAttribute("type", "button"); - temp_element.setAttribute("value", args[i]); - temp_element.setAttribute("number", i+1); - temp_element.onclick= function(){clckd(this.number)}; - elements.push(temp_element); - } - - for (i = 0; i < args.length; i++) { - var br_element = document.createElement('br');; - var container = document.getElementById('container'); - if (args[i] != "") { - textnode=document.createTextNode(args[i]); - container.appendChild(elements[i]); - container.appendChild(br_element); - } - } - container.appendChild(br_element); -} diff --git a/hybrids/mshta/ui.extensions/choose.button.bat b/hybrids/mshta/ui.extensions/choose.button.bat deleted file mode 100644 index b6a2bf7..0000000 --- a/hybrids/mshta/ui.extensions/choose.button.bat +++ /dev/null @@ -1,52 +0,0 @@ -@if (@X)==(@Y) @end /*** Javascript comment -@echo off -rem :: a UI extension example for bat files -rem :: that not require enabled WSH as it uses mshta -rem :: As mshta allows JScript directives it is possible to -rem :: to use the batch file as javascript source file -rem :: seen first here -rem :: https://groups.google.com/forum/#!msg/alt.msdos.batch.nt/b8q29_uLfQs/4uoVLRo1uOsJ -rem :: -rem :: by Vasil "npocmaka" Arnaudov -rem :: - - -( - mshta "about:chooserbuttons:" -)|( - for /f "tokens=* delims=" %%B in ('more') do @( - echo selected buton: %%B - ) -) -exit /b 0 - -**/ - -function clckd(a){ - var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1); - close(fso.Write(a)); -} - -function prepare(){ - window.resizeTo(200,150); - var element1 = document.createElement("input"); - element1.setAttribute("type", "button"); - element1.setAttribute("value", "yep"); - //this will not work on IE or MSHTA - // element1.setAttribute("onclick", "clckd('yep');"); - element1.onclick= function() {clckd('yep');}; - - var element2 = document.createElement("input"); - element2.setAttribute("type", "button"); - element2.setAttribute("value", "nope"); - //this will not work on IE or MSHTA - // element2.setAttribute("onclick", "clckd('nope');"); - element2.onclick= function() {clckd('nope');}; - - - var container = document.getElementById('container'); - container.appendChild(element1); - container.appendChild(element2); - - //alert(document.getElementById('container').innerHTML); -} diff --git a/hybrids/mshta/ui.extensions/countdown.bat b/hybrids/mshta/ui.extensions/countdown.bat deleted file mode 100644 index 82eeaf6..0000000 --- a/hybrids/mshta/ui.extensions/countdown.bat +++ /dev/null @@ -1,74 +0,0 @@ - - - -It's the final countdown - - -

Seconds left

-
--
- - - - - diff --git a/hybrids/mshta/ui.extensions/passwordSubmiter.bat b/hybrids/mshta/ui.extensions/passwordSubmiter.bat deleted file mode 100644 index 867df7d..0000000 --- a/hybrids/mshta/ui.extensions/passwordSubmiter.bat +++ /dev/null @@ -1,37 +0,0 @@ - - - -Password submitter - - - - - -
- - - - diff --git a/hybrids/mshta/ui.extensions/radioButtons.bat b/hybrids/mshta/ui.extensions/radioButtons.bat deleted file mode 100644 index f99de61..0000000 --- a/hybrids/mshta/ui.extensions/radioButtons.bat +++ /dev/null @@ -1,94 +0,0 @@ -@if (@X)==(@Y) @end /*JScript comment -@echo off - -if "%~1" equ "" ( - echo usage: - echo %~nx0 [radio_button_name [radio_button_name[..]]] - exit /b 0 -) - -( - echo %* -)|( - mshta "about:radioChoose:
" -)|( - for /f "tokens=* delims=" %%R in ('more') do @( - @(@echo(%%R) - ) -) - -rem echo %result% -exit /b 0 - -**/ - -var argline; -var result; -var errmessage; -var elements = new Array(); -var textnode; - -function clckd(){ - // alert(a); - var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1); - - //fso.Write(line); - //close(fso.Write(a)); - - for (i = 0; i < elements.length; i++) { - if (elements[i].checked ) { - close(fso.Write(i+1)); - //alert(i+1); - } - } - -} - -function prepare(){ - - try { - var fso2= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(0); - argline=fso2.ReadLine(); - //alert(argline); - //argline = "radio gaga radio gogo someone still loves you" - var args=argline.split(" "); - } catch (err) { - errmessage = "cannot get the input"; - var fso= new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1); - fso.Write(errmessage); - } - - var br_element = document.createElement('br');; - - var i; - var temp_element; - for (i = 0; i < args.length; i++) { - temp_element = document.createElement("input"); - temp_element.setAttribute("type", "radio"); - temp_element.setAttribute("name", "gaga"); - temp_element.setAttribute("value", i); - temp_element.setAttribute("id", "gaga".concat(i)); - temp_element.value=args[i]; - elements.push(temp_element); - } - - for (i = 0; i < args.length; i++) { - var br_element = document.createElement('br');; - var container = document.getElementById('container'); - if (args[i] != "") { - textnode=document.createTextNode(args[i]); - container.appendChild(elements[i]); - container.appendChild(textnode); - container.appendChild(br_element); - } - } - container.appendChild(br_element); - var submit = document.createElement("input"); - - submit.setAttribute("type", "button"); - submit.setAttribute("value", "submit"); - submit.onclick= function() {clckd();}; - container.appendChild(submit); - - //alert(document.getElementById('container').innerHTML); -} diff --git a/hybrids/mshta/ui.extensions/userInput.bat b/hybrids/mshta/ui.extensions/userInput.bat deleted file mode 100644 index 82d26fe..0000000 --- a/hybrids/mshta/ui.extensions/userInput.bat +++ /dev/null @@ -1,55 +0,0 @@ - - - -User Input - - - - - -
- - - - diff --git a/hybrids/mshta/weekNumber.bat b/hybrids/mshta/weekNumber.bat deleted file mode 100644 index 0fbbc55..0000000 --- a/hybrids/mshta/weekNumber.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off - - for /f %%W in ( - 'mshta vbscript:Execute("createobject(""scripting.filesystemobject"").GetStandardStream(1).writeline(DatePart(""ww"",Now()))"^^^&close^)' - ) do @( - set "weekn=%%W" - ) - -echo %weekn% diff --git a/hybrids/wsh/EjectCD.bat b/hybrids/wsh/EjectCD.bat deleted file mode 100644 index d780b85..0000000 --- a/hybrids/wsh/EjectCD.bat +++ /dev/null @@ -1,69 +0,0 @@ -@cScript.EXE //noLogo "%~f0?.WSF" //job:info %~nx0 %* -@exit /b 0 - - - - diff --git a/hybrids/wsh/vbexecutor.bat b/hybrids/wsh/vbexecutor.bat deleted file mode 100644 index 3fb1315..0000000 --- a/hybrids/wsh/vbexecutor.bat +++ /dev/null @@ -1,65 +0,0 @@ -@echo off -set job=Execute -for %%# in (-h /h /help -help) do ( - if "%~1" equ "%%~#" ( - (echo() - echo Executes vbscript statements - (echo() - echo Usage: - echo %~nx0 [function] statement [statement] - (echo() - echo double quotes in ststements must be replaced with single quotes - echo in ordred to avoid collision with command line arguments - (echo() - echo default function is /Execute - echo other options are /Eval and /ExecuteGlobal - (echo() - echo examples: - echo call %~nx0 "Wscript.Echo('example')" "WScript.Sleep(3000)" - echo call %~nx0 /Execute "Wscript.Echo('example')" "WScript.Sleep(3000)" - echo call %~nx0 /ExecuteGlobal "Function SumTwo(a,b):SumTwo=a+b:End Function" "WScript.Echo(SumTwo(2,2))" - echo call %~nx0 /Eval "WScript.Echo(2+2)" - exit /b 0 - ) -) - -cscript /noLogo "%~f0?.WSF" //job:execute %* -exit /b %ErrorLevel% - - - - diff --git a/hybrids/wsh/win32process.bat b/hybrids/wsh/win32process.bat deleted file mode 100644 index a778439..0000000 --- a/hybrids/wsh/win32process.bat +++ /dev/null @@ -1,326 +0,0 @@ - -@echo off -cscript //nologo //job:win32process "%~f0?.wsf" "%~nx0" %* -exit /b %errorlevel% - - - - - - - - - - diff --git a/math/isInteger.bat b/math/isInteger.bat deleted file mode 100644 index 6ec5042..0000000 --- a/math/isInteger.bat +++ /dev/null @@ -1,25 +0,0 @@ -@echo off - -:isInterer input [returnVar] -setlocal enableDelayedexpansion -set "input=%~1" - -if "!input:~0,1!" equ "-" ( - set "input=!input:~1!" -) else ( - if "!input:~0,1!" equ "+" set "input=!input:~1!" -) - -for %%# in (1 2 3 4 5 6 7 8 9 0) do ( - if not "!input!" == "" ( - set "input=!input:%%#=!" - ) -) - -if "!input!" equ "" ( - set result=true -) else ( - set result=false -) - -endlocal & if "%~2" neq "" (set %~2=%result%) else echo %result% diff --git a/math/removeLeadingZeroes.bat b/math/removeLeadingZeroes.bat deleted file mode 100644 index 2716d29..0000000 --- a/math/removeLeadingZeroes.bat +++ /dev/null @@ -1,11 +0,0 @@ -::http://stackoverflow.com/questions/14762813/remove-leading-zeros-in-batch-file - -:: exit /b number automatically removes leading zeroes and does not take the number as octal -:: also requires small piece of coding , but could affect the performance a little bit - -:removeLeadingZeroes number [rtnVar] -setlocal - cmd /c exit /b %~1 -endlocal && ( - if "%~2" neq "" (set %~2=%errorlevel%) else echo %errorlevel% -) diff --git a/network/bitsDownloader.bat b/network/bitsDownloader.bat deleted file mode 100644 index 7bf21dd..0000000 --- a/network/bitsDownloader.bat +++ /dev/null @@ -1,61 +0,0 @@ - @echo off - setlocal - - :: uses bitsadmin utility to download a file - :: bitsadmin is not available in winXP Home edition - :: the only way to download a file with 'pure' batch - :download - - if "%2" equ "" ( - call :help - exit /b 5 - ) - - if "%1" equ "" ( - call :help - exit /b 6 - ) - set url=%~1 - set file=%~2 - rem ---- - if "%~3" NEQ "" ( - set /A timeout=%~3 - ) else ( - set timeout=5 - ) - - bitsadmin /cancel download >nul - bitsadmin /create /download download >nul - call bitsadmin /addfile download "%url%" "%CD%\%file%" >nul - bitsadmin /resume download >nul - bitsadmin /setproxysettings download AUTODETECT >nul - - set /a attempts=0 - :repeat - set /a attempts +=1 - if "%attempts%" EQU "10" ( - echo TIMED OUT - endlocal - exit /b 1 - ) - bitsadmin /info download /verbose | find "STATE: ERROR" >nul 2>&1 && endlocal && bitsadmin /cancel download && echo SOME KIND OF ERROR && exit /b 2 - bitsadmin /info download /verbose | find "STATE: SUSPENDED" >nul 2>&1 && endlocal && bitsadmin /cancel download &&echo FILE WAS NOT ADDED && exit /b 3 - bitsadmin /info download /verbose | find "STATE: TRANSIENT_ERROR" >nul 2>&1 && endlocal && bitsadmin /cancel download &&echo TRANSIENT ERROR && exit /b 4 - bitsadmin /info download /verbose | find "STATE: TRANSFERRED" >nul 2>&1 && goto :finishing - - w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:%timeout% >nul 2>&1 - goto :repeat - :finishing - bitsadmin /complete download >nul - echo download finished - endlocal - goto :eof - - :help - echo %~n0 url file [timeout] - echo. - echo url - the source for download - echo file - file name in local directory where the file will be stored - echo timeout - number in seconds between each check if download is complete (attempts are 10) - echo. - goto :eof diff --git a/network/checkNet.bat b/network/checkNet.bat deleted file mode 100644 index 0d7de32..0000000 --- a/network/checkNet.bat +++ /dev/null @@ -1,51 +0,0 @@ -@echo off -:checkNet - -:: -:: checks if a network interface with given name is connected -:: or not through ipconfig command -:: - -setlocal - -if "%~1" equ "" echo no network name passed & exit /b 1 - -set "network_to_check=%~1" -if "%network_to_check:~-1,1%" NEQ ":" set "network_to_check=%network_to_check%:" - -set nt=0 -setlocal enableDelayedExpansion -for /f "skip=3 delims=" %%$ in ('ipconfig') do ( - set "line=%%$" - ! echo %%$ >&2 - - if "!line:~0,1!" neq " " ( - set /a nt=nt+1 - set _nt!nt!=!line! - - ) else ( - ! echo ---- - for /f %%# in ("!nt!") do ( - ! echo a:%%# - ! echo --- %%# --- - - set "_nt!nt!=!_nt%%#! !line!" - - ) - ) -) - -set _nt|find /i "%network_to_check%" >nul 2>nul||( - echo network not found - exit /b 1 -) - -set _nt| find /i "%network_to_check%"|find /i "Media disconnected" >nul 2>nul&&( - echo disconnected - exit /b 1 -) - -echo connected - -endlocal -endlocal diff --git a/other/ArrayListPOC.bat b/other/ArrayListPOC.bat deleted file mode 100644 index b2633a3..0000000 --- a/other/ArrayListPOC.bat +++ /dev/null @@ -1,575 +0,0 @@ -@echo off -rem ---- allows to call a subroutine inside FOR loop ---- -rem ---- thanks to Aacini ---- -rem --- by Vasil "npocmaka" Arnaudov -if /I "%1" equ "call" shift & shift & goto %2 - -rem ============================== -rem == checking paramateres == -rem ============================== - -if "%1" equ "-?" ( - call :help -) - -if "%1" equ "?" ( - call :help -) - -if "%1" equ "/?" ( - call :help -) - -if "%1" equ "h" ( - call :help -) - -if "%1" equ "-h" ( - call :help -) - -if "%1" equ "help" ( - call :help -) - -if "%1" equ "-help" ( - call :help -) - -if "%1" equ "" ( - call :help -) - -if "%1" equ "remote_machine" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :remote_macine %2 - ) -) - -if "%1" equ "add" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :add "%~2" - ) -) - -if "%1" equ "getvalueat" ( - if "%~3" equ "" ( - call :help - goto :eof - ) else ( - call :getvalueat %2 %3 - ) -) - -if "%1" equ "length" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :length %2 - ) -) - -if "%1" equ "fast_list" ( - call :fast_list -) - -if "%1" equ "list" ( - call :list -) - -if "%1" equ "indexof" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :indexof %2 - ) -) - -if "%1" equ "lastindexof" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :lastindexof %2 - ) -) - -if "%1" equ "contains" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :contains %2 - ) -) - -if "%1" equ "pop" ( - call :pop -) - -if "%1" equ "queue" ( - call :queue -) - -if "%1" equ "deleteat" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :deleteat %2 - ) -) - -if "%1" equ "push" ( - if "%~2" equ "" ( - call :help - goto :eof - ) else ( - call :push %2 - ) -) - -if "%1" equ "insert" ( - if "%~3" equ "" ( - call :help - goto :eof - ) else ( - call :insert %2 %3 - ) -) - -if "%1" equ "isempty" ( - call :isempty -) - -if "%1" equ "clear" ( - call :clear -) - -if "%1" equ "clear" ( - call :clear -) - -goto :eof - -rem ================================ -rem === subroutines definitions ==== -rem ================================ - -rem --- if it is not set will be ignored --- -:remote_macine [%1 - the remote machine] - set remote_machine=\\%~1 -goto eof - -:add [%1 - item to add] -setlocal - for /f "tokens=1-2 delims==" %%J in ('at %remote_machine% 00:00 /every:31 "%~1"') do ( - echo added item %%K : %~1 - goto :endadd - ) - :endadd -endlocal & goto :eof - - -:getvalueat [%1 - position of the item;%2 - variable to store value at] -setlocal - set /a errorlevel=0 - set var=%2 - - for /f "tokens=* delims= " %%E in ('at %remote_machine% %1 ^| find "The AT job ID does not exist" ') do ( - if "%%E" NEQ "" ( - echo IndexOutOfBoundException - goto :eof - ) - ) - - - for /f "tokens=1,* delims=: " %%I in ('at %remote_machine% %1 ^| find "Command:"') do ( - if "%%I" EQU "" ( - echo IndexOutOfBoundException - goto :eof - ) - set "variable=%%~J" >nul - ) - - -endlocal & call set "%var%=%variable%" -goto :eof - -:length [%1 - value to store length at ] - returns 0 on empty. -setlocal - set var=%1 - set /a variable=0 - setlocal ENABLEDELAYEDEXPANSION - for /f "eol=- tokens=1 delims= " %%L in ('at %remote_machine% ^| find "Each"') do ( - set /a variable=!variable!+1 - ) - endlocal & set variable=%variable% -endlocal & call set /a "%var%=%variable%" -goto :eof - -:fast_list - list elements and numbers -setlocal - rem -- check if there's local time settings hour suffix - for /f "tokens=1,2,3 delims= " %%T in ('date /t') do ( - if "%%V" EQU "" ( - set /a last_column=5 - ) else ( - set /a last_column=6 - ) - ) - - - if %last_column% EQU 5 ( - for /f "eol=- tokens=1-6,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - echo %%A : %%~F - ) - ) - - if %last_column% EQU 6 ( - for /f "eol=- tokens=1-5,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - echo %%A : %%~F - ) - ) - - -endlocal -goto :eof - -:list - list elements and numbers -setlocal - call :length len - setlocal ENABLEDELAYEDEXPANSION - for /l %%L in (1,1,!len!) do ( - call :getvalueat %%L val >nul - echo %%L : !val! - ) - endlocal -endlocal -goto :eof - - - -:indexof [%1 - check if is contained] - echoes first index -setlocal - rem -- check if there's local time settings hour suffix - - for /f "tokens=1,2,3 delims= " %%T in ('date /t') do ( - if "%%V" EQU "" ( - set /a last_column=5 - ) else ( - set /a last_column=6 - ) - ) - set /a index=-1 - - if %last_column% EQU 5 ( - for /f "eol=- tokens=1-6,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - if "%%~F" EQU "%~1" ( - set /a index=%%A >nul - goto :endcheck - ) - ) - ) - - if %last_column% EQU 6 ( - for /f "eol=- tokens=1-5,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - if "%%~F" EQU "%~1" ( - set /a index=%%A - goto :endcheck - ) - ) - ) - - :endcheck -endlocal & echo %index% -goto :eof - - -:lastindexof [%1 - check if is contained] - echoes last index -setlocal - rem -- check if there's local time settings hour suffix - - for /f "tokens=1,2,3 delims= " %%T in ('date /t') do ( - if "%%V" EQU "" ( - set /a last_column=5 - ) else ( - set /a last_column=6 - ) - ) - - set /a index=-1 - - if %last_column% EQU 5 ( - for /f "eol=- tokens=1-6,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - if "%%~F" EQU "%~1" ( - set /a index=%%A >nul - ) - ) - ) - - if %last_column% EQU 6 ( - for /f "eol=- tokens=1-5,* delims= " %%A in ('at %remote_machine% ^| find "Each"') do ( - if "%%~F" EQU "%~1" ( - set /a index=%%A - ) - ) - ) - - :endcheck -endlocal & echo %index% -goto :eof - -:contains [%1 - check if is contained] set errorlevel to -1 if is contained -setlocal - set /a errorlevel=0 - set result= - for /f "usebackq" %%C in (`%~f0 call :indexof %~1`) do ( - set result=%%C - ) - - if "%result%" NEQ "-1" ( - set /a errorlevel=1 - ) else ( - set /a errorlevel=0 - ) -endlocal & set /a errorlevel=%errorlevel% -goto :eof - - -:pop - deletes and echoes the first element in the list -setlocal - - if "%1" EQU "" ( - call :length left - ) else ( - set /a left=%1 > nul - ) - - if %left% equ 0 ( - call at %remote_machine% /delete /yes - goto :eof - ) - - - call :getvalueat %left% current_element - call :pop %left%-1 - - rem :: get first element - if %left% EQU 1 ( - echo %current_element% - goto :eof - ) - - at %remote_machine% 00:00 /every:31 %current_element% >nul - -endlocal -goto :eof - -:queue - delete and return the last element in the list -setlocal - - if [%len%] EQU [] ( - call :length len - ) - - if "%len%" EQU "0" ( - goto :eof - ) - - if "%1" EQU "" ( - call :length left - ) else ( - set /a left=%1 > nul - ) - if %left% equ 0 ( - call at %remote_machine% /delete /yes - goto :eof - ) - - call :getvalueat %left% current_element - call :queue %left%-1 - - if %left% EQU %len% ( - echo %current_element% - goto :eof - ) - - at %remote_machine% 00:00 /every:31 "%current_element%" >nul - -endlocal -goto :eof - -:deleteat [%1 - number of the element to be deleted] - returns the value of deleted element -setlocal - set /a deleteat=%1 - - if "%2" EQU "" ( - call :length left - ) else ( - set /a left=%2 > nul - ) - if %left% equ 0 ( - call at %remote_machine% /delete /yes - goto :eof - ) - - call :getvalueat %left% current_element - call :deleteat %deleteat% %left%-1 - - if %left% EQU %deleteat% ( - echo %current_element% - goto :eof - ) - - at %remote_machine% 00:00 /every:31 "%current_element%" >nul - -endlocal -goto :eof - -:push [%1 - set this value on the first position] -setlocal - set "push=%~1" - - if "%2" EQU "" ( - call :length left - ) else ( - set /a left=%2 > nul - ) - if %left% equ 0 ( - at %remote_machine% /delete /yes - at %remote_machine% 00:00 /every:31 %push% >nul - goto :eof - ) - - call :getvalueat %left% current_element - call :push "%push%" %left%-1 - - at %remote_machine% 00:00 /every:31 "%current_element%" >nul - -endlocal -goto :eof - -:insert [%1 - value to insert , %2 - position to insert ] -setlocal - set "insert=%~1" - set /a pos=%2 - - - if [%len%] EQU [] ( - call :length len - setlocal enabledelayedexpansion - if !pos! GTR !len! ( - echo echo IndexOutOfBoundException - goto :eof - ) - endlocal - ) - - - if "%3" EQU "" ( - call :length left - ) else ( - set /a left=%3 > nul - ) - if %left% equ 0 ( - at %remote_machine% /delete /yes - goto :eof - ) - - call :getvalueat %left% current_element - call :insert "%insert%" %pos% %left%-1 - - if %left% EQU %pos% ( - at %remote_machine% 00:00 /every:31 "%insert%" >nul - ) - - at %remote_machine% 00:00 /every:31 "%current_element%" >nul - -endlocal -goto :eof - -:clear - clears the list - at %remote_machine% /delete /yes >nul -goto :eof - -:isempty - checks if the list is empty -setlocal - call :length len - if "%len%" EQU "0" ( - echo YES - ) else ( - echo NO - ) -endlocal -goto :eof - -:size - echoes the length -setlocal - call :length len - echo %len% -endlocal -goto :eof - -:help -echo %~n0 is a script that uses AT command for enumerated list. -echo you can have only one instance of this list - except if you're -echo not using remote host for storage (see remote_host key switch). -echo The list will be persisted on the system even after restart. -echo Following command swithes are slow are not recommended for often usage: -echo pop,queue,deleteat,push,insert - as they are using recursion and delete and -echo preset the values again (at does not reuse jobs ids even if the jobs are deleted ). -echo Use this script only on your own responsibility.For more info check commands bellow. -echo\ -echo %~n0 ^| [-? ^|? ^|/? ^|-h ^|-help ^|help ^|h] prints this message -echo - prints this message -echo\ -echo %~n0 add item - adds an item to the list.Avoid following sympls -echo as they are special symbols for cmd.exe : ( , ), ^&, ^| , ^> , ^< , ^^ , %% , ^= , : , ~ . -echo\ -echo %~n0 getvalueat position variable_name - gets the value -echo at given possition and store the result to the variable name. -echo If outflows the list prinst "indexOutOfBoundException". -echo\ -echo %~n0 length variable_name - get the length and stores the result in variable_name. -echo If list is empty sets 0. -echo\ -echo %~n0 remote_macine machine_name - sets remote machine where the list is stored. -echo\ -echo %~n0 fastlist - lists elements using internal AT command listing -echo the elements will be not sorted by number but will run faster than list. -echo\ -echo %~n0 list - lists all elements. -echo\ -echo %~n0 indexof value - returns the possition of first appearance of the given value. -echo\ -echo %~n0 lastindexof value - returns the possition of last appearance of given value. -echo\ -echo %~n0 contains value - check if the given value is contained in the -echo list.Set ERRORLEVEL to 1 if so. -echo\ -echo %~n0 pop - deletes the first element and echoes it's value. -echo\ -echo %~n0 queue - deletes the last element and echoes it's value -echo\ -echo %~n0 deleteat position - deletes an element on given position -echo and echoes it's value. -echo %~n0 push value - set an element on first possition with given value. -echo\ -echo %~n0 insert value position - insert an element with the given position and value. -echo\ -echo %~n0 clear - clears the list. -echo\ -echo %~n0 size - echoes the size (length). -echo\ -echo %~n0 isempty - checks if the list is empty . -echo\ -goto :eof diff --git a/other/beeper.bat b/other/beeper.bat deleted file mode 100644 index 24965c8..0000000 --- a/other/beeper.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -setlocal -::Define a Linefeed variable -(set LF=^ -%=-=% -) - -for /f eol^=^%LF%%LF%^ delims^= %%A in ( - 'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x07"' -) do echo(%%A diff --git a/other/continueEnter.bat b/other/continueEnter.bat deleted file mode 100644 index ab47893..0000000 --- a/other/continueEnter.bat +++ /dev/null @@ -1,5 +0,0 @@ -:: continue only after enter is pressed -:: Unlike set /p= will not save the typed non-enter keys -:: in the buffer -:: http://ss64.org/viewtopic.php?id=1695 -runas /user:# "" >nul 2>&1 diff --git a/other/listBrosers.bat b/other/listBrosers.bat deleted file mode 100644 index ae8e5f2..0000000 --- a/other/listBrosers.bat +++ /dev/null @@ -1,101 +0,0 @@ -@echo off -setlocal enableExtensions - -rem --- requires admin permissions --- - -echo. -echo. -echo INSTALLED BROWSERS -echo. -echo. - -rem ::::::::::::::::::::::::::::::::::::::::::::::::::::: -rem :: exporting registry values for installed browsers -rem ::::::::::::::::::::::::::::::::::::::::::::::::::::: - -rem for 64 bit systems -START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet -rem for 32 bit systems -if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet - -setLocal enableDelayedExpansion -for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do ( - rem extracting browser name from icon path - set "browser=%%B" - rem removing \DefaultIcon] string - set "browser=!browser:\DefaultIcon]=!" - rem get the browser name - for %%P in ("!browser!") do echo %%~nP -) -endLocal - -echo. -echo. -echo EXECUTABLES PATHS -echo. -echo. - -setLocal enableDelayedExpansion -for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe\\\",0\"^"') do ( - set "browser=%%~B" - set "browser=!browser:\\=\!" - echo !browser! - -) -setLocal enableDelayedExpansion -for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe,0\"^"') do ( - set "browser=%%~B" - set "browser=!browser:\\=\!" - set "browser=!browser:,0=!" - echo !browser! - -) -endLocal - - -rem delete temp file -del /Q /F "%Temp%\BROW3.reg" - - -echo. -echo. -echo DEFAULT BROWSER -echo. -echo. - -START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command -setLocal enableDelayedExpansion -for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do ( - set "default=%%B" - rem removing double slashes - set "default=!default:\\=\!" - rem removing end slash - set "default=!default:~0,-1!" - rem get the name - for %%D in ("!default!") do echo %%~nD -) -endLocal -del /Q /F "%Temp%\BROW5.reg" - -echo. -echo. -echo DEFAULT .HTML VIEWER -echo. -echo. - -START /W REGEDIT /E "%Temp%\BROW6.reg" HKEY_CLASSES_ROOT\htmlfile\shell\open\command -setLocal enableDelayedExpansion -for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW6.reg" ^| find "@"') do ( - set "default=%%B" - set "default=!default:\\=\!" - set "default=!default:~0,-1!" - for %%D in ("!default!") do echo %%~nD -) -endLocal -del /Q /F "%Temp%\BROW6.reg" -echo. -echo. -pause -:: -:: by Vasil "npocmaka" Arnaudov -:: diff --git a/other/listBrowsers.bat b/other/listBrowsers.bat deleted file mode 100644 index 8728e17..0000000 --- a/other/listBrowsers.bat +++ /dev/null @@ -1,98 +0,0 @@ -@echo off -:: list installed browsers -:: uses regedit so it's compatible with windows XP -setlocal enableExtensions - -echo. -echo. -echo INSTALLED BROWSERS -echo. -echo. - -rem ::::::::::::::::::::::::::::::::::::::::::::::::::::: -rem :: exporting registry values for installed browsers -rem ::::::::::::::::::::::::::::::::::::::::::::::::::::: - -rem for 64 bit systems -START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet -rem for 32 bit systems -if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet - -setLocal enableDelayedExpansion -for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do ( - rem extracting browser name from icon path - set "browser=%%B" - rem removing \DefaultIcon] string - set "browser=!browser:\DefaultIcon]=!" - rem get the browser name - for %%P in ("!browser!") do echo %%~nP -) -endLocal - -echo. -echo. -echo EXECUTABLES PATHS -echo. -echo. - -setLocal enableDelayedExpansion -for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe\\\",0\"^"') do ( - set "browser=%%~B" - set "browser=!browser:\\=\!" - echo !browser! - -) -setLocal enableDelayedExpansion -for /f "tokens=* delims=@=" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /B "@" ^| findstr /E ".exe,0\"^"') do ( - set "browser=%%~B" - set "browser=!browser:\\=\!" - set "browser=!browser:,0=!" - echo !browser! - -) -endLocal - - -rem delete temp file -del /Q /F "%Temp%\BROW3.reg" - - -echo. -echo. -echo DEFAULT BROWSER -echo. -echo. - -START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command -setLocal enableDelayedExpansion -for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do ( - set "default=%%B" - rem removing double slashes - set "default=!default:\\=\!" - rem removing end slash - set "default=!default:~0,-1!" - rem get the name - for %%D in ("!default!") do echo %%~nD -) -endLocal -del /Q /F "%Temp%\BROW5.reg" - -echo. -echo. -echo DEFAULT .HTML VIEWER -echo. -echo. - -START /W REGEDIT /E "%Temp%\BROW6.reg" HKEY_CLASSES_ROOT\htmlfile\shell\open\command -setLocal enableDelayedExpansion -for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW6.reg" ^| find "@"') do ( - set "default=%%B" - set "default=!default:\\=\!" - set "default=!default:~0,-1!" - for %%D in ("!default!") do echo %%~nD -) -endLocal -del /Q /F "%Temp%\BROW6.reg" -echo. -echo. -pause diff --git a/other/officeVersion.bat b/other/officeVersion.bat deleted file mode 100644 index 72ce36b..0000000 --- a/other/officeVersion.bat +++ /dev/null @@ -1,97 +0,0 @@ -@echo off -:office_ver -setlocal enableDelayedExpansion -echo %~1 | find /i "help" >nul 2>&1 && ( goto :help ) - -for /f "tokens=2 delims==" %%O in ('ftype ^|findstr /r /I "\\OFFICE[0-9]*" 2^>nul') do ( - set "verp=%%~O" - goto :end_for -) -:end_for - -for %%P in ("%verp%") do ( - set "off_path=%%~dpP" - for %%V in ("!off_path:~0,-1!") do ( - - set "office_version=%%~nV" - goto :end_for2 - ) -) -:end_for2 - -echo internal version: %office_version% -echo %office_version% | find /i "office7" >nul 2>&1&& ( - echo "Office 97" - if "%~1" neq "" ( endlocal & set "%~1=Office 97" - exit /b 0 - ) -) -echo %office_version% | find /i "office8" >nul 2>&1 && ( - echo "Office XP" - if "%~1" neq "" ( endlocal & set "%~1=Office XP" - exit /b 0 - ) -) -echo %office_version% | find /i "office9" >nul 2>&1 && ( - echo "Office 2000" - if "%~1" neq "" ( endlocal & set "%~1=Office 2000" - exit /b 0 - ) -) -echo %office_version% | find /i "office10" >nul 2>&1 && ( - echo "Office XP" - if "%~1" neq "" ( endlocal & set "%~1=Office XP" - exit /b 0 - ) -) -echo %office_version% | find /i "office11" >nul 2>&1 && ( - echo "Office 2003" - if "%~1" neq "" ( endlocal & set "%~1=Office 2003" - exit /b 0 - ) -) -echo %office_version% | find /i "office12" >nul 2>&1 && ( - echo "Office 2007" - if "%~1" neq "" ( endlocal & set "%~1=Office 2007" - exit /b 0 - ) -) -echo %office_version% | find /i "office14" >nul 2>&1 && ( - echo "Office 2010" - if "%~1" neq "" ( endlocal & set "%~1=Office 2010" - exit /b 0 - ) -) -echo %office_version% | find /i "office15" >nul 2>&1 && ( - echo "Office 2013" - if "%~1" neq "" ( endlocal & set "%~1=Office 2013" - exit /b 0 - ) -) - -echo %office_version% | find /i "office16" >nul 2>&1 && ( - echo "Office 2016" - if "%~1" neq "" ( endlocal & set "%~1=Office 2016" - exit /b 0 - ) -) - -endlocal -goto :eof -rem MAPPING: -rem Office 97 - 7.0 -rem Office 98 - 8.0 -rem Office 2000 - 9.0 -rem Office XP - 10.0 -rem Office 2003 - 11.0 -rem Office 2007 - 12.0 -rem Office 2010 - 14.0 -rem Office 2013 - 15.0 -rem Office 2016 - 16.0 -:help -echo %~n0 - displays current microsoft office version -echo %~n0 [RtnVar] -echo( -RtnVar - stores result in variable RtnVar -echo( -echo by Vasil "npocmaka" Arnaudov diff --git a/other/pushdCounter.bat b/other/pushdCounter.bat deleted file mode 100644 index af7f075..0000000 --- a/other/pushdCounter.bat +++ /dev/null @@ -1,37 +0,0 @@ -:pushd_counter -::http://ss64.org/viewtopic.php?id=1697 -@echo off -set prompt_backup=%prompt% -prompt $+ -( echo on - for %%a in (1) do ( @rem - ) -)>%temp%\p.tmp -@echo off -prompt %prompt_backup% -set "prompt_backup=" -for /f "usebackq tokens=1 delims=() " %%P in ("%temp%\p.tmp") do ( - set s=%%P -) -del %temp%\p.tmp /q >nul -setlocal EnableDelayedExpansion - set "s=#!s!" - set "len=0" - for %%A in (2187 729 243 81 27 9 3 1) do ( - set /A mod=2*%%A - for %%Z in (!mod!) do ( - if "!s:~%%Z,1!" neq "" ( - set /a "len+=%%Z" - set "s=!s:~%%Z!" - - ) else ( - if "!s:~%%A,1!" neq "" ( - set /a "len+=%%A" - set "s=!s:~%%A!" - ) - ) - ) - ) -endlocal & echo %len% -set "s=" -exit /b diff --git a/other/pushdCounterTmpF.bat b/other/pushdCounterTmpF.bat deleted file mode 100644 index 1821c36..0000000 --- a/other/pushdCounterTmpF.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -pushd >%temp%\temp.temp -type %temp%\temp.temp | find /c "\" -rem find /c "\" %temp%\temp.temp -del %temp%\temp.temp /q >nul diff --git a/other/setlocalLevelCounter.bat b/other/setlocalLevelCounter.bat deleted file mode 100644 index 9638f63..0000000 --- a/other/setlocalLevelCounter.bat +++ /dev/null @@ -1,5 +0,0 @@ -set "lev=" -(@for /l %%i in (1 1 33) do ( setlocal 2>nul && set lev=%%i ) && for /l %%o in (1 1 %lev% ) do ( endlocal & set lev=%lev%))&(set /a lev=32-lev) -echo %lev% - -:: http://ss64.org/viewtopic.php?id=1778 diff --git a/printing/printCHM.bat b/printing/printCHM.bat deleted file mode 100644 index 3e71cbb..0000000 --- a/printing/printCHM.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -if "%~1" equ "" ( - echo usage: - echo %~n0 file.chm - exit /b 1 -) - -if "%~x1" neq ".chm" ( - echo you need a file with .chm etension - exit /b 2 -) - -start "" /b /wait hh -decompile ~~ %~sf1 - -for /r "~~" %%h in (*.htm) do ( - rundll32.exe "%systemroot%\system32\mshtml.dll",PrintHTML "%%~fh" -) - -rd "~~" /s /q >nul 2>nul diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..efb3261 --- /dev/null +++ b/readme.md @@ -0,0 +1 @@ +this is looking much better already diff --git a/stringutils/countOfSubstrings.bat b/stringutils/countOfSubstrings.bat deleted file mode 100644 index 821116f..0000000 --- a/stringutils/countOfSubstrings.bat +++ /dev/null @@ -1,67 +0,0 @@ -@echo off -:checkCountOf string countOf [rtnrVar] -:: checks count of a substring in a string -setlocal EnableDelayedExpansion -set "string=aa" - -set "string=%~1" -set "checkCountOf=%~2" - -if "%~1" equ "" ( - if "%~3" neq "" ( - endlocal & ( - echo 0 - set "%~3=0" - exit /b 0 - ) - ) else ( - endlocal & ( - echo 0 - exit /b 0 - ) -) - - -) - -if "!checkCountOf!" equ "$" ( - set "string=#%string%#" - set "string=!string:%checkCountOf%%checkCountOf%=#%checkCountOf%#%checkCountOf%#!" -) else ( - set "string=$%string%$" - set "string=!string:%checkCountOf%%checkCountOf%=$%checkCountOf%$%checkCountOf%$!" -) - - -set LF=^ - - -rem ** Two empty lines are required -set /a counter=0 - - -for %%L in ("!LF!") DO ( - for /f "delims=" %%R in ("!checkCountOf!") do ( - set "var=!string:%%~R%%~R=%%~L!" - set "var=!var:%%~R=%%~L!" - - for /f "tokens=* delims=" %%# in ("!var!") do ( - set /a counter=counter+1 - ) - ) -) - -if !counter! gtr 0 ( - set /a counter=counter-1 -) - -if "%~3" neq "" ( - endlocal & ( - echo %counter% - set "%~3=%counter%" - ) -) else ( - endlocal & ( - echo %counter% - ) -) diff --git a/stringutils/endsWith.bat b/stringutils/endsWith.bat deleted file mode 100644 index 27f5c03..0000000 --- a/stringutils/endsWith.bat +++ /dev/null @@ -1,30 +0,0 @@ -:endsWith [%1 - string to be checked;%2 - string for checking ] - -@echo off -rem :: sets errorlevel to 1 if %1 ends with %2 else sets errorlevel to 0 - -setlocal EnableDelayedExpansion - -set "string=%~1" -set "checker=%~2" -rem set "var=!string:%~2=&echo.!" -set LF=^ - - -rem ** Two empty lines are required -rem echo off -for %%L in ("!LF!") DO ( - for /f "delims=" %%R in ("!checker!") do ( - rem set "var=!string:%%~R%%~R=%%~L!" - set "var=!string:%%~R=%%L#!" - ) -) -for /f "delims=" %%P in (""!var!"") DO ( - set "temp=%%~P" -) - -if "%temp%" EQU "#" ( - endlocal & exit /b 1 -) else ( - endlocal & exist /b 0 -) diff --git a/stringutils/indexOf.bat b/stringutils/indexOf.bat deleted file mode 100644 index 4f72cc0..0000000 --- a/stringutils/indexOf.bat +++ /dev/null @@ -1,28 +0,0 @@ -:indexof [%1 - string ; %2 - find index of ; %3 - if defined will store the result in variable with same name] -::http://ss64.org/viewtopic.php?id=1687 -@echo off -setlocal enableDelayedExpansion - -set "str=%~1" -set "s=!str:%~2=&rem.!" -set s=#%s% -if "%s%" equ "#%~1" endlocal& if "%~3" neq "" (set %~3=-1&exit /b 0) else (echo -1&exit /b 0) - - set "len=0" - for %%A in (2187 729 243 81 27 9 3 1) do ( - set /A mod=2*%%A - for %%Z in (!mod!) do ( - if "!s:~%%Z,1!" neq "" ( - set /a "len+=%%Z" - set "s=!s:~%%Z!" - - ) else ( - if "!s:~%%A,1!" neq "" ( - set /a "len+=%%A" - set "s=!s:~%%A!" - ) - ) - ) - ) - endlocal & if "%~3" neq "" (set %~3=%len%) else echo %len% -exit /b 0 diff --git a/stringutils/lastIndexOf.bat b/stringutils/lastIndexOf.bat deleted file mode 100644 index 334bb3f..0000000 --- a/stringutils/lastIndexOf.bat +++ /dev/null @@ -1,62 +0,0 @@ -:lastindexof [%1 - string ; %2 - find last index of ; %3 - if defined will store the result in variable with same name] -::http://ss64.org/viewtopic.php?id=1687 -@echo off -setlocal enableDelayedExpansion - - -set "str=%~1" -set "splitter=%~2" - -set LF=^ - - -rem ** Two empty lines are required -echo off -setlocal -for %%L in ("!LF!") DO ( - for /f "delims=" %%R in ("!splitter!") do ( - set "var=!str:%%R=%%L!" - ) -) - -for /f delims^=^" %%P in ("!var!") DO ( - set "last_part=%%~P" -) - -if "!last_part!" equ "" if "%~3" NEQ "" ( - echo "not contained" >2 - endlocal - set %~3=-1 - exit -) else ( - echo "not contained" >2 - endlocal - echo -1 -) -setlocal DisableDelayedExpansion - -set ^"\n=^^^%LF%%LF%^%LF%%LF%^^" -set $strLen=for /L %%n in (1 1 2) do if %%n==2 (%\n% - for /F "tokens=1,2 delims=, " %%1 in ("!argv!") do (%\n% - set "str=A!%%~2!"%\n% - set "len=0"%\n% - for /l %%A in (12,-1,0) do (%\n% - set /a "len|=1<<%%A"%\n% - for %%B in (!len!) do if "!str:~%%B,1!"=="" set /a "len&=~1<<%%A"%\n% - )%\n% - for %%v in (!len!) do endlocal^&if "%%~b" neq "" (set "%%~1=%%v") else echo %%v%\n% - ) %\n% -) ELSE setlocal enableDelayedExpansion ^& set argv=, - - -%$strlen% strlen,str -%$strlen% plen,last_part -%$strlen% slen,splitter - -set /a lio=strlen-plen-slen -endlocal & endlocal & endlocal & if "%~3" NEQ "" ( - set "%~3=%lio%" -) else ( - echo %lio% -) -exit /b 0 diff --git a/stringutils/reverse.bat b/stringutils/reverse.bat deleted file mode 100644 index fa5e37f..0000000 --- a/stringutils/reverse.bat +++ /dev/null @@ -1,37 +0,0 @@ -:reverse [%1 - string to reverse ; %2 - if defined will store the result in variable with same name] -@echo off -setlocal disableDelayedExpansion -set "str=%~1" -set LF=^ - - -rem ** Two empty lines are required -set ^"\n=^^^%LF%%LF%^%LF%%LF%^^" -set $strLen=for /L %%n in (1 1 2) do if %%n==2 (%\n% - for /F "tokens=1,2 delims=, " %%1 in ("!argv!") do (%\n% - set "str=A!%%~2!"%\n% - set "len=0"%\n% - for /l %%A in (12,-1,0) do (%\n% - set /a "len|=1<<%%A"%\n% - for %%B in (!len!) do if "!str:~%%B,1!"=="" set /a "len&=~1<<%%A"%\n% - )%\n% - for %%v in (!len!) do endlocal^&if "%%~b" neq "" (set "%%~1=%%v") else echo %%v%\n% - ) %\n% -) ELSE setlocal enableDelayedExpansion ^& set argv=, - -%$strLen% len,str -setlocal enableDelayedExpansion - -set /a half=len/2 -set "res=!str:~%half%,-%half%!" - -for /L %%C in (%half%,-1,0) do ( - set /a len=%len%-1-%%C - if %%C neq %half% ( - for %%c in (!len!) do ( - set "res=!str:~%%c,1!!res!!str:~%%C,1!" - ) - ) - -) -endlocal & endlocal & if "%~2" NEQ "" (set %~2=%res%) else echo %res% diff --git a/stringutils/split.bat b/stringutils/split.bat deleted file mode 100644 index 7ff5e66..0000000 --- a/stringutils/split.bat +++ /dev/null @@ -1,45 +0,0 @@ -:split [%1 - string to be splitted;%2 - split by;%3 - possition to get; %4 - if defined will store the result in variable with same name] -::http://ss64.org/viewtopic.php?id=1687 - -setlocal EnableDelayedExpansion - -set "string=%~2%~1" -set "splitter=%~2" -set /a position=%~3 - -set LF=^ - - -rem ** Two empty lines are required -echo off -for %%L in ("!LF!") DO ( - for /f "delims=" %%R in ("!splitter!") do ( - set "var=!string:%%~R%%~R=%%~L!" - set "var=!var:%%~R=%%~L!" - if "!var!" EQU "!string!" ( - echo "%~1" does not contain "!splitter!" >&2 - exit /B 1 - ) - ) -) - -if "!var!" equ "" ( - endlocal & if "%~4" NEQ "" ( set "%~4=") -) -if !position! LEQ 0 ( set "_skip=" ) else (set "_skip=skip=%position%") - -for /f "eol= %_skip% delims=" %%P in ("!var!") DO ( - if "%%~P" neq "" ( - set "part=%%~P" - goto :end_for - ) -) -set "part=" -:end_for -if not defined part ( - endlocal - echo Index Out Of Bound >&2 - exit /B 2 -) -endlocal & if "%~4" NEQ "" (set %~4=%part%) else echo %part% -exit /b 0 diff --git a/stringutils/startsWith.bat b/stringutils/startsWith.bat deleted file mode 100644 index 926411e..0000000 --- a/stringutils/startsWith.bat +++ /dev/null @@ -1,27 +0,0 @@ -:startsWith [%1 - string to be checked;%2 - string for checking ] -@echo off -rem :: sets errorlevel to 1 if %1 starts with %2 else sets errorlevel to 0 - -setlocal EnableDelayedExpansion - -set "string=%~1" -set "checker=%~2" -rem set "var=!string:%~2=&echo.!" -set LF=^ - - -rem ** Two empty lines are required -rem echo off -for %%L in ("!LF!") DO ( - for /f "delims=" %%R in ("!checker!") do ( - rem set "var=!string:%%~R%%~R=%%~L!" - set "var=!string:%%~R=#%%L!" - ) -) -for /f "delims=" %%P in (""!var!"") DO ( - if "%%~P" EQU "#" ( - endlocal & exit /b 1 - ) else ( - endlocal & exit /b 0 - ) -) diff --git a/stringutils/stringToHex.bat b/stringutils/stringToHex.bat deleted file mode 100644 index 5f25488..0000000 --- a/stringutils/stringToHex.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -:stringToHex -del tmp.hex >nul 2>nul -del tmp.str >nul 2>nul -(echo|set /p=%~1)>tmp.str - -certutil -encodehex tmp.str tmp.hex >nul -setlocal enableDelayedExpansion -set "hex_str=" -for /f "usebackq tokens=2 delims= " %%A in ("tmp.hex") do ( - set "line=%%A" - set hex_str=!hex_str!!line:~0,48! - set hex_str=!hex_str: =! - -) -echo !hex_str! -exit /b %errorlevel% diff --git a/stringutils/strlen0.3 b/stringutils/strlen0.3 deleted file mode 100644 index 04bc2ec..0000000 --- a/stringutils/strlen0.3 +++ /dev/null @@ -1,22 +0,0 @@ -:strlen0.3 StrVar [RtnVar] - setlocal EnableDelayedExpansion - set "s=#!%~1!" - set "len=0" - for %%A in ( 6561 2187 729 243 81 27 9 3 1) do ( - set /A mod=2*%%A - for %%Z in (!mod!) do ( - if !mod! GTR 8190 ( - set mod=8190 - ) - if "!s:~%%Z,1!" neq "" ( - set /a "len+=%%Z" - set "s=!s:~%%Z!" - - ) else ( - if "!s:~%%A,1!" neq "" ( - set /a "len+=%%A" - set "s=!s:~%%A!" - ) - ) - ) - ) diff --git a/stringutils/strlen2.5 b/stringutils/strlen2.5 deleted file mode 100644 index 01edce2..0000000 --- a/stringutils/strlen2.5 +++ /dev/null @@ -1,21 +0,0 @@ - - - :strlen2.5 StrVar [RtnVar] - :: http://ss64.org/viewtopic.php?id=424 - :: by Vasil "npocmaka" Arnaudov - setlocal enableDelayedExpansion - set "s=!%~1!" - set len=0 - if defined s for /l %%N in (1,1,8192) do if "!s:~%%N,-%%N!" equ "" ( - set len=%%N - goto :break - ) - :break - set /a len=2*!len!-1 - for %%E in (!len!) do ( - set s=!s:~%%E! - ) - if "!s!" neq "" set /a len=!len!+1 - endlocal & if "%~2" neq "" (set %~2=%len%) else echo %len% - exit /b - diff --git a/stringutils/strlen2.9 b/stringutils/strlen2.9 deleted file mode 100644 index b305ad7..0000000 --- a/stringutils/strlen2.9 +++ /dev/null @@ -1,39 +0,0 @@ - - - :strlen2.9 StrVar [RtnVar] - :: http://ss64.org/viewtopic.php?id=424 - :: by Vasil "npocmaka" Arnaudov - setlocal enableDelayedExpansion - set "s=!%~1!" - set len=0 - if defined s for /l %%N in (1,5,8192) do if "!s:~%%N,-%%N!" equ "" ( - set len=%%N - goto :break - ) - :break - - if !len! gtr 1 ( - set /a len=2*!len!-12 - for %%E in (!len!) do ( - set s=!s:~%%E! - ) - ) - - if defined s ( - if "!s:~0!" neq "" set /a len=!len!+1 - if "!s:~1!" neq "" set /a len=!len!+1 - if "!s:~2!" neq "" set /a len=!len!+1 - if "!s:~3!" neq "" set /a len=!len!+1 - if "!s:~4!" neq "" set /a len=!len!+1 - if "!s:~5!" neq "" set /a len=!len!+1 - if "!s:~6!" neq "" set /a len=!len!+1 - if "!s:~7!" neq "" set /a len=!len!+1 - if "!s:~8!" neq "" set /a len=!len!+1 - if "!s:~9!" neq "" set /a len=!len!+1 - if "!s:~10!" neq "" set /a len=!len!+1 - if "!s:~11!" neq "" set /a len=!len!+1 - ) - - endlocal & if "%~2" neq "" (set %~2=%len%) else echo %len% - exit /b - diff --git a/stringutils/toLowerCase.bat b/stringutils/toLowerCase.bat deleted file mode 100644 index 8044a8b..0000000 --- a/stringutils/toLowerCase.bat +++ /dev/null @@ -1,12 +0,0 @@ -:toLowerCase string [var] - setlocal enableDelayedExpansion - set "str=%~1" - for %%# in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do (set "str=!str:%%#=%%#!") - endlocal & ( - if "%~2" equ "" ( - echo %str% - ) else ( - set "%~2=%str%" - ) - ) -exit /b 0 diff --git a/stringutils/toUpperCase.bat b/stringutils/toUpperCase.bat deleted file mode 100644 index d4f1194..0000000 --- a/stringutils/toUpperCase.bat +++ /dev/null @@ -1,12 +0,0 @@ -:toUpperCase string [var] - setlocal enableDelayedExpansion - set "str=%~1" - for %%# in (A B C D E F G H I J K L M N O P P R S T U V W X Y Z) do (set "str=!str:%%#=%%#!") - endlocal & ( - if "%~2" equ "" ( - echo %str% - ) else ( - set "%~2=%str%" - ) - ) -exit /b 0 diff --git a/system/checkPermissions.bat b/system/checkPermissions.bat deleted file mode 100644 index 6b1bdca..0000000 --- a/system/checkPermissions.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off -:: checks if the current session has admin permissions -:: exist with 1 if there are -:: and with 0 if there are no -fltmc >nul 2>&1 && ( - echo has admin permissions - exit /b 1 -) || ( - echo has NOT admin permissions - exit /b 0 -) diff --git a/system/chkPermissions.bat b/system/chkPermissions.bat deleted file mode 100644 index 3d7ddbb..0000000 --- a/system/chkPermissions.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -setlocal enableDelayedExpansion -:: checks if the current session has admin permissions -:: uses only internal commands (checks existence of =:: variable) -:: exist with 1 if there are -:: and with 0 if there are no - -set "dv==::" -if defined !dv! ( - echo has NOT admin permissions - endlocal & exit /b 0 -) else ( - echo has admin permissions - endlocal & exit /b 1 -) diff --git a/system/monitorInfo.bat b/system/monitorInfo.bat deleted file mode 100644 index bff560f..0000000 --- a/system/monitorInfo.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off - -del ~.txt /q /f >nul 2>nul -start "" /w dxdiag /t ~ -setlocal enableDelayedExpansion -set currmon=1 -for /f "tokens=2 delims=:" %%a in ('find "Current Mode:" ~.txt') do ( - echo Monitor !currmon! : %%a - set /a currmon=currmon+1 - -) -endlocal -del ~.txt /q /f >nul 2>nul diff --git a/system/netVersions.bat b/system/netVersions.bat deleted file mode 100644 index bdb17eb..0000000 --- a/system/netVersions.bat +++ /dev/null @@ -1,13 +0,0 @@ -@echo off - -for /r "%SystemRoot%\Microsoft.NET\Framework\" %%# in ("*csc.exe") do ( - set "l=" - for /f "skip=1 tokens=2 delims=k" %%$ in ('"%%# #"') do ( - if not defined l ( - echo Installed: %%$ - set l=%%$ - ) - ) -) - -echo latest installed .NET %l% diff --git a/system/screenres.bat b/system/screenres.bat deleted file mode 100644 index 3391eee..0000000 --- a/system/screenres.bat +++ /dev/null @@ -1,29 +0,0 @@ -@echo off -::gets the screen resolution depending on the windows version. -setlocal -for /f "tokens=4,5 delims=. " %%a in ('ver') do set "version=%%a%%b" - - -if version lss 62 ( - ::set "wmic_query=wmic desktopmonitor get screenheight, screenwidth /format:value" - for /f "tokens=* delims=" %%@ in ('wmic desktopmonitor get screenwidth /format:value') do ( - for /f "tokens=2 delims==" %%# in ("%%@") do set "x=%%#" - ) - for /f "tokens=* delims=" %%@ in ('wmic desktopmonitor get screenheight /format:value') do ( - for /f "tokens=2 delims==" %%# in ("%%@") do set "y=%%#" - ) - -) else ( - ::wmic path Win32_VideoController get VideoModeDescription,CurrentVerticalResolution,CurrentHorizontalResolution /format:value - for /f "tokens=* delims=" %%@ in ('wmic path Win32_VideoController get CurrentHorizontalResolution /format:value') do ( - for /f "tokens=2 delims==" %%# in ("%%@") do set "x=%%#" - ) - for /f "tokens=* delims=" %%@ in ('wmic path Win32_VideoController get CurrentVerticalResolution /format:value') do ( - for /f "tokens=2 delims==" %%# in ("%%@") do set "y=%%#" - ) - -) - -echo Resolution %x%x%y% - -endlocal