2013-12-14 2 views
2

내 학교용 채팅방을 만들고 있지만 필요에 따라 파일을 가져와야하지만 내 문제는 파일 경로가 매번 변경되어야한다는 것입니다. 한 시스템에서 다른 시스템으로 파일을 이동하십시오. 그래서이 메인 파일 내 전체 코드 나배치 파일 경로 vairiable % PATH %

작동하는 %PATH%을 만드는 방법을 알고 싶습니다 :

당신은 내가이

주에 새로운 해요 알 수 있습니다으로 : 여기있는 모든 것은 설정된 파일 경로로 잘 작동하지만 컴퓨터를 변경할 때 더 쉽게 작업하기를 원합니다. 당신이 당신이 의도 같은 값이 있는지 분석하기 위해 그 변수를 에코 수있는 진단 목적 http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/path.mspx?mfr=true

:

아무것도 아마 PATH에 %가 여기에 문서화 된 환경 변수를 예약되어

@echo off 

:Tittle 
cls 
color 74 
title Terms of Service 
echo _________________________-Terms-______________________________ 
echo If you are using this ChatRoom then you agree to the following. 
echo *you will not use Horrid Language 
echo *you will make your account with either your real name or 
echo Student id 
echo. 
echo This is monitored everyday so if anything is out of line it will be removed. 
echo. 
echo If you agree to follow these terms then type "yes" otherwise exit. 

set /p c=Do you Agree to follow the terms?: 
if %c% EQU yes goto Menu 
if %c% EQU ADMIN1423 goto Admin 
if %c% EQU dad goto Menu 
if %c% EQU carrie goto Menu 
if %c% EQU dad SET PATH=%PATH%;c:\Users\Dan W Frye\Desktop\(-_-) 
:Admin 
color 02 
cls  
Echo 

Echo. 
Echo 1.) Check User list 
Echo. 
Echo 2.) Create File Path       
Echo. 
Echo 3.) Admin Help 
Echo. 
echo 4.) N/A 
echo. 
Echo 

set /p c=Selection Number: 
if %c% EQU 1 goto UserList 
if %c% EQU 2 goto CreatePath 
if %c% EQU 3 goto AdminHelp 
if %c% EQU 4 goto Admin 
if %c% EQU back goto Tittle 

:UserList 
color 0b 
cls 
title User Listing 
cls 
start cmd 
CALL "%PATH%\Data\Chat Settings\Users\BuAsTeCrHs.bat" 
pause 
goto Admin 

:CreatePath 
cls 
color 01 
echo 
echo. 
echo The File Path Must look like this(No " "): "Driver (C:)"\Containing folder" thats it the  echo rest is automatically "\Data\Chat Settings\Users\....." 
echo. 
echo 
echo. 
echo The File Path you want to create. 
set /p PATH=File Path: 

echo. 
echo The Location/Device you are using. 
set /p LOC=Location: 

echo. 
echo %PATH% >>"%PATH%\Data\Chat Settings\File Paths\%LOC%.txt" 
echo The file path has been created! 
pause 
goto Admin 
:AdminHelp 

pause 
goto Tittle 
:Menu 
color 0b 

cls 

Echo -[ChatBox]- 
Echo 
Echo. 
Echo 1.) Login 
Echo. 
Echo 2.) Register 
Echo. 
Echo 3.) Exit 
Echo. 
echo 4.) Help 
echo. 
Echo 
Echo. 
set /p c=Selection Number: 
if %c% EQU 1 goto Login 
if %c% EQU 2 goto Register 
if %c% EQU 3 exit 
if %c% EQU 4 goto help 
if %c% EQU 5 goto Terms 
:help 
cls 
echo if you are not able to see the chat log then you must not have 
echo the file "Chatroom_reader.bat" open without this you cannot see 
echo messages sent by other users. 
echo. 
echo if you have suggestions or comments then please type "comment" 
echo. 
echo if you need assistance with any other problem you may have 
echo encountered then please type "other" to let the developer know 
echo what the problem is. otherwise type "back" to go back to the menu. 
set /p c=Option: 
if %c% EQU comment goto comments 
if %c% EQU other goto other 
if %c% EQU back goto menu 
:comments 
cls 
title Comments 
echo Enter your Username, and Password to Place a Comment 
echo. 
set /p UN=Username: 
echo. 
set /p PW=Password: 
echo. 
if NOT Exist "%PATH%\Data\Chat Settings\Users\%UN%.txt" Goto Failed 
echo %PW% >"%tmp%\chat.tmp" 
fc "%tmp%\chat.tmp" "%PATH%\Data\Chat Settings\Users\%UN%.txt" >nul 
if errorlevel==1 goto Failed 
if errorlevel==0 goto Comment 

:Comment 
cls 
echo. 
set /p SUBJECT=Subject: 
echo. 
set /p COMMENT=Comment: 
echo. 
echo %SUBJECT% : %COMMENT% >"%PATH%\Data\Chat Settings\Comments\%UN%.txt" 
goto User 
:other 
cls 
title Other 
echo Enter your Username, and Password to Place a Comment 
echo. 
set /p UN=Username: 
echo. 
set /p PW=Password: 
echo. 
if NOT Exist "C:\Users\Dan W Frye\Desktop\(-_-)\Data\Chat Settings\Users\%UN%.txt" Goto Failed 
echo %PW% >"%tmp%\chat.tmp" 
fc "%tmp%\chat.tmp" "C:\Users\Dan W Frye\Desktop\(-_-)\Data\Chat Settings\Users\%UN%.txt" >nul 
if errorlevel==1 goto Failed 
if errorlevel==0 goto OtherA 

:OtherA 
cls 
set /p OTHERC=Other Concern: 
echo. 
echo %OTHERC% >"%PATH%\Data\Chat Settings\Other\%UN%.txt" 
goto User 
:Login 
cls 
echo Enter your Username, and Password to login to the Chat Server 
echo. 
set /p UN=Username: 
echo. 
set /p PW=Password: 
echo. 

if NOT Exist "%PATH%\Data\Chat Settings\Users\%UN%.txt" Goto Failed 
echo %PW% >"%tmp%\chat.tmp" 
fc "%tmp%\chat.tmp" "%PATH%\Data\Chat Settings\Users\%UN%.txt" >nul 
if errorlevel==1 goto Failed 
if errorlevel==0 goto User 

:User 
cls 
Echo Welcome %UN%          The Current date is %date% 
echo 
echo. 
echo 1.) Chat 
echo. 
echo 2.) Logout 
echo. 
echo 3.) Change Password 
echo. 
echo 4.) Private Chat 
echo. 
echo 5.) Enter a Private Chat room 
echo. 
echo 
set /p c=Selection Number: 
if %c% EQU 1 goto chat 
if %c% EQU 2 goto Menu 
if %c% EQU 3 goto CHP 
if %c% EQU 4 goto PRIVATE 
if %c% EQU 5 goto PRIVATENTER 

:PRIVATENTER 
echo Please enter the name of the Private chat room if you do not know the name you may not  enter. 
set /p Chat= 
if %Chat% EQU scooter goto scooter 
if %Chat% EQU Cre-Br goto Cre-Br 

:Cre-Br 
cls 
set name=[%time%]%UN% 
cls 
color 02 
echo Last Message sent by %UN% \/ 
echo [%time%]%UN%:%text% 
set /p text=Say: 

echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\Cre-Br.txt" 
goto Cre-Br 


:scooter 
cls 
echo %Chat% 

set name=[%time%]%UN% 

color 02 
echo Last Message sent by %UN% \/ 
echo [%time%]%UN%:%text% 
set /p text=Say: 

echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\scooter.txt" 
goto scooter 

:PRIVATE 
cls 
set /p Chat=Chat Name: 

echo this is %UN%s Private chat room >>"%PATH%\Data\Chat Settings\Program_Files\%Chat%.txt" 
echo. 
echo @echo off >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo color 0b >>"%PATH%H:\(-_-)\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo cls >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo title Message Box >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo :home >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo cls >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 
echo findstr /v "g91dhjt637hsuexv27niw9" "%PATH%\Data\Chat Settings\Program_Files\%Chat%.txt"  >>"C:\Users\Dan W Frye\Desktop\Batch\Chat Settings\Private Chats\%Chat%.bat" 
echo goto home >>"%PATH%\Data\Chat Settings\Private Chats\%Chat%.bat" 

goto User 

:CHP 
cls 
set /p PW=Old Password: 
echo. 
set /p NP=New Password: 
echo %NP% >"%PATH%\Data\Chat Settings\Users\%UN%.txt 
goto User 

:Register 
cls 
color 07 

echo Register (Note the username is your screen name Please use your real name or School ID EX,  CaBu56789) 
echo. 
set /p NU=Username: 
echo. 
set /p NP=Password: 
echo. 
echo %NP% >"%PATH%\Data\Chat Settings\Users\%NU%.txt" 
echo. 
cls 
goto login 

:Failed 
color 0c 
cls 
echo You have entered am invalid Username and or Password 
echo Please try again or Register for free 
pause 
goto menu 

:chat 
set name=[%time%]%UN% 
cls 
color 02 
echo Everything said here is on recored please mind your 
echo language! 
echo Last Message sent by %UN% \/ 
echo [%time%]%UN%:%text% 
set /p text=Say: 

echo %name% : %text% >>"%PATH%\Data\Chat Settings\Program_Files\ChatRoom.txt" 

goto chat 

답변

0

%을 도울 수 :

echo %path% 
+0

난 그냥 그랬하고 경로가 날이었다 준 C : \ 프로그램 파일 \ 공용 Files \ Microsoft Shared \ 윈도우 라이브; C : \ 프로그램 파일 (X8 6) \ 공용 Files \ Microsoft 공유 C : \ windows \ system32; C : \ windows; C : \ windows \ System32 \ Wbem; C : \ windows \ System32 \ WindowsPowerShell \ v1.0 \; C : \ Program Fil (x86) \ Windows Live \ Shared, c : \ Users \ Dan WYFry \ Desktop \ (-_-) – FBspitty

0

코드에서 경로가 이미 메뉴로 분기 한 후에 설정되었습니다. 이것은 당신을 위해 작동 할 수 있습니다

set path=%path%;%PUBLIC% 

C:\Users\Public에 배치 파일을 복사하고 거기에서 실행 :

if %c% EQU carrie goto Menu 
if %c% EQU dad SET PATH=%PATH%;c:\Users\Dan W Frye\Desktop\(-_-)& goto menu 

는 모든 사용자의 경로에 배치 파일을 넣어하려면 다음을 사용합니다.
여분의 권한이 필요한 경우가 아니면 모든 사용자에 대해 실행해야합니다.

+0

그래서 두 가지 작업을 동시에 수행하지 않도록하는 것이 무엇입니까? 어떻게 작동하는지 알 수 있기 때문에 – FBspitty

+0

변수가 PATH 문에 추가 된 후 : 메뉴 레이블로 분기됩니다.코드에서 아빠가 로그인 할 때 PATH 문을 변경하는 행은 실행되지 않습니다. – foxidrive

+0

@Durry42는 "SET"progpath = c : \ Users \ % username % \ Desktop \ (-_-) ""하드 디스크의 동일한 작업을 수행 할 수있는 방법이 무엇인지 잘 알고 있습니까? SET progpath = % HARDDISK % \ Users \ % username % \ Desktop \ (-_-) – FBspitty

0

@ Jermu Virtanen에 의해 언급 된 바와 같이 변수는 Windows 시스템 경로 설정입니다 ... 실제로 무엇을하는지 모르는 한 사용하거나 변경해서는 안됩니다. %PATH% 대신 %PROGPATH%과 같은 것을 사용하십시오.

또한 @foxdrive에서 언급 한 것처럼 사용자가 "dad"를 입력하면 path 변수를 설정하기 전에 "menu"로 이동합니다. 다시 '관리자'를 선택한 다음 '사용자 나열'을 선택하면 처음으로 설정하지 않고 경로를 다시 호출합니다.

컴퓨터의 도메인 이름 %userdomain%과 현재 사용자 %username%을 가져 와서 일부 로그인 또는 경로 설정을 자동화 할 수 있습니다.

ee;

SET "progpath=c:\Users\%username%\Desktop\(-_-)" 
+0

나는 그것이 나를 위해 일할 것이라고 말하고 싶지만 내가가는 학교는 네트워크 설정을 가지고있다. "H : \ (-_-)"그래서 경로를 설정할 수 있도록'% PATH % \ Data \ Chat Settings \ '으로 설정했습니다. '% PATH %'는 컴퓨터마다 바뀝니다. 학교 네트워크가'C :'에 있지 않다 – FBspitty

+0

그 외 학교 네트워크 문제 당신이 말한 것! 하지만 ... 그것도 실패 ERRORLEVEL == 0 실패하면 가서 왜 이해가 안 돼요 – FBspitty

+0

그것의 끝에 다른 폴더를 추가하여 경로를 사용하여 괜찮아요 PATH 변수의 지점입니다. Durry42가 의미하는 바는'path','date'''time' 등과 같은 시스템 변수를 일반적인 용도의 변수로 사용하지 말아야한다는 것입니다. @ Durry42 이것을 반영하여 답을 편집하십시오. 나는 당신의 문제에 대한 가능한 해결책으로 나의 대답을 편집했다. – foxidrive