Can someone help me with this?!

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
chinky20018
Posts: 2
Joined: 18 Sep 2011 10:24

Can someone help me with this?!

#1 Post by chinky20018 » 18 Sep 2011 10:27

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"

chinky20018
Posts: 2
Joined: 18 Sep 2011 10:24

Re: Can someone help me with this?!

#2 Post by chinky20018 » 18 Sep 2011 10:35

How do I copy notepad.exe into the directory?? How do i find it??

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Can someone help me with this?!

#3 Post by Ranguna173 » 18 Sep 2011 13:51

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.

Ocalabob
Posts: 79
Joined: 24 Dec 2010 12:16
Location: Micanopy Florida

Re: Can someone help me with this?!

#4 Post by Ocalabob » 19 Sep 2011 19:45

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!

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Can someone help me with this?!

#5 Post by Ranguna173 » 20 Sep 2011 11:04

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?

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: Can someone help me with this?!

#6 Post by nitt » 20 Sep 2011 18:31

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?

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Can someone help me with this?!

#7 Post by Ranguna173 » 21 Sep 2011 10:04

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..

theoldman
Posts: 3
Joined: 21 Sep 2011 17:14

Re: Can someone help me with this?!

#8 Post by theoldman » 21 Sep 2011 17:24

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!

theoldman
Posts: 3
Joined: 21 Sep 2011 17:14

Re: Can someone help me with this?!

#9 Post by theoldman » 21 Sep 2011 18:50

I finally (and embarrassingly) figured it out...use the @echo off command. Thanks everyone.

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Can someone help me with this?!

#10 Post by Ranguna173 » 22 Sep 2011 12:05

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.

theoldman
Posts: 3
Joined: 21 Sep 2011 17:14

Re: Can someone help me with this?!

#11 Post by theoldman » 25 Sep 2011 12:04

Thanks Ranguna173!

nitt
Posts: 218
Joined: 22 Apr 2011 02:43

Re: Can someone help me with this?!

#12 Post by nitt » 25 Sep 2011 13:35

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


I was talking to Ocalabob. >.>

Ranguna173
Posts: 104
Joined: 28 Jul 2011 17:32

Re: Can someone help me with this?!

#13 Post by Ranguna173 » 26 Sep 2011 09:17

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!

Post Reply