![]() |
|
Restricted privileges command line - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: Restricted privileges command line (/Thread-Restricted-privileges-command-line) |
Restricted privileges command line - Inori - 04-05-2016 So, as usual, I'm finding ways to piss of my school's administrative staff. I found that even though they've blocked command line usage, it's possible to get said usage back by using batch files. main code: Code: @echo off&setlocal
:: set path to user defined path
set cfgpath=C:\Users\Kagetane\Desktop\Code\~projects\cmd\config
:setup
:: collects userpath and sets to temporary variable
set /p usrp=<%cfgpath%\path.txt
:: loop to get user variables
set /p t=<%cfgpath%\vars.txt
:defloop
for /f "tokens=1* delims=;" %%a in ("%t%") do (
if defined ttl (
if defined host (
if defined root (
set user=%%a
) else set root=%%a
) else set host=%%a
) else set ttl=%%a
set t=%%b
)
if defined t goto defloop
path=%path%;%usrp% :: adds user's path to session path
cd %root% :: goes to defined root directory
:: main program loop
:loop
title %ttl% - %cd%
echo %cd% %user%@%host%~
set /p cmd=$
%cmd%
goto loopFor defining your userpath, just delimit entries with a semicolon in a path.txt file in your config directory, leaving the last entry without a semicolon at the end For example: Code: H:\Programming\Source\Ruby22;H:\Programming\Source\Git;H:\Programming\Source\nodejs;H:\Programming\Source\Python;H:\Programming\Source\Python\ScriptsFinally, for user variables, do the same as you did with the path in a file called vars.txt, but in the following format: Code: title;hostname;root directory;userExample: Code: :: this config
command "console";no-access-to-anything;H:/Programming/Files;inori
:: produces this
H:/Programming/Files inori@no-access-to-anythings~
$Note: this is still pretty buggy, and I hate messing with batch, since error tracebacks are non-existent, so if anyone finds bug fixes, lmk |