Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Batch help


  • Please log in to reply

#1
Rocknrollcows

Rocknrollcows

    Member

  • Member
  • PipPipPip
  • 432 posts
hey, i wanted to try something

is it possible to make it so that when you type something, it goes into the place?

IE

[Username] = bob

del c:\documents and settings\[username]\desktop\*.txt

?
  • 0

Advertisements


#2
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
del %userprofile%\desktop\*.*

:)
  • 0

#3
Rocknrollcows

Rocknrollcows

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 432 posts
thanks :)
  • 0

#4
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
You have a lot to learn grasshopper :) :)
  • 0

#5
Rocknrollcows

Rocknrollcows

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 432 posts
teach me ur ways master. !
  • 0

#6
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
*Fredil Yupigo is not your master... he thinks that if (when) you get far enough in your training, ScHwErV will be :)
  • 0

#7
Rocknrollcows

Rocknrollcows

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 432 posts
wait...

i just tested the code. it didnt do anything?

del c:\documents and settings\%userprofile%\desktop\*.txt
  • 0

#8
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
%userprofile% is the environment variable for C:\Documents and Settings\Username. The whole path also has to be in quotes, because there are spaces in the folder "documents and settings". So, the code to delete all text files on a given user's desktop would be del /f /q "%userprofile%\desktop\*.txt" - elsewise you will get the message The system cannot find the file specified, because it would be looking for some odd... subset thingy of C:\Documents, which doesn't usually exist.

*Fredil Yupigo doesn't think it deletes the C:\Documents file either because he just tried it :)

Here's to me lecturing you - I just had to edit in my quotes! :) :)

Edited by Fredil Yupigo, 16 January 2008 - 08:27 PM.

  • 0

#9
Rocknrollcows

Rocknrollcows

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 432 posts
whats the /f?

i know what the /q is but ive never seen a /f O.o

thanks man (or woman)
  • 0

#10
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
Last I checked, I'm an adolescent male! :)

/f is the thing to force a file delete of a read-only file - get acquainted with cmd.exe's help command :)

C:\Documents and Settings\Fred>help del
Deletes one or more files.

DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names

names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.

/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find.

C:\Documents and Settings\Fred>

Of course, /f is not very useful because it can't delete more protected files like system files; you could consider either an attrib to remove the system file attribute (safer, but less reliable) or MoveEx, which is very powerful and potentially dangerous - use that with caution.
  • 0

#11
Rocknrollcows

Rocknrollcows

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 432 posts
interesting..

so how does it feel to able to drive?

*dramatic Pause*

....in 2 years.


anyways.. yea, i pull that on all my friends XD

thanks bro.

is there a way to delete/kill/remove a protected file using only batch? (not MoveEx)

Edited by Rocknrollcows, 16 January 2008 - 08:40 PM.

  • 0

#12
Chopin

Chopin

    Member 2k

  • Member
  • PipPipPipPipPip
  • 2,639 posts
Most, yes. All, no; the files of some temporary directories (*COUGH* index.dat *COUGH) are protected against deletion, and files of most malware are as well, unfortunately.

Plus, MoveEx is a program written to extend the functionality of a batch file - you put it in the same folder as the batch file you're running and simply type MoveEx as the command. ping works the same way - there's a program called ping.exe in your C:\WINDOWS\System32 folder :)
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP