Forums: Batch Scripts - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch Scripts only started learning a few mins ago

#1 User is offline   toe 

  • Staff Sergeant
  • Icon
  • Group: Members
  • Posts: 271
  • Joined: 10-November 04

Posted 01 May 2005 - 10:36 PM

how would u modify these. (only started learning batch bout 10 mins ago so go easy on me)

A.) i just want it to open telnet for an example at the moment it jst spams shit in cmd and doesnt open anything loop it repeatedly
C:
cd windows
telnet


B.) at the moment it just flashes on the screen and doesnt stay there so u can read the ECHO commands
@ECHO OFF
ECHO This deletes temp shit
ECHO setting sights for windows/temp compensating for wind speed
cd windows\temp
ECHO takes aim and fires
del *.tmp
ECHO killed those dirty temp files.............


basically i dont want to have to run it through cmd i just want to be able to double click the file and it will do what its ment to.

-thx toe
0

#2 User is offline   bonarez 

  • Master Sergeant
  • Icon
  • Group: Specialist
  • Posts: 906
  • Joined: 17-March 04

Posted 01 May 2005 - 11:25 PM

your batch file did what it's supposed to do:

it deletes all *.tmp files from temp dir

if you want to see the echo's just put a pause on the bottom >

@ECHO OFF
ECHO This deletes temp shit
ECHO setting sights for windows/temp compensating for wind speed
cd windows\temp
ECHO takes aim and fires
del *.tmp
ECHO killed those dirty temp files.............

pause


pause will wait until you hit enter (or any other key)

you could play around a bit with the del command >

"del /?" will show you more options
Paraskavedeka Triaphoba
0

#3 User is offline   Terminal 

  • Master Sergeant
  • Icon
  • Group: Specialist
  • Posts: 536
  • Joined: 21-February 04

Posted 01 May 2005 - 11:51 PM

U can also use environment variables like %windir% for windows directory ..
bcoz if u run bat from some folder than the "cd windows" command will look for windows directroy in that folder . So use
del %windir%\temp\*.tmp /f /q


some more environment variables here http://www.wilsonmar.com/1envvars.htm
0

#4 User is offline   belgther 

  • Master Sergeant
  • Icon
  • Group: Specialist
  • Posts: 650
  • Joined: 06-October 04

Posted 02 May 2005 - 12:17 AM

1)Windows directory is already added to your path listing. It means, when you just type telnet in command line, or instruct a batch file to do so, it opens, no matter wherever you are... To prove this, you can go to Start-Run then type telnet, and you are in...
But be careful... Because if you name your batch file as telnet.bat, you get an infinite loop because the bat file has a higher running priority than telnet.exe. Since .exe, .bat and .com files are directly executable, you will get an infinite loop by naming your batch file as telnet.bat
BTW, there's no need to make a batch file for running telnet... Because you can simply add a shortcut with the command "telnet".
2)i would suggest "\windows\temp" instead of "windows\temp". But the solution with environment variables is also good... The backslash at the starting makes you go to the root directory at first. And with pause, here's a hint: if you write "pause >nul" instead of "pause", you won't see the message "press any key to continue..." if it annoys you...
Hope this helps...
"The wisest one is the one who knows himself/herself." Quote of the life
belgther... aka... belgther
0

#5 User is offline   toe 

  • Staff Sergeant
  • Icon
  • Group: Members
  • Posts: 271
  • Joined: 10-November 04

Posted 02 May 2005 - 05:07 PM

Terminal, on May 2 2005, 07:51 AM, said:

U can also use environment variables like %windir% for windows directory ..
bcoz if u run bat from some folder than the "cd windows" command will look for windows directroy in that folder . So use
del %windir%\temp\*.tmp /f /q


some more environment variables here http://www.wilsonmar.com/1envvars.htm


wot do the /f /q commands do?
Thnx for the replies they have helped alot.

-toe
0

#6 User is offline   SkitZZ 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 138
  • Joined: 04-December 03

Posted 02 May 2005 - 05:45 PM

toe, on May 3 2005, 01:07 AM, said:

wot do the /f /q commands do?
Thnx for the replies they have helped alot.

-toe


as bonarez sead go to cmd and type "del /?"

C:\>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.


SkitZZ
0

#7 User is offline   toe 

  • Staff Sergeant
  • Icon
  • Group: Members
  • Posts: 271
  • Joined: 10-November 04

Posted 02 May 2005 - 06:12 PM

yeah just did that and couldnt delete my post :)

-toe
0

#8 User is offline   toe 

  • Staff Sergeant
  • Icon
  • Group: Members
  • Posts: 271
  • Joined: 10-November 04

Posted 02 May 2005 - 08:37 PM

Also say i want to make a batch script to for example to run netcat with the commands:
netcat.exe -lvvp 432 -d -e cmd.exe (assuming netcat is in C:)

can in it be done in batch? and what are some other usefull things that you have used batch scripts for?

-toe
0

#9 User is offline   tuxi 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 29
  • Joined: 02-October 04

Posted 03 May 2005 - 10:57 PM

Quote

Also say i want to make a batch script to for example to run netcat with the commands:
netcat.exe -lvvp 432 -d -e cmd.exe (assuming netcat is in C:)

can in it be done in batch? and what are some other usefull things that you have used batch scripts for?

-toe


Sure no problem
just do this
c:
cd /
netcat.exe -lvvp 432 -d -e cmd.exe


Other usefull things let me think a bit you could automate nearly all windows processes.
0

#10 User is offline   lesaew 

  • Private
  • Icon
  • Group: Members
  • Posts: 11
  • Joined: 03-September 04

Posted 05 May 2005 - 12:17 AM

Nice!

Is it possible to create a batch file to delete all temp files and temp internet files on a WinXP machine? (XP creates a folder for each profile/user with identical subfolders which are hidden under %user%\local settings\* where tmp files and temp internet files are stored)
I think I figured it out.

@ECHO OFF
ECHO This empties Temp and Temp Internet Folders

del C:\Documents and Settings\%userdir%\Local Settings\Temporary Internet Files\*.*
del C:\Documents and Settings\%userdir%\Local Settings\Temp\*.*

ECHO Temporary Internet Files and Temp folders for each user have been emptied.............

pause


Can someone verify this for me before I run it and toast something I didn't intend to toast?

/r
0

#11 User is offline   toe 

  • Staff Sergeant
  • Icon
  • Group: Members
  • Posts: 271
  • Joined: 10-November 04

Posted 05 May 2005 - 07:27 PM

looks good to me, but i only started with batch coz i found c++ a bit hard to learn at the moment, school fags my codeing life over. Oh with the del command sometimes you have to force the delete on read only files. So it wood be something like this:
del C:\Documents and Settings\%userdir%\Local Settings\Temp\*.* /f

as above says type del /? for some more info.

-toe
0

#12 User is offline   lesaew 

  • Private
  • Icon
  • Group: Members
  • Posts: 11
  • Joined: 03-September 04

Posted 06 May 2005 - 03:47 AM

Just tried to run it, error said it could not find the specified file. I'm guesing the %userdir% isn't an appropriate wildcard.

Suggestions?
0

#13 User is offline   bonarez 

  • Master Sergeant
  • Icon
  • Group: Specialist
  • Posts: 906
  • Joined: 17-March 04

Posted 06 May 2005 - 05:07 AM

try %username%

you can find the variables with the 'set' command

ps: cool batch tricks at robvanderwoude.com
Paraskavedeka Triaphoba
0

#14 User is offline   spook 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 48
  • Joined: 05-November 04

Posted 06 May 2005 - 07:01 AM

lesaew, on May 6 2005, 12:47 PM, said:

Just tried to run it, error said it could not find the specified file. I'm guesing the %userdir% isn't an appropriate wildcard.

Suggestions?


del %HOMEDRIVE%%HOMEPATH%\Local Settings\Temp\*.* /f


Tried it, but without the del and /f... But it probably does its job
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

  • Share



Our Sponsors:


SwiftLayer Affiliate Web Hosting