Search found 391 matches

by avery_larry
12 Jul 2010 14:06
Forum: DOS Batch Forum
Topic: Ping server & Send mail
Replies: 3
Views: 6322

Re: Ping server & Send mail

If for some reason you *don't* need this to be native dos, then I suggest the hostmonitor program: http://www.ks-soft.net/hostmon.eng/index.htm Really nice monitoring program. Otherwise, to expand on what aGerman said -- I have a file I've created called "pingtest", which doesn't send an e...
by avery_larry
09 Jul 2010 10:42
Forum: DOS Batch Forum
Topic: Logging into Windows
Replies: 3
Views: 4844

Re: Logging into Windows

You can find the reg settings for autologon and import them via a batch file, copy another batch file to the startup folder, reboot using shutdown.exe, and then wipe the autologin reg settings using the batch file you put in the startup folder while calling a 3rd batch file that deletes the 2nd batc...
by avery_larry
07 Jul 2010 14:21
Forum: DOS Batch Forum
Topic: Need to know the status of BAT file execution
Replies: 1
Views: 3347

Re: Need to know the status of BAT file execution

Well, each individual program will *typically* return an errorlevel. You can test for that: @echo off c:\myotherprogram.exe if errorlevel 255 goto :error255 if errorlevel 100 goto :error100 if errorlevel 10 goto :error10 if errorlevel 1 goto :error1 echo if you get here, then errorlevel is 0 echo wh...
by avery_larry
02 Jul 2010 11:57
Forum: DOS Batch Forum
Topic: Basic compound variable problem
Replies: 5
Views: 5856

Re: Basic compound variable problem

One can hope that they know how to change for their language, and one can also hope that they know how to ask for additional help if this has to work for multiple languages. Besides -- do you know it's token #3 in every language? AND -- looking at the OP -- I should have warned them that using this ...
by avery_larry
02 Jul 2010 11:42
Forum: DOS Batch Forum
Topic: How to find cause of error from "CD /D %yourPath%"
Replies: 10
Views: 9246

Re: How to find cause of error from "CD /D %yourPath%"

Wouldn't a simple "if exist" work?

Code: Select all

rd "whatever folder" >nul 2>nul
if errorlevel 1 (
   if exist "whatever folder" (
      echo rd failed and the folder exists -- FROZEN
      ) else (
         echo rd failed and folder doesn't exist -- ABSENT
   )
)
by avery_larry
02 Jul 2010 11:34
Forum: DOS Batch Forum
Topic: Pros and Cons of starting a script "setlocal"
Replies: 5
Views: 6248

Re: Pros and Cons of starting a script "setlocal"

When I have script files that call other script files, I will sometimes use setlocal and endlocal to make sure I don't accidentally use the same variable name in both scripts, and subsequently mess up the calling scripts variable values. Since I'm doing the coding, it's fairly likely that I'll use s...
by avery_larry
02 Jul 2010 11:29
Forum: DOS Batch Forum
Topic: Basic compound variable problem
Replies: 5
Views: 5856

Re: Basic compound variable problem

for /f "tokens=3" %%a in ('dir /-c "c:\directory"^|find /i "bytes free"') do set sizeinbytes=%%a
by avery_larry
21 Jun 2010 10:22
Forum: DOS Batch Forum
Topic: For Loop Using Text File As Input Problem
Replies: 2
Views: 3871

Re: For Loop Using Text File As Input Problem

Is that all on one line?

for /f "usebackq delims=" %a in ("c:\path to file\singlefileslist.txt") do copy "%a" v:\test


If there is no ouput on the screen, my first guess is that it can't find singlefileslist.txt . . .
by avery_larry
21 Jun 2010 10:09
Forum: DOS Batch Forum
Topic: Check if command's output contains some text
Replies: 3
Views: 29875

Re: Check if command's output contains some text

Code: Select all

yourcommandhere | find /i "the text you're looking for"
if not errorlevel 1 (
   echo The stuff you want to do
   echo goes here
)
by avery_larry
18 Jun 2010 14:37
Forum: DOS Batch Forum
Topic: "No valid files found" return screen from batch script (???)
Replies: 14
Views: 15698

Re: "No valid files found" return screen from batch script (

I would guess that it's not too many files, but rather too many characters in the for loop: for %%a in (%*) do if the %* is reeeeaaaaly long I'm pretty sure it'll choke. In fact, it's probably a cmd limitation, which means you probably have a character limit for the command line itself (which means ...
by avery_larry
18 Jun 2010 14:25
Forum: DOS Batch Forum
Topic: Filter out a line that is too long from a txt file...
Replies: 8
Views: 8478

Re: Filter out a line that is too long from a txt file...

*untested* setlocal enabledelayedexpansion for /f "usebackq delims=" %%a in (old.txt) do ( set "tmp_var=%%a" if "!tmp_var:~24,1!"=="" echo.%%a>>new.txt ) Note this will also filter out blank lines. The code to include blank lines gets more complicated.
by avery_larry
18 Jun 2010 11:54
Forum: DOS Batch Forum
Topic: Help with the FOR command, get current iteration number
Replies: 3
Views: 4745

Re: Help with the FOR command, get current iteration number

You can actually use the delayedexpansion that you have enabled:

CALL:setTitle "Processing file !currentfile! of %filecount%"
by avery_larry
16 Jun 2010 09:59
Forum: DOS Batch Forum
Topic: How to undo SHIFT effect
Replies: 2
Views: 4106

Re: How to undo SHIFT effect

I would suggest you try and avoid using shift completely if you might need the parameters later in your script. 2 ideas for you: 1) Specific to the code you have shown, you could use a for loop: @ECHO OFF echo start: %1 for %%a in (%*) do echo %%a echo end: %1 2) You can use a for loop to go through...
by avery_larry
15 Jun 2010 15:01
Forum: DOS Batch Forum
Topic: Help with command list batch
Replies: 6
Views: 6500

Re: Help with command list batch

call batchsubstitute ...
call batchsubstitute ...


if you don't use the "call" statement, then you pass control to the other batch file and you do not return to the calling batch file.
by avery_larry
04 Jun 2010 08:39
Forum: DOS Batch Forum
Topic: New to the batch - Folder removal
Replies: 6
Views: 6987

Re: New to the batch - Folder removal

rd /s /q "%userprofile%\Application Data\Sun\Java" or if that doesn't work because of hidden/read only files or something: I guess I don't know if this actually works but: del "%userprofile%\Application Data\Sun\Java\*.*" /F /S /Q /A: R /A: H /A: A And finally, an "if exist&...