Search found 83 matches
- 08 Jan 2021 04:58
- Forum: DOS Batch Forum
- Topic: ERRORLEVEL and Where.exe program
- Replies: 2
- Views: 245
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...
- 02 Nov 2020 02:36
- Forum: DOS Batch Forum
- Topic: Nesting statement if ()==() ( ) gives an error
- Replies: 2
- Views: 1043
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...
- 16 May 2020 06:52
- Forum: DOS Batch Forum
- Topic: Substitute a Word with a word and a new-line.
- Replies: 1
- Views: 1034
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...
- 22 Mar 2020 10:13
- Forum: DOS Batch Forum
- Topic: Copy all previous cmd output and write into a file
- Replies: 3
- Views: 1925
Re: Copy all previous cmd output and write into a file
Code: Select all
FOR /F %a IN ('doskey /history') DO echo %a
PS. doskey /history shows the output when it is not inside FOR Loop
- 22 Mar 2020 10:01
- Forum: DOS Batch Forum
- Topic: Copy all previous cmd output and write into a file
- Replies: 3
- Views: 1925
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.
Might be enough for what I need.
Code: Select all
doskey /history
- 22 Mar 2020 09:55
- Forum: DOS Batch Forum
- Topic: Copy all previous cmd output and write into a file
- Replies: 3
- Views: 1925
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 ...
- 22 Mar 2020 08:31
- Forum: DOS Batch Forum
- Topic: Make cmd.exe parse piped batch code
- Replies: 2
- Views: 2007
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...
- 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: 1853
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...
- 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: 1853
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...
- 15 Mar 2020 04:50
- Forum: DOS Batch Forum
- Topic: @Echo off is not working when Piping batch code to cmd
- Replies: 8
- Views: 3249
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 ...
- 15 Mar 2020 04:28
- Forum: DOS Batch Forum
- Topic: @Echo off is not working when Piping batch code to cmd
- Replies: 8
- Views: 3249
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...
- 15 Mar 2020 03:58
- Forum: DOS Batch Forum
- Topic: @Echo off is not working when Piping batch code to cmd
- Replies: 8
- Views: 3249
@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...
- 14 Mar 2020 11:43
- Forum: DOS Batch Forum
- Topic: Arithmetic inside Round brackets leads to Missing operand
- Replies: 10
- Views: 3619
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...
- 14 Mar 2020 11:12
- Forum: DOS Batch Forum
- Topic: Arithmetic inside Round brackets leads to Missing operand
- Replies: 10
- Views: 3619
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...
- 14 Mar 2020 10:29
- Forum: DOS Batch Forum
- Topic: Arithmetic inside Round brackets leads to Missing operand
- Replies: 10
- Views: 3619
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...