Search found 442 matches

by orange_batch
23 Feb 2012 12:23
Forum: DOS Batch Forum
Topic: 50%
Replies: 6
Views: 7533

Re: 50%

Code: Select all

@echo off
set hi=60

set /a hi=hi*30/2
if "%hi:~-1%"=="0" (set hi=%hi:~,-1%) else set hi=%hi:~,-1%.%hi:~-1%

set hi
pause


Returns decimal number to tenths (unless number is an integer).
by orange_batch
04 Feb 2012 00:19
Forum: DOS Batch Forum
Topic: Software development and regional testing.
Replies: 3
Views: 6197

Re: Software development and regional testing.

I've been working on a piece of software too Ed, for almost 2 years on and off. A little over 1000 lines of code though, much of it space and commenting, but highly complex/optimized/modular. You do need a regional copy of Windows for the differences between languages with DOS tools. Changing locale...
by orange_batch
30 Jan 2012 21:24
Forum: DOS Batch Forum
Topic: Making Force Close Batch
Replies: 10
Views: 12162

Re: Making Force Close Batch

Well as he said, force-terminating processes is unsafe work best done with only a few clicks using task manager, however I'm not going to wag a finger. Here's my own vbscript based tasklister which is in some ways better than tasklist, and will work on Windows XP Home where tasklist is nonexistent a...
by orange_batch
25 Jan 2012 16:45
Forum: DOS Batch Forum
Topic: help - prompt for password
Replies: 4
Views: 7810

Re: help - prompt for password

Answered the same question a number of times recently: viewtopic.php?f=3&t=2677&p=12235#p12235
by orange_batch
25 Jan 2012 15:23
Forum: DOS Batch Forum
Topic: Parse a string to get part after "\\"
Replies: 11
Views: 13222

Re: Parse a string to get part after "\\"

Ok, you have a variable foobar which is expanded when you write it as %foobar% . When expanded, you can replace matching text using the syntax: %foobar:apples=oranges% With %foobar:\=" "% , all \ become " " : \\DPTEST\smspkgf$\GLB0001 becomes " "" "DPTEST"...
by orange_batch
25 Jan 2012 12:31
Forum: DOS Batch Forum
Topic: Parse a string to get part after "\\"
Replies: 11
Views: 13222

Re: Parse a string to get part after "\\"

Well, "%foobar:\=" "%" outputs this: "" "" "DPTEST" "smspkgf$" "GLB0001" The two empty quotation marks cause two iterations in the for loop. Normal for will iterate for each item within (), using the delimiters space, tab, and com...
by orange_batch
25 Jan 2012 11:31
Forum: DOS Batch Forum
Topic: Parse a string to get part after "\\"
Replies: 11
Views: 13222

Re: Parse a string to get part after "\\"

Yes, read for /? , but I thought I would explain a little myself. Here's your standard version: set string=\\DPTEST\smspkgf$\GLB0001 for /f "delims=\ tokens=1" %%a in ("%string%") do ( echo %%a ) for /f = for 's text-processing mode. "delims=\ tokens=1" = Options. delim...
by orange_batch
11 Jan 2012 06:27
Forum: DOS Batch Forum
Topic: find a file, rename it, then rename back again...
Replies: 2
Views: 4868

Re: find a file, rename it, then rename back again...

A better option would be to write an exception in the clean-up script for those particular files. Otherwise, the process goes like... ren file1.tmp file1.tmp.dat ren file2.bak file2.bak.dat *script runs* ren file1.tmp.dat file1.tmp ren file2.bak.dat file2.bak ren has the syntax: ren source new_name ...
by orange_batch
03 Jan 2012 19:11
Forum: DOS Batch Forum
Topic: Erase SET /P Prompt after execution
Replies: 9
Views: 14655

Re: Erase SET /P Prompt after execution

phillid, great! Please note it said libstdc++-6.dll was missing for me with gotoxy, as well as the other DLL for both. nitt wrote a program here that did a similar job as gotoxy but it relied on .NET. I requested a C(++) version but he was unable... However, nitt's version I think had one feature, w...
by orange_batch
03 Jan 2012 18:55
Forum: DOS Batch Forum
Topic: Determine parent folder name without entire folder path?
Replies: 17
Views: 24581

Re: Determine parent folder name without entire folder path?

I've written a complex function for the same purpose, so maybe I can help... This is a very simplified version (it is unable to handle paths at the drive root and first level). The behaviour of a trailing backslash is actually a useful thing to exploit. You can determine if a path is a folder, a fil...
by orange_batch
03 Jan 2012 04:02
Forum: DOS Batch Forum
Topic: Detect if batchfile is launched from explorer or dosprompt
Replies: 7
Views: 11198

Re: Detect if batchfile is launched from explorer or dosprom

Just my 2 cents, WMI is very useful. As aGerman said, the command line WMIC tool isn't available with all relevant versions of Windows though. Accessing WMI through VBScript is, however. Basic VBScript WMI construct: set a=getobject("winmgmts:") set b=a.execquery("select whatever_prop...
by orange_batch
02 Jan 2012 04:14
Forum: DOS Batch Forum
Topic: "For" string needs to process only one line
Replies: 5
Views: 8700

Re: "For" string needs to process only one line

I need it to process only the first line of test.txt. REM Printline: REM Standard printline: set "$file=test.txt" for /f "usebackq tokens=1*" %%a in ("!$file!") do ( set "check=%%a" if "!check:~,9!"=="printline" ( set "command=%%a&quo...
by orange_batch
02 Jan 2012 02:21
Forum: DOS Batch Forum
Topic: why is this FOR doing this?
Replies: 22
Views: 23637

Re: why is this FOR doing this?

Yes, that is what I was talking about. I said it makes 2 processes, I want it to make just one. Use start cmd /k cd /d C:\ start will create the new cmd instance separately, which allows the first instance to reach the end (and exit) if loaded by a batch file. Simply figure what works best for you.
by orange_batch
01 Jan 2012 05:38
Forum: DOS Batch Forum
Topic: how to timeout on xp
Replies: 3
Views: 9219

Re: how to timeout on xp

Or the vbscript method...

sleep.vbs

Code: Select all

wscript.sleep wscript.arguments(0)*1000

Code: Select all

cscript sleep.vbs //nologo seconds
by orange_batch
30 Dec 2011 17:38
Forum: DOS Batch Forum
Topic: batch launcher for an .exe and it will write ip there
Replies: 2
Views: 4892

Re: batch launcher for an .exe and it will write ip there

http://www.dostips.com/forum/viewtopic.php?f=3&t=2677&p=12235#p12235 ...where "%{F3}" contains whatever key presses/special keys you want to enter. So "94.103.150.147" would suffice. You may need to focus your application window first. So all together...: set a=wscript.cr...