|
|
|
Move text var to notepad (bat)
|
Original Message
|
Name: cholo71796
Date: June 8, 2008 at 21:30:15 Pacific
Subject: Move text var to notepad (bat)OS: Windows XPCPU/Ram: NoideaModel/Manufacturer: Yes |
Comment: (This is a question about batch files) I was wondering if there is a way to take a multi-word text variable (I'm not confused about that part) and place it in a notepad file. You know, like a survey- for example, if the program asks, "Do you like chicken? Y/N" (with the appropriate coding) and you input 'N' and the program asks you, "Why?" I would like the program to save/move the answer in a notepad file- either several answer in one notepad file, or one for every answer. Thanks in advance!
Report Offensive Message For Removal
|
|
Response Number 3
|
Name: cholo71796
Date: June 9, 2008 at 07:24:33 Pacific
|
Reply: (edit)Awesome! Thanks! The only problem is that if I use the program again it will remove the first variables data in that file, right? I'll try it now.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: cholo71796
Date: June 9, 2008 at 07:56:32 Pacific
|
Reply: (edit)Okay, dang, it's even worse than I thought, I must be doing something wrong. I run the script: cls @ECHO OFF setlocal EnableDelayedExpansion :QUESTION echo Do you like chicken? (Y/N) set/p "cho=>" if %cho%==Y goto THESTORE if %cho%==y goto THESTORE if %cho%==N goto SURVEY if %cho%==n goto SURVEY echo Input unknown. goto QUESTION :THESTORE echo Good, I'll go buy some now. PAUSE goto end :SURVEY echo What? Why don't you like chicken? set/p !var!=Type your response: sleep 3 echo !var!>>Reason.txt I'm probably forgetting something very simple, but I can't find out what I'm doing wrong. The program creates a new file called 'Reason' and all it says is ECHO is off.
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Mechanix2Go
Date: June 9, 2008 at 12:29:37 Pacific
|
Reply: (edit)this: set/p !var!=Type your response: should be: set/p var=Type your response: ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: cholo71796
Date: June 9, 2008 at 17:09:25 Pacific
|
Reply: (edit)Ach, thanks, I knew it was simple, works like a charm! One final question: Say that I were to give my batch file to someone who is literally incapable of editing the code, I would want them to be able to put some data into a .txt which would then be imported to the .bat file. How would I go about importing the text? Or as a better alternative, would there be a way for the script to ask for the user to create their password on first use?
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: cholo71796
Date: June 10, 2008 at 08:50:58 Pacific
|
Reply: (edit)Okay, I doubted the last (Number 7) post, but I'm still wondering at number 6, I know there's a way to call batch files and also to send text to text files, but is there a way to call text files? I really, really hope so, but if there's not, it's okay, I guess.
Report Offensive Follow Up For Removal
|
|
Response Number 11
|
Name: Shr0Om
Date: June 16, 2008 at 13:20:22 Pacific
|
Reply: (edit)To ask for password on first run (possible that it works with XP only if you want to use %username%) @echo off if not exist "c:\%username%.pwd" (goto :CrePassword) else goto :login
:CrePassword cls echo Hello: %username% echo As this is your first time here, you need to create a password. set /p pass1=Please enter new password: if "%pass1%" equ "" echo You cannot make an empty password! & PAUSE & goto :CrePassword set /p pass2=Please confirm password: if "%pass1%" neq "%pass2%" echo Passwords doesn't match. Try again! & pause & goto :CrePassword echo %pass1% >"c:\%username%.pwd" ::Hides the file attrib +h "c:\%username%.pwd" :login cls echo LOGIN: if exist c:\%username%.pwd set /p login=<c:\%username%.pwd set /p pass=Enter password: if %pass% equ %login% (goto :start) else echo Incorrect password. & pause & goto login
:Start echo Login sucsess.. pause
Report Offensive Follow Up For Removal
|

|

|
Use following form to reply to current message:
|
|

|