Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS 

Code Of A Game

This Is A Code Of A Game.

Coppy It Into Notepad And Then Save It As Game.bat

Warning!
Make Sure It Says "All Files (*.*)" And Not "Text Document (.txt)" At The Bottom.
The Code Is:
@echo off
goto verybegingame
: verybegingame
echo Welcome To This Game!
title Game Start
echo Press Any Key For Stuff.
pause >nul
echo Loading...
ping localhost 6 >nul
echo.. Loading Comple!
pause >nul
cls
echo Rules:
title Game Rules
echo..You Answer Each Question.
echo. If It Is Correct, You Will Move On.
echo If It is InCorrect, The Program Will
echo Exit And You Will Need To Try Again.
echo.. If You Get All The Questions Right, You
echo Will Receave A Speical Code.
echo Enter THe Code For A Suprse!
echo...
echo Good Luck!
echo.....
echo Press A Key Of An Option, And Then 
echo Press 'Enter'.
echo...
echo                        1 = Play Game          2 = Enter Code
SET /P "onechoose1=Enter 1 or 2 option here:"
If %onechoose1%= 1 then goto playgame
If %onechoose1%= 2 then goto entercode
:playgame
cls
echo What Is My Name?
echo A.Jonathan
echo B.Sam
echo C.Johnn
SET /p "q1=Enter Option:"
If NOT%q1%= A then exit
:entercode
echo  Enter Code
SET /P "codeenter= "
If %entercode%=code... goto prize
:prize



All Of ThAT...
MAKE MORE QUESTIONS.
etc.

Batch code to make win folder hidden and password protected

Open any text editor and copy the the contents of this code to a text file and save it with any name having .bat extension.

cls
@ECHO OFF
echo 			// Check1 (In Main Function)
title Folder LockFolder
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLockFolder
if NOT EXIST LockFolder goto MDLockFolder
:AuthConfirm
echo Are you sure u want to Lock Folder  (Y/N)
set/p "cho=>"
if %cho%==Y goto LockFolder
if %cho%==y goto LockFolder
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto AuthConfirm
:LockFolder
ren LockFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder LockFolder Locked!
goto End
:UNLockFolder
echo Enter password to Unlock Folder
set/p "pass=>"
if NOT %pass%==TYPE YOUR PASSWORD HERE goto FailUnlock
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" LockFolder
echo Folder UnLocked successfully!
goto End
:FailUnlock
echo Invalid password!
echo Try again?  (Y/N)
set/p "choice=>"
if %choice%==Y goto UNLockFolder
if %choice%==y goto UNLockFolder
if %choice%==N goto END
if %choice%==n goto END
:MDLockFolder
echo 			// Check2 (In MD Dir Function)
md LockFolder
echo Folder LockFolder created successfully!
goto End
:End

One-click connect from cygwin to full-screen Linux (X stuff required)

Optional: execute the following once (see http://hacks.oreilly.com/pub/h/66 for
details), to avoid typing in the password.

set LINUX_HOST=mylinuxhost
ssh-keygen -t rsa
ssh %USERNAME%@%LINUX_HOST% "mkdir .ssh; chmod 0700 .ssh"
bash -c 'scp ~/.ssh/id_rsa.pub %LINUX_HOST%:.ssh/authorized_keys2'


Now, if you save the following as a BATCH file, you can just click it
to connect to fullscreen Linux:

set LINUX_HOST=mylinuxhost
start /min xinit 
xhost +%LINUX_HOST%
ssh %LINUX_HOST% "declare -x DISPLAY=%COMPUTERNAME%:0; echo $DISPLAY;gnome-session"'


NOTES:
1.
Sometimes xhost + does not execute in time. O well. Just close
all windows that got opened and try again.

2.
If you didn't do the step one (ssh keys), you will be prompted
to enter the linux password; this increases the chances of the above
error.

3.
The single terminal window appearing in the Linux desktop is in fact
a window from your PC.

Lowercasing a string in BAT files

Using this silliness, here's an example of BAT file that will
lower-case a string given as an argument.

echo>%1
dir /b/l %1>lower.tmp
set /p result=<lower.tmp
echo %result%


Saving this as lower.bat, I run

lower "HELLO WORLD"


and get

hello world

as a result

Using Unix shell's backquote functionality in DOS/Windows batch files

In BAT files, an equivalent of a Unix shell's
set foo `bar`


can be accomplished as

bar>bar.tmp
set /p foo=<bar.tmp


If you're spoiled by Unix's notion of
true pipes, note that the following:

bar | set /p foo=


does not work.
« Newer Snippets
Older Snippets »
Showing 1-5 of 5 total  RSS