Error in Batch File

chippy9000

Distinguished
Jul 13, 2011
8
0
18,510
Hi Guys, :hello:
I recently am making my own folder-lock "Software" and was all fine until the last Batch,

@echo off
title ZionBot Settings...
if EXIST ZionBot.exe goto Change
echo When notepad appears, change HEREHEREHEREHEREHERE to your desired password. Go file>save and save again...
pause
notepad"C:\Program Files\ZionBot\Zionbot.bat"
echo When dialog pops up, click "Compile" on the bottom. When finished, close the window...
pause
"C:\Program Files\ZionBot\bat2exe.exe"
echo ZionBot Installation is now complete...
del "Desktop\Create Password.lnk"
pause
goto End
:Change
echo Enter PIN giving at your purchase...
set/p "pass=>"
if NOT %pass%==Pin goto Change
echo When notepad appears, change HEREHEREHEREHEREHERE to your desired password. Go file>save and save again...
pause
notepad "C:\Program Files\ZionBot\Zionbot.bat"
Del "C:\Program Files\ZionBot\Zionbot.exe"
echo When dialog pops up, click "Compile" on the bottom. When finished, close the window...
pause
"C:\Program Files\ZionBot\bat2exe.exe"
echo ZionBot password is now changed...
pause
:End
cls

It's suppose to open notepad were the user can enter his/her desired password, he/she already made one it is changed.
I tried it out and this happened.


qwerty.png


It skips the first few lines, HELP!! :( :cry:
 
Solution
Hi newcomer. It seems you didn't read the rules for posting on these forums cause when posting code, you have to put these in-between [.code][/code] (minus the dot) to make things clear for everyone, and show that these lines are the actual code. Now that's being said, I would be a brute not to answer someone polite enough to salute us. ^^

I'll give you a trick: when testing and you don't know what happen, just insert some more echo lines in-between some principal lines. Here's a small example to show what I mean:
Code:
echo Here's a program to do something...
first command
echo test1
second command
echo test2
third command
echo test3
fourth command
echo now it should have worked all the way...
etc.
etc.
By doing this, when executing the...

MrBig55

Distinguished
Jun 27, 2011
350
0
18,810
Hi newcomer. It seems you didn't read the rules for posting on these forums cause when posting code, you have to put these in-between [.code][/code] (minus the dot) to make things clear for everyone, and show that these lines are the actual code. Now that's being said, I would be a brute not to answer someone polite enough to salute us. ^^

I'll give you a trick: when testing and you don't know what happen, just insert some more echo lines in-between some principal lines. Here's a small example to show what I mean:
Code:
echo Here's a program to do something...
first command
echo test1
second command
echo test2
third command
echo test3
fourth command
echo now it should have worked all the way...
etc.
etc.
By doing this, when executing the program you'll get a visual on what lines are skipped, ran, or did not ran the way it's intended. Once you know the program runs perfectly you can just do a little search through your program, searching for "test" and delete all these lines. That'll take seconds but will save you hours of blind debug. Oh well now let's talk about your program.

I copied your program in a batch file on my desktop, then opened a command windows before running your program. It first told me to press any key which I did, then a file named "save" appeared on my desktop.

I opened that "save" file. Here's what it's written in it:
When notepad appears, change HEREHEREHEREHEREHERE to your desired password. Go file and save again...
that specific program line is this:
echo When notepad appears, change HEREHEREHEREHEREHERE to your desired password. Go file>save and save again...

So your program is misinterpreting your echo line. The quotes ("") does not only serve when there are spaces in filenames, but also when there are symbols that has other functions as well. In this case the english quotes (<>) means a read/write to a file, which the program did as you can see, it did save the echo line in a file named save, as the english quotes implies in this line. Just put your line in quotes ("") when using symbols, and the line will execute normally, showing text in the command windows and not in a file named "save".
 
Solution

chippy9000

Distinguished
Jul 13, 2011
8
0
18,510
sorry for the super late reply, thanks MrBig55 I did just that and it work like a charm, I also digged in for special characters in the interweb and found special characters can be escaped by the ^ key infront of it.
thanks dude, over 9000 internets to you