Page 1 of 1

Can someone help me with this?!

Posted: 18 Sep 2011 10:27
by chinky20018
I'm totally confused!!
Create a batch file that meets the following criteria:

1) displays your first name
2) displays your last name on the next line
3) creates a directory called "hokus" in C:\
4) creates a directory called "pokus" in C:\hokus\
5) copies notepad.exe into C:\hokus\pokus\
(hint: you'll need to find where notepad.exe is first)
6) no commands should show when running the batch, only the results of those commands
7) show a directory listing of C:\hokus\pokus
8) display the word "done"

Re: Can someone help me with this?!

Posted: 18 Sep 2011 10:35
by chinky20018
How do I copy notepad.exe into the directory?? How do i find it??

Re: Can someone help me with this?!

Posted: 18 Sep 2011 13:51
by Ranguna173

Code: Select all

@echo off
cd c:\
if exist "hokus" (goto check) else (goto start)

:check
cd .\hokus
if exist name (
goto check_2
) else (
goto start
)

:check_2
< name (
  set /p line1=
  set /p line2=
)
goto start_a

:start

echo What is your first name?
set /p FN=

cls
echo What is your second name?
set /p SN=

cd c:\
md hokus
cd .\hokus
echo %FN%>name
echo %SN%>>name
set line1=%FN%
set line2=%SN%

:start_a
cls
echo %line1%
echo %line2%
echo The "hokus" folder has been done in c:\
cd c:\hokus
md pokus
echo The "pokus" folder has been done in c:\hokus
copy C:\Windows\System32\notepad.exe c:\hokus\pokus
echo The notepad.exe has been copied to c:\hokus\pokus
echo done
echo Press any key to close this window
pause>nul
exit


There is a "name" file in c:\hokus
It contain the first and the last name.

Re: Can someone help me with this?!

Posted: 19 Sep 2011 19:45
by Ocalabob
Greetings Chinky20018,

This looks like a school\class assignment. If that's true, then post the code you have written thus far and the good folks here will be more than willing to help you.

Best wishes!

Re: Can someone help me with this?!

Posted: 20 Sep 2011 11:04
by Ranguna173
Ocalabob wrote:Greetings Chinky20018,

This looks like a school\class assignment. If that's true, then post the code you have written thus far and the good folks here will be more than willing to help you.

Best wishes!


What?
My answer didn't do it?

Re: Can someone help me with this?!

Posted: 20 Sep 2011 18:31
by nitt
Ranguna173 wrote:
Ocalabob wrote:Greetings Chinky20018,

This looks like a school\class assignment. If that's true, then post the code you have written thus far and the good folks here will be more than willing to help you.

Best wishes!


What?
My answer didn't do it?


... What kind of school teaches Batch?

Re: Can someone help me with this?!

Posted: 21 Sep 2011 10:04
by Ranguna173
nitt wrote:
Ranguna173 wrote:
Ocalabob wrote:Greetings Chinky20018,

This looks like a school\class assignment. If that's true, then post the code you have written thus far and the good folks here will be more than willing to help you.

Best wishes!


What?
My answer didn't do it?


... What kind of school teaches Batch?


Why did you replied to me?
I never said it was school work..

Re: Can someone help me with this?!

Posted: 21 Sep 2011 17:24
by theoldman
I have the same class...and while I appreciate the response that gave the complete answer, I'd really like to explore and figure it out independently. What I came up with does everything the instructor gave in the directions except it shows the commands (item #6 in his list of directions) I cannot figure out what command to issue that will prevent the commands from showing, just the result of the commands. This is what I have written so far:

c:
cls
echo first name
echo last name
dir
md hokus
cd c:\hokus
md pokus
move %SystemRoot%\system32\notepad.exe pokus
dir c: /s
echo done

(Just so you'll know, I'm running the command in a virtual computer in VirtualBox running Windows XP)

Thanks!

Re: Can someone help me with this?!

Posted: 21 Sep 2011 18:50
by theoldman
I finally (and embarrassingly) figured it out...use the @echo off command. Thanks everyone.

Re: Can someone help me with this?!

Posted: 22 Sep 2011 12:05
by Ranguna173
theoldman wrote:I have the same class...and while I appreciate the response that gave the complete answer, I'd really like to explore and figure it out independently. What I came up with does everything the instructor gave in the directions except it shows the commands (item #6 in his list of directions) I cannot figure out what command to issue that will prevent the commands from showing, just the result of the commands. This is what I have written so far:

c:
cls
echo first name
echo last name
dir
md hokus
cd c:\hokus
md pokus
move %SystemRoot%\system32\notepad.exe pokus
dir c: /s
echo done

(Just so you'll know, I'm running the command in a virtual computer in VirtualBox running Windows XP)

Thanks!



Dude, it has been solved!

Ranguna173 wrote:

Code: Select all

@echo off
cd c:\
if exist "hokus" (goto check) else (goto start)

:check
cd .\hokus
if exist name (
goto check_2
) else (
goto start
)

:check_2
< name (
  set /p line1=
  set /p line2=
)
goto start_a

:start

echo What is your first name?
set /p FN=

cls
echo What is your second name?
set /p SN=

cd c:\
md hokus
cd .\hokus
echo %FN%>name
echo %SN%>>name
set line1=%FN%
set line2=%SN%

:start_a
cls
echo %line1%
echo %line2%
echo The "hokus" folder has been done in c:\
cd c:\hokus
md pokus
echo The "pokus" folder has been done in c:\hokus
copy C:\Windows\System32\notepad.exe c:\hokus\pokus
echo The notepad.exe has been copied to c:\hokus\pokus
echo done
echo Press any key to close this window
pause>nul
exit


There is a "name" file in c:\hokus
It contain the first and the last name.

Re: Can someone help me with this?!

Posted: 25 Sep 2011 12:04
by theoldman
Thanks Ranguna173!

Re: Can someone help me with this?!

Posted: 25 Sep 2011 13:35
by nitt
Ranguna173 wrote:Why did you replied to me?
I never said it was school work..


I was talking to Ocalabob. >.>

Re: Can someone help me with this?!

Posted: 26 Sep 2011 09:17
by Ranguna173
theoldman wrote:Thanks Ranguna173!


You are welcome!
BTW you can find notepad in
C:\windows\system32\
There should be a notepad.exe there.

nitt wrote:I was talking to Ocalabob. >.>


Oh.
Ok!