Search found 4506 matches

by aGerman
19 Sep 2011 14:11
Forum: DOS Batch Forum
Topic: Break server connection
Replies: 2
Views: 2386

Re: Break server connection

I'm not sure whether it is available on all XP versions, but there is a command OPENFILES.

Also PsFile (downloadable here) could help.

Unfortunately I'm not familiar with those remote stuff.

Regards
aGerman
by aGerman
18 Sep 2011 11:17
Forum: DOS Batch Forum
Topic: How to start service and launch *.exe from desktop shortcut
Replies: 2
Views: 2696

Re: How to start service and launch *.exe from desktop short

Hi Alan,

try the following:

Create a shortcut with
-Target:
%comspec% /c "net start VMUSBArbService & CD /D E:\VMWare & start E:\VMWare\vmplayer.exe"
-Start in:
%systemroot%\system32

Regards
aGerman
by aGerman
11 Sep 2011 12:25
Forum: DOS Batch Forum
Topic: scheduled tasks
Replies: 3
Views: 2771

Re: scheduled tasks

But I have a problem with a scheduled task : I have a script that mounts a drive on each server start : net use P: \\server\share$ The person that has created this task is "sean". The Last result of this task is "0". When I launch your script, the last result for this task is &q...
by aGerman
11 Sep 2011 06:18
Forum: DOS Batch Forum
Topic: How to add multiple numbers found in a text document
Replies: 5
Views: 4656

Re: How to add multiple numbers found in a text document

multiples of 3 and 5 below 1000 0 isn't a multiple of 3 or 5 also 1000 is not below 1000. For that reason: start is 3 (or 5), step is 3 (or 5), end is 999. @echo off >multiples.log type nul for /l %%a in (3,3,999) do ( >>multiples.log echo %%a ) pause for /l %%a in (5,5,999) do ( >>multiples.log ec...
by aGerman
10 Sep 2011 16:45
Forum: DOS Batch Forum
Topic: Help with code for maths script-PLEASE HELP
Replies: 5
Views: 4647

Re: Help with code for maths script-PLEASE HELP

Haha, true. Mostly I use goto :eof in this case (out of habit). But actually you could deploy exit /b to return a value to the line where the sub routine was called from. @echo off call :sum 10 20 echo %errorlevel% call :equals 10 20 &&echo true||echo false pause goto :eof :sum setlocal set ...
by aGerman
10 Sep 2011 15:08
Forum: DOS Batch Forum
Topic: scheduled tasks
Replies: 3
Views: 2771

Re: scheduled tasks

I hope your output is comparable to my German output. Are all values enclosed in quotes? Would you find the last result in the 7th column? How ever, try that code and tell me if something's going wrong. @echo off for /F "delims=, tokens=2,7" %%R in ('schtasks /query /fo csv /v^|findstr /vi...
by aGerman
10 Sep 2011 09:38
Forum: DOS Batch Forum
Topic: Looping through files in a directory
Replies: 1
Views: 2618

Re: Looping through files in a directory

With FOR /F you have to loop against the output of DIR in this case.

Code: Select all

for /f "delims=" %%a in ('dir /a-d /b /s "%direc%"') do echo %%a

FOR /R has a different syntax

Code: Select all

for /r "%direc%" %%a in (*.*) do echo %%a

Regards
aGerman
by aGerman
10 Sep 2011 09:35
Forum: DOS Batch Forum
Topic: Help with code for maths script-PLEASE HELP
Replies: 5
Views: 4647

Re: Help with code for maths script-PLEASE HELP

EXIT is a command you normally shouldn't use in a batch code, except EXIT /B to return an ERRORLEVEL value. @echo off :a set "A=" &set "B=" set /p "A= Enter first number : " set /p "B= Enter second number : " pause set "C=%A% + %B%" & call :a...
by aGerman
09 Sep 2011 09:26
Forum: DOS Batch Forum
Topic: Help with set /a command
Replies: 15
Views: 17471

Re: Help with set /a command

You're right Dave. I assume logical and arithmetic shift are only the same for the left shift operator.

Regards
aGerman
by aGerman
09 Sep 2011 08:06
Forum: DOS Batch Forum
Topic: Help with set /a command
Replies: 15
Views: 17471

Re: Help with set /a command

An example for "logical shift":

Code: Select all

@echo off &setlocal
set /a "result=7<<2"
echo %result%
pause

The output is 28.
Why?
The binary expression for 7 is 111.
Shifting 2 digits to the left results to
11100 (bin) = 28 (dec).

Regards
aGerman
by aGerman
05 Sep 2011 17:39
Forum: DOS Batch Forum
Topic: Almost there - Lil Help Pretty please? :-)
Replies: 3
Views: 3955

Re: Almost there - Lil Help Pretty please? :-)

Untested: @echo off set "root=J:\Musicfiles" for /f "delims=" %%a in ('dir /ad /b "%root%"') do ( for /f "delims=" %%b in ('dir /a-d /b /s "%root%\%%a"') do ( move /y "%%b" "%root%\%%a\" ) for /f "delims=" %%b in ('dir /...
by aGerman
05 Sep 2011 17:24
Forum: DOS Batch Forum
Topic: for /f
Replies: 9
Views: 7910

Re: for /f

Good explanation, nitt.
Additional ...
FOR /F is made to process text streams line by line. Such a stream could be the output of a command as well as a simple string or the content of a file.

Regards
aGerman
by aGerman
02 Sep 2011 10:28
Forum: DOS Batch Forum
Topic: Batch script with condition?
Replies: 3
Views: 4281

Re: Batch script with condition?

Maybe it makes sense to write each single output into a temporary log file, then check the errorlevel and append the temporary file to your list only if errorlevel is greater than 0. >"tmp.log" tnsping test1.bb.com if errorlevel 1 >>"tnsping.log" type "tmp.log" >"t...
by aGerman
01 Sep 2011 13:14
Forum: DOS Batch Forum
Topic: Renaming multiple files within folder(s)
Replies: 10
Views: 7065

Re: Renaming multiple files within folder(s)

Haha you won, !k. Lets write a code with the best of both. @echo off &setlocal for /f "delims=" %%a in ('dir /a-d /b /s "* - *.mp3"') do ( for /f "tokens=1* delims=-" %%b in ("%%~nxa") do ( set "name=%%c" call ren "%%a" "%%name:~1%...
by aGerman
01 Sep 2011 12:52
Forum: DOS Batch Forum
Topic: Renaming multiple files within folder(s)
Replies: 10
Views: 7065

Re: Renaming multiple files within folder(s)

Similar: @echo off &setlocal for /f "delims=" %%a in ('dir /a-d /b /s "* - *.mp3"') do ( set "oldname=%%~nxa" setlocal enabledelayedexpansion for /f "tokens=1* delims=?" %%b in ("!oldname: - =?!") do ( ren "%%a" "%%c" ) endloc...