Search found 3615 matches

by aGerman
11 Nov 2019 10:45
Forum: DOS Batch Forum
Topic: SEARCH FOR FOLDERS WITHOUT PDF FILES
Replies: 1
Views: 44

Re: SEARCH FOR FOLDERS WITHOUT PDF FILES

Not sure about your folder structure. My test environment: - A folder with the test script and 3 subfolders a, b, and c. - Only folder b contains a PDF file (along with other files) @echo off &setlocal for /d %%i in (*) do if not exist "%%~i\*.pdf" echo %%i pause Output: a c Drücken Sie eine beliebi...
by aGerman
11 Nov 2019 05:49
Forum: DOS Batch Forum
Topic: Determine if laptop is running on AC or battery
Replies: 7
Views: 167

Re: Determine if laptop is running on AC or battery

If nothing helps I still can write two lines of C code for this purpose. Just let me know.

Steffen
by aGerman
10 Nov 2019 17:38
Forum: DOS Batch Forum
Topic: Play a sound (.wav) file, without opening an application
Replies: 4
Views: 131

Re: Play a sound (.wav) file, without opening an application

There has to be an application involved which is able to process and play your sound file. But the Windows Media Player provides an interface without window using ActiveX. It's not accessible with Batch directly. But you can use hybrid scripts such as npocmaka's mediarunner.bat. https://github.com/n...
by aGerman
09 Nov 2019 15:26
Forum: DOS Batch Forum
Topic: date and time format inconsistencies
Replies: 7
Views: 125

Re: date and time format inconsistencies

mrpaulc wrote:
09 Nov 2019 15:11
and maybe someone knows of a list of formats for locales.
It's dependent on Windows versions, too. There is no value in gathering a list of formats if you are already able to get the information locale-independent IMHO.

Steffen
by aGerman
09 Nov 2019 14:50
Forum: DOS Batch Forum
Topic: date and time format inconsistencies
Replies: 7
Views: 125

Re: date and time format inconsistencies

I assume the format specification is either hard-coded in the executable or (since it is locale-specific) in a .mui file.
However, how could you ever find this information in a binary file if you still want to use only built-in functions of the cmd?

Steffen
by aGerman
09 Nov 2019 12:47
Forum: DOS Batch Forum
Topic: date and time format inconsistencies
Replies: 7
Views: 125

Re: date and time format inconsistencies

What do you mean? wmic.exe belongs to the Windows command line tools just as reg.exe does. If using reg.exe is okay for you, what's wrong with wmic.exe?

Steffen
by aGerman
09 Nov 2019 11:59
Forum: DOS Batch Forum
Topic: date and time format inconsistencies
Replies: 7
Views: 125

Re: date and time format inconsistencies

We have large threads about date and time formatting in this forum. They point out that not even the values of the registry keys are reliable to find out how the cmd formats the strings. To cut a long story short - use WMIC. @echo off &setlocal for /f %%i in ('WMIC OS GET LocalDateTime /value') do f...
by aGerman
08 Nov 2019 10:41
Forum: DOS Batch Forum
Topic: Determine if laptop is running on AC or battery
Replies: 7
Views: 167

Re: Determine if laptop is running on AC or battery

Do hybrid scripts work for you? @if (@a)==(@b) @end /* @echo off &setlocal for /f %%i in ('cscript //nologo //e:jscript "%~fs0"') do set "PowerOnline=%%i" echo %PowerOnline% pause goto :eof */ var objWMIService = (new ActiveXObject('WbemScripting.SWbemLocator')).ConnectServer('.', 'root\\WMI'), colI...
by aGerman
08 Nov 2019 10:29
Forum: DOS Batch Forum
Topic: Determine if laptop is running on AC or battery
Replies: 7
Views: 167

Re: Determine if laptop is running on AC or battery

Does this mean you still work on such an old Windows version where WMIC is not even available? Or is only the BatteryStatus class not available?

Steffen
by aGerman
08 Nov 2019 10:18
Forum: DOS Batch Forum
Topic: Get only information from PHYSICALDRIVE0.
Replies: 1
Views: 102

Re: Get only information from PHYSICALDRIVE0.

Hint: run this in a cmd window ... WMIC Path class-name GET /value ... where you have to replace class-name with the WMI class you want to check. This will output all members of the class with the related values. Use the member which is suitable for filtering the output along with a WHERE statement ...
by aGerman
08 Nov 2019 10:07
Forum: DOS Batch Forum
Topic: Determine if laptop is running on AC or battery
Replies: 7
Views: 167

Re: Determine if laptop is running on AC or battery

Code: Select all

@echo off &setlocal
for /f %%i in ('WMIC /NAMESPACE:\\root\WMI Path BatteryStatus GET PowerOnline /value') do for /f %%j in ("%%i") do set "%%j"
echo %PowerOnline%
pause
You should get either TRUE or FALSE.

Steffen
by aGerman
07 Nov 2019 11:14
Forum: DOS Batch Forum
Topic: [SOLVED] Query if battery is installed.
Replies: 2
Views: 105

Re: Query if battery is installed.

The Win32_ComputerSystem class might be the better choice here. https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystem @echo off &setlocal for /f "delims=" %%i in ('WMIC Path Win32_ComputerSystem GET PCSystemType /value') do for /f "tokens=2 delims==" %%j in ("%%i") do ( if...
by aGerman
06 Nov 2019 13:18
Forum: DOS Batch Forum
Topic: [SOLVED] Get TRUE HDD data as opposed to CAPACITY data.
Replies: 5
Views: 180

Re: Get TRUE HDD data as opposed to CAPACITY data.

Any exit /b or goto :eof in your main code will lead to leave the script processing. (FWIW goto :eof is for "go to end of file", no actual :eof label necessary.) That's why I wrote that you need it at the end of the main code. @echo off SetLocal EnableDelayedExpansion Set OUTPUT=%userprofile%\Deskto...
by aGerman
06 Nov 2019 10:54
Forum: DOS Batch Forum
Topic: [SOLVED] Get TRUE HDD data as opposed to CAPACITY data.
Replies: 5
Views: 180

Re: Get TRUE HDD data as opposed to CAPACITY data.

Batch is by far the worst language to do things like that. You can't calculate with numbers having decimals because numbers in Batch are integers only. And since the type size of this integer is limited to 32 bits you can't even process the volume size in bytes because 2147483647 is the greatest val...
by aGerman
05 Nov 2019 19:22
Forum: DOS Batch Forum
Topic: [SOLVED] Delete row in >> %OUTPUT%.
Replies: 8
Views: 213

Re: Delete row in >> %OUTPUT%.

I don't know all the WMI classes and their members by heart. Good point to start in your case is that site: https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/operating-system-classes Just have a look at the classes of your interest and see if one of them has the members you are looking for...