Search found 92 matches

by BoQsc
10 Jan 2023 14:54
Forum: DOS Batch Forum
Topic: Converting from bytes to gigabytes in multiple division statements.
Replies: 3
Views: 10858

Converting from bytes to gigabytes in multiple division statements.

Note: 30417637376 Bytes = 28.3286 Gigabytes Let's say I want to convert 30417637376 of bytes to gigabytes. set /A "gb=30417637376/1024" The usual issue is that Command Prompt will refuse to do the division with such large number. C:\Users\Windows10>set /A "gb=30433865728/1024" Invalid number. Numbe...
by BoQsc
05 Jan 2023 11:11
Forum: DOS Batch Forum
Topic: wmic, overall disk capacity, convert bytes to gb
Replies: 2
Views: 12569

Re: wmic, overall disk capacity, convert bytes to gb

It's probably a division accuracy. Numbers are limited to 32-bits of precision.
by BoQsc
07 Jul 2022 13:22
Forum: DOS Batch Forum
Topic: How can I ECHO the currently executing command?
Replies: 8
Views: 6291

Re: How can I ECHO the currently executing command?

What about a subroutine geting the command line passed? @ECHO OFF ECHO This is some example. call :repeatAndExec some_file.exe -flags arguments PAUSE goto :eof :repeatAndExec echo %* %* goto :eof Steffen I mean yeah, it's good enough, haven't encountered any inconsistencies in my own adaptations.
by BoQsc
07 Jul 2022 12:04
Forum: DOS Batch Forum
Topic: How can I ECHO the currently executing command?
Replies: 8
Views: 6291

Re: How can I ECHO the currently executing command?

I'm not completely new to the language, only a bit rusty.
by BoQsc
07 Jul 2022 11:56
Forum: DOS Batch Forum
Topic: How can I ECHO the currently executing command?
Replies: 8
Views: 6291

Re: How can I ECHO the currently executing command?

I didn't expect that this is much of a problem ¯\_(ツ)_/¯ If the empty line is something you can't accept, then you have to repeat the command line yourself using ECHO. Like so ... echo some_file.exe -flags arguments some_file.exe -flags arguments Steffen I was pretty sure that there was a cleaner w...
by BoQsc
07 Jul 2022 11:06
Forum: DOS Batch Forum
Topic: How can I ECHO the currently executing command?
Replies: 8
Views: 6291

Re: How can I ECHO the currently executing command?

Set the prompt empty. Then turn echo on to repeat the executed command line. @ECHO OFF ECHO This is some example. prompt $H echo on some_file.exe -flags arguments @echo off PAUSE Steffen This introduces the unnecessary empty line in-between. This is some example. notepad.exe -flags arguments Press ...
by BoQsc
07 Jul 2022 09:15
Forum: DOS Batch Forum
Topic: How can I ECHO the currently executing command?
Replies: 8
Views: 6291

How can I ECHO the currently executing command?

Let's say. I want to ECHO (Display in the Command Prompt output) the: some_file.exe -flags arguments but also execute it. in the script: @ECHO OFF ECHO This is some example. some_file.exe -flags arguments REM I want this to be shown in the output on the command line. And also execute it. PAUSE EXIT
by BoQsc
08 Feb 2022 07:52
Forum: DOS Batch Forum
Topic: Why this if statement not working properly?
Replies: 6
Views: 5880

Re: Why this if statement not working properly?

That's not the point, why does it even show that error when it shouldn't, even when the file exists in that place.

Code: Select all

IF NOT EXIST "C:\Users\Windows10\machines\disk1.img.qcow2" (
The disk1.img.qcow2 exists on my system, but the errors outputs still appear.
by BoQsc
08 Feb 2022 07:36
Forum: DOS Batch Forum
Topic: Why this if statement not working properly?
Replies: 6
Views: 5880

Why this if statement not working properly?

The output is: 'qemu-img' is not recognized as an internal or external command, operable program or batch file. tssd While there should be no output at all. Even when the C:\Users\Windows10\machines\disk1.img.qcow2 exists. These errors appear. @ECHO OFF IF NOT EXIST "C:\Users\Windows10\machines\disk...
by BoQsc
08 Jan 2021 04:58
Forum: DOS Batch Forum
Topic: ERRORLEVEL and Where.exe program
Replies: 2
Views: 3785

ERRORLEVEL and Where.exe program

I'd like to have a readable form of code that checks whether a program is available to be used. It's mostly to check if the program is available from the PATH Environment Variable. I'd like to ask if this makes any sense and is a correct way to do that, or you have any improvements on that. @ECHO OF...
by BoQsc
02 Nov 2020 02:36
Forum: DOS Batch Forum
Topic: Nesting statement if ()==() ( ) gives an error
Replies: 2
Views: 5587

Nesting statement if ()==() ( ) gives an error

These IF statements are suppose to compare strings. As you will see we are comparing: literal "c" character with another literal "c" character . And later on, adding another if statement that compare: literal "b" character with another literal "b" character . Or at least I think so. First test, ever...
by BoQsc
16 May 2020 06:52
Forum: DOS Batch Forum
Topic: Substitute a Word with a word and a new-line.
Replies: 1
Views: 2888

Substitute a Word with a word and a new-line.

I'd like that in the variable SET "substitute=quiethaha" the value quiethaha would be split in two lines: quiet haha I'm quite sure it is possible. But I can't really remember on how. search-replace.cmd @ECHO OFF SETLOCAL ENABLEDELAYEDEXPANSION SET "word=quiet" SET "substitute=quiethaha" FOR /F "del...
by BoQsc
22 Mar 2020 10:13
Forum: DOS Batch Forum
Topic: Copy all previous cmd output and write into a file
Replies: 3
Views: 5165

Re: Copy all previous cmd output and write into a file

Code: Select all

FOR /F %a IN ('doskey /history') DO echo %a
I pasted this command into Command Prompt and there is no output. How come? I expected it to print every line.

PS. doskey /history shows the output when it is not inside FOR Loop
by BoQsc
22 Mar 2020 10:01
Forum: DOS Batch Forum
Topic: Copy all previous cmd output and write into a file
Replies: 3
Views: 5165

Re: Copy all previous cmd output and write into a file

I found something, this command shows the history of commands pasted into the command line.

Code: Select all

doskey /history
Might be enough for what I need.
by BoQsc
22 Mar 2020 09:55
Forum: DOS Batch Forum
Topic: Copy all previous cmd output and write into a file
Replies: 3
Views: 5165

Copy all previous cmd output and write into a file

Microsoft Windows [Version 10.0.18362.720] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\user> Let's say I want to output all this to a file. How can I achieve this? Later on I'm considering parsing the cmd output for what happened and what commands and arguments were issued in the ...