Search found 135 matches

by Eureka!
16 Feb 2021 10:22
Forum: DOS Batch Forum
Topic: Put the End Time the computer will sleep.
Replies: 13
Views: 8729

Re: Put the End Time the computer will sleep.

Maybe this can help you: @echo off setlocal set MINUTES=12 for /f "usebackq delims=" %%t in (`powershell.exe -ExecutionPolicy Bypass -noprofile -nologo -command ^(get-date^).AddMinutes^(%MINUTES%^)`) DO set BEDTIME=%%t echo BEDTIME = %BEDTIME% pause The tricky part is escaping special characters bet...
by Eureka!
15 Feb 2021 02:57
Forum: DOS Batch Forum
Topic: How to get all characters after a substring
Replies: 11
Views: 7973

Re: How to get all characters after a substring

You can skip the extra call-statement, which complicates things, by replacing set BUFFER=%x& call set YOURVAR=%BUFFER:*Word=%& call vboxcontrol guestproperty set /myproperties/myproperty %YOURVAR% with: set BUFFER=%x& call vboxcontrol guestproperty set /myproperties/myproperty %BUFFER:*Word=% What h...
by Eureka!
14 Feb 2021 14:15
Forum: DOS Batch Forum
Topic: How to get all characters after a substring
Replies: 11
Views: 7973

Re: How to get all characters after a substring

This is quite chaotic, indeed. What should variable Registry1Ext contain? It looked like it should be .Document.12, but some time later you say: No, I need the version with the string "Word". Whereas the variable "Registry1Ext" has immediately the new content, it looks like the property "myproperty"...
by Eureka!
24 Jan 2021 04:40
Forum: DOS Batch Forum
Topic: Request for help to speed up batch program for 17,000 TXT files
Replies: 6
Views: 5522

Re: Request for help to speed up batch program for 17,000 TXT files

Sure, SORT with /UNIQUE will still sort properly and give the correct values, except the output may have mixed case. That may or may not be a problem. That's why the ... The remaining unique words can be converted to lowercase in a final step All words would still be converted to lowercase. It's ju...
by Eureka!
23 Jan 2021 19:45
Forum: DOS Batch Forum
Topic: Request for help to speed up batch program for 17,000 TXT files
Replies: 6
Views: 5522

Re: Request for help to speed up batch program for 17,000 TXT files

rem Write each remaining word >=4 characters as lowercase on a new line call jrepl "\S{4,}" "$txt=$0.toLowerCase()" /jmatchq /f "%%F" /o - rem Reduce to sorted list of unique words sort /unique "%%F" /o "%%F" It might be more efficient to *not* convert the words to lowercase, as this SORT command i...
by Eureka!
23 Jan 2021 19:20
Forum: DOS Batch Forum
Topic: SORT supports the /UNIQUE and /CASE_SENSITIVE options!
Replies: 5
Views: 4334

Re: SORT supports the /UNIQUE option!

ShadowThief wrote:
23 Jan 2021 14:18
I could have sworn that we already had a thread about this and I learned about it from that.
There was. This was the first time I heard about it (thanks to @penpen), but undoubtedly there were earlier mentions of it.
by Eureka!
30 Dec 2020 14:29
Forum: DOS Batch Forum
Topic: Equivalent 9XDos code to NT Find bat/cmd path %~dp0
Replies: 12
Views: 9711

Re: Equivalent 9XDos code to NT Find bat/cmd path %~dp0

maybe the TRUENAME command can help you here.
Something like: TRUENAME %0 or even TRUENAME %0\..

(but memory is vague; maybe truename wasn't even in Win98)
by Eureka!
28 Dec 2020 08:40
Forum: DOS Batch Forum
Topic: Pass a comand on a batch with admin privileges
Replies: 4
Views: 5073

Re: Pass a comand on a batch with admin privileges

Do you have any code that doesn't require adding registry keys? What is wrong with adding registry keys? (they are removed too, btw) I just want to ask for elevation and pass a parameter, this way it can be autostart from a rar sfx... That is what this script does! I edited the original code a litt...
by Eureka!
27 Dec 2020 05:24
Forum: DOS Batch Forum
Topic: Pass a comand on a batch with admin privileges
Replies: 4
Views: 5073

Re: Pass a comand on a batch with admin privileges

Start DEMO.cmd with some parameters, like DEMO a b c d DEMO.cmd @echo off setlocal :: Check if elevated; restart as elevated admin if not. whoami.exe /groups|findstr /i /c:"S-1-5-32-544" > nul || goto :NEEDADMIN REM Your code here echo This is elevated code echo Demo : current (elevated) commandline...
by Eureka!
22 Nov 2020 15:03
Forum: DOS Batch Forum
Topic: Detecting and removing TABs from a string without prior access to the TAB character
Replies: 14
Views: 11923

Re: Detecting and removing TABs from a string without prior access to the TAB character

You're welcome! (FWIW: another alternative if you have delayedexpansion already enabled) @echo off setlocal enabledelayedexpansion set STRING=abc def ghi.txt set TEMPSTRING=%STRING: =% for /f %%x in ("%TEMPSTRING%") do set NOT=%%~x set REST=!TEMPSTRING:%NOT%=! set TAB=%REST:~0,1% echo NEWSTRING=!STR...
by Eureka!
22 Nov 2020 12:50
Forum: DOS Batch Forum
Topic: Detecting and removing TABs from a string without prior access to the TAB character
Replies: 14
Views: 11923

Re: Detecting and removing TABs from a string without prior access to the TAB character

Basic concept (with comments for clarity) @echo off setlocal :: abc[space][space]def[tab]ghi.txt set STRING=abc def ghi.txt :: Strip spaces set TEMPSTRING=%STRING: =% :: Get first "word" before TAB for /f %%x in ("%TEMPSTRING%") do set NOT=%%~x :: Use all characters of first word as delimiter :: so ...
by Eureka!
18 Nov 2020 10:30
Forum: DOS Batch Forum
Topic: About variable expansion
Replies: 8
Views: 6585

Re: About variable expansion

If your string doesn't contain spaces ( it looks that way, based on your demo string ), you can also do something like this: @echo off setlocal enabledelayedexpansion set string=120400082_V1_UTR_HN512_gfhtgnnrt for /L %%i in (0,1,9) DO set STRING=!STRING:%%i= ! if "%STRING:~0,1%" EQU " " set PRE=* i...
by Eureka!
14 Nov 2020 11:57
Forum: DOS Batch Forum
Topic: how to pick up the duplicated files only from the greatest versions
Replies: 4
Views: 4053

Re: how to pick up the duplicated files only from the greatest versions

My bad! I accidentally added the /R option to the wrong sort (my original version worked fine).
Code and output above are updated.
by Eureka!
13 Nov 2020 19:15
Forum: DOS Batch Forum
Topic: how to pick up the duplicated files only from the greatest versions
Replies: 4
Views: 4053

Re: how to pick up the duplicated files only from the greatest versions

Assuming the structure of the part before the "\" is always the same (\Tnnn-nnnnn-nnnn\) : (and assuming your list is in mockup.lst) @echo off setlocal enabledelayedexpansion for /f "usebackq delims=" %%I in (`sort mockup.lst ^| sort /R /+17`) do ( if /i "!PREVIOUS!" NEQ "%%~nI" ( echo %%I>> after.t...
by Eureka!
08 Nov 2020 15:12
Forum: DOS Batch Forum
Topic: batch file PID
Replies: 6
Views: 6528

Re: batch file PID

Alternative: for /f "tokens=2 delims==" %%i in ( 'wmic process WHERE ^"CommandLine LIKE '%comspec:\=\\% /c wmic process WHERE \^"CommandLine LIKE%%'^" get ParentProcessId /value' ) do set "PID=%%i" (based on this thread ) EDIT: Never mind; a similar solution was already mentioned in one of the linke...