search for ccna answer

Showing posts with label Bat File. Show all posts
Showing posts with label Bat File. Show all posts

Wednesday, June 11, 2008

IF and IF NOT commands in batch file

There are three variations of the IF and IF NOT commands.

  • IF EXIST: Execute the commandline only if a particular file exists:

    IF EXIST some.txt COPY c:/some.dll %windir%/SYSTEM/some.dll

  • Compare two text strings, and execute the commandline only if they are identical.

    IF %HostWinBootDrv%==C SET WinDir=C:\WINDOWS

  • Error testing: Check the exit code of the most recently run program. If it is equal to or greater than the number specified, execute the command:

    IF ERRORLEVEL 4 ERASE trashfile.tmp /P


The better way to understand this command is try it yourself.
If got any question, post it here. I will try my best to solve it.

Sunday, June 8, 2008

Turn ON/OFF your Remote Desktop

Here is the batch :

@ECHO OFF
:Prompt
::Prompting technician for machine name/IP which to connect
SET /P TargetMachine=Please enter the machine name or IP address:
CLS
ECHO Remote Desktop Check on \\%TargetMachine%
:Menu
ECHO.
ECHO 1. Remote Desktop Check (Enabled 0x0 or disabled 0x1)
ECHO 2. Remote Desktop On (0x0)
ECHO 3. Remote Desktop Off (0x1)

set choice=
set /p choice=Please type in your choice and press enter.
if not '%choice%'==' set choice=%choice:~0,1%
if '%choice%'=='1' goto RemoteDesktopCheck
if '%choice%'=='2' goto RemoteDesktopOn
if '%choice%'=='3' goto RemoteDesktopOff
ECHO "%choice%" is not valid please try again
ECHO.
goto Menu

::Listing 3: CheckRD.cmd
:RemoteDesktopCheck
@reg query "\\%TargetMachine%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
GOTO Prompt

::Listing 4: RDOn.cmd
:RemoteDesktopOn
@reg add "\\%TargetMachine%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
GOTO Prompt

::Listing 5: RDOff.cmd
:RemoteDesktopOff
@reg add "\\%TargetMachine%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 1 /f
GOTO Prompt

Copy and save it the name as you like.

This batch file can use to check for your remote desktop status either on or off. On the other hand, you can also use it to turn on or off of your remote desktop.

For more details of Remote Desktop : Please visit here .

Wednesday, March 5, 2008

Start Your messenger and Chat wif your friend

Bat FILE



Start Copy After The Line
----------------------------------------------------------------------------------------------
@echo off
echo This Is A Bat File That Open Messenger And Can Send Msg To Other PC
echo P/S :Other Computer Must Also Open Messenger
echo Send This File To Them If Wan to Chat Wif Them :)
echo Authuor : BNC
echo Product : startM

pause
pause
cls

@echo off
sc config messenger start= auto
net start messenger
cls

echo Now You Can Send Msg !
:main
set /p Ip= -Your Friend IP ^>
set /p Msg= -Your Msg ^>

net send %Ip% %Msg%

echo Press 1 To Contiune Send Msg
set choice2=
set /p choice2=

if '%choice2%'=='1' goto main

if '%choice2%'=='2' goto end
goto


:end
exit

----------------------------------------------------------------------------------------------
Copy End Before The line


Commentary
Copy and Save it to xxxxx.bat (xxxxx is the file name that u like)
Then Just Click it
When u run it
it will start the messenger that include in xp , not the MSN!

after that , u need to enter the ip of your friend pc (ur friend oso muz be started the messenger or else error will occur), then juz type in the message follow wat show in command prompt

Just Press Enter
If you wan to continue sending msg to other , press 1 , if not , press 2 to exit.

Hope Enjoy This Batch File :)