Search found 81 matches

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: 139

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: 1136

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: 1136

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: 1136

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 ...
by BoQsc
22 Mar 2020 08:31
Forum: DOS Batch Forum
Topic: Make cmd.exe parse piped batch code
Replies: 2
Views: 1168

Make cmd.exe parse piped batch code

Is it possible to make cmd.exe to parse piped batch code? Are there ways to process piped batch code? There seems to be conflicts between cmd interpreter syntax and batch syntax. PS. I'm not talking about running a batch script. I'm talking about running the piped batch code. If not: Are there any c...
by BoQsc
16 Mar 2020 05:04
Forum: DOS Batch Forum
Topic: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies
Replies: 2
Views: 1173

Re: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

Did you call your script WMIC.cmd/.bat? That would explain this behaviour exactly. I make a habit out of adding the file extension to programs used in scripts to avoid this (replace WMIC with WMIC.exe) But it is always better to avoid naming your scripts the same as an already existing program. I s...
by BoQsc
16 Mar 2020 03:19
Forum: DOS Batch Forum
Topic: Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies
Replies: 2
Views: 1173

Wmic command placed in a batch file is not responding and refuse to work without administrator privilegies

I came across this weird behaviour with Wmic: Running WMIC from manually opened command prompt without administrator privilegies - works properly and output is delivered as expected. Running WMIC from batch file without administrator privilegies - Wmic is stuck in the permanent loop without any outp...
by BoQsc
15 Mar 2020 04:50
Forum: DOS Batch Forum
Topic: @Echo off is not working when Piping batch code to cmd
Replies: 8
Views: 1732

Re: @Echo off is not working when Piping batch code to cmd

Then I suggest you write a wrapper script that takes the URL you're downloading as %1 and pipes that to cmd /q Wouldn't it be possible without wrapper script? ' There are no ways to enclose code and pipe it into cmd /q like in this pseudo code? Non-working pseudo-code ( echo Hello this is going to ...
by BoQsc
15 Mar 2020 04:28
Forum: DOS Batch Forum
Topic: @Echo off is not working when Piping batch code to cmd
Replies: 8
Views: 1732

Re: @Echo off is not working when Piping batch code to cmd

Why don't you want to use cmd /Q? That's how you do it. You see typing additional options are hard. They are hard to remember, takes aditional time for beginners that are only starting to use command line prompt, and they will use this command only few times in years. I'm starting to think that I s...
by BoQsc
15 Mar 2020 03:58
Forum: DOS Batch Forum
Topic: @Echo off is not working when Piping batch code to cmd
Replies: 8
Views: 1732

@Echo off is not working when Piping batch code to cmd

I would like to know if there is any known way to turn off Echo when piping batch code to cmd. Only by adding /Q option to cmd.exe, the output is actually with echo off. I need the script to be the trigger of echo off, and not the /Q option of cmd.exe If not, Are there any alternative ways to execut...
by BoQsc
14 Mar 2020 11:43
Forum: DOS Batch Forum
Topic: Arithmetic inside Round brackets leads to Missing operand
Replies: 10
Views: 1978

Re: Arithmetic inside Round brackets leads to Missing operand

And here the main script with the new method of gathering date from operating system: Seems to be working pretty well. @ECHO OFF SETLOCAL EnableDelayedExpansion REM Get current Year and Month for Windows 10 Windows 8.1 Windows 8 Windows 7 FOR /F "skip=1 tokens=1-6" %%A IN ('WMIC Path Win32_LocalTime...
by BoQsc
14 Mar 2020 11:12
Forum: DOS Batch Forum
Topic: Arithmetic inside Round brackets leads to Missing operand
Replies: 10
Views: 1978

Re: Arithmetic inside Round brackets leads to Missing operand

Your way of dealing with dates is not good as it depends on the locale settings for the computer. For example, %date% on my machine yields Fri 03/13/2020 which completely breaks your code. You should be using FOR /F with WMIC OS GET LOCALDATETIME to get the date and/or time in a way that can be par...
by BoQsc
14 Mar 2020 10:29
Forum: DOS Batch Forum
Topic: Arithmetic inside Round brackets leads to Missing operand
Replies: 10
Views: 1978

Re: Arithmetic inside Round brackets leads to Missing operand

Windows 8 is not deprecated. Windows 8 Unsupported as of January 12, 2016 https://en.wikipedia.org/wiki/Windows_8 Windows 8.1 Mainstream support ended on January 9, 2018 Extended support until January 10, 2023 Upgrading to Windows 8.1 is required for Windows 8 users to receive updates and support a...
by BoQsc
13 Mar 2020 14:46
Forum: DOS Batch Forum
Topic: Arithmetic inside Round brackets leads to Missing operand
Replies: 10
Views: 1978

Re: Arithmetic inside Round brackets leads to Missing operand

Why are you still explicitly expanding the variable? It works, but as I showed in my last post, that is not needed when using SET /A. You could use SET /A "YEAR=YEAR_NOW - 1" Note that in this case you must explicitly expand the month value to get the correct result. SET /A "PREVMONTH=1MONTH-100" w...
by BoQsc
13 Mar 2020 11:47
Forum: DOS Batch Forum
Topic: Arithmetic inside Round brackets leads to Missing operand
Replies: 10
Views: 1978

Arithmetic operation is successful but "Missing operator." is displayed in the output

@ECHO OFF SETLOCAL EnableDelayedExpansion REM Get current Year and Month for Windows 10 SET "year_now=%date:~2,2%"; SET "month_now=%date:~5,2%"; SET "releaseCycle=Interim"; IF "%releaseCycle%"=="LTS" ( echo "Haven't been implemented"; ) ELSE IF "%releaseCycle%"=="Interim" ( IF %month_now% LSS 04 ( ...