1.

Solve : Q AND A?

Answer»

IQ test......

Question 1
I have a batch FILE called "Test.bat". Look below
Code: [Select]echo off
msg * LINE number ONE loaded!
msg * Line number two loaded!
msg * Line number three loaded!
msg * Ending program!
exit
I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"
How can i do that with batch command?

Question 2
I have a batch file called "test.bat". Look below.
Code: [Select]echo off
:a
taskkill /f /im password_viewer.exe
goto a
Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.
But the worm will then restart itself after killing it so i have to put a loop in my batch command.
Putting the loop make my computer slow. How can i kill the WORM when only it is running?

Question 3
I have a batch file called "Test.bat". Look below.
Code: [Select]echo off
echo Type Your Score.
set/p score=>
echo %score% >>Score.txt
pause
echo View your score.
type score.txt
pause
exit
And a Text file called "Score.txt"
Code: [Select]score 76
score 89
score 85
score 67
I want my batch file to display only the score in line three char six that is 85. How can i do that?

Question 4
In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.
But an error occured when i try to remove the "G:\Junk" using batch command:
Cannot remove directory because the directory is not empty
What MUST i do?

ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT. Quote from: progmer on July 18, 2010, 07:28:21 PM

IQ test......

Question 1
I have a batch file called "Test.bat". Look below
Code: [Select]echo off
msg * Line number one loaded!
msg * Line number two loaded!
msg * Line number three loaded!
msg * Ending program!
exit
I want to replace the script "Line Number Two Loaded!" with "Line Two Loaded!"
How can i do that with batch command?
you can use a file processing tool, such as sed for windows.
Code: [Select]C:\test>sed "s/Line number two/Line two/" file
echo off
msg * Line number one loaded!
msg * Line two loaded!
msg * Line number three loaded!
msg * Ending program!

Quote
Question 2
I have a batch file called "test.bat". Look below.
Code: [Select]echo off
:a
taskkill /f /im password_viewer.exe
goto a
Ok, the password_viewer.exe is a little worm in my PC. I want to kill it using Batch command.
But the worm will then restart itself after killing it so i have to put a loop in my batch command.
Putting the loop make my computer slow. How can i kill the WORM when only it is running?
you are not solving the root of the problem. Use a virus scanner to remove the worm, or do it manually such as REGISTRY and system32. Then make an effort to always update your virus signatures, and discipline yourself not to run unknown
executables anyhow.

Quote
Question 3
I have a batch file called "Test.bat". Look below.
Code: [Select]echo off
echo Type Your Score.
set/p score=>
echo %score% >>Score.txt
pause
echo View your score.
type score.txt
pause
exit
And a Text file called "Score.txt"
Code: [Select]score 76
score 89
score 85
score 67
I want my batch file to display only the score in line three char six that is 85. How can i do that?
again, if you have downloaded sed
Code: [Select]C:\test>sed -n "3s/^score //p" score.txt
85

Quote
Question 4
In my drive "G:\Junk" have a lot of subfolder, jpg, mp3, txt, bat and a lot of junk in it.
But an error occured when i try to remove the "G:\Junk" using batch command:
Cannot remove directory because the directory is not empty
What must i do?
If it says its not empty, then go empty them...or you can "force" deletion using switches from some of the delete commands eg del, deltree..etc...

Quote
ONE QUESTION RIGHT GET 25 MARKS. I WILL BE APPRECIATED IF ANYONE GOT MOST OF THE QUESTION RIGHT.
next time, try to research a bit on the internet as well.. Quote from: ghostdog74 on July 18, 2010, 07:56:43 PM
you can use a file processing tool, such as sed for windows.
Can you give me a script that don't need to download "sed"?
Because machine without "sed" will not be able to run the program.progmer, why did you choose such an irritating way of asking your questions? It is bound to limit the help that you get.


Discussion

No Comment Found