The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,733 other followers

Archive for the ‘Batch-Files’ Category

How bad is the Windows command line really?

Posted by jpluimers on 2017/04/13

How bad is the Windows command line really?

The Windows command line is bad. Very bad.

But it took until recently for old Windows versions – that out of the box had either no or poor PowerShell versions – to have slowly died.

So only now PowerShell finally has become an option that really works across all Windows versions I use. Go PowerShell!

–jeroen

Posted in Batch-Files, Development, PowerShell, Scripting, Software Development | Leave a Comment »

7zip: compress from the command-line; a few notes and a small batch file

Posted by jpluimers on 2017/04/04

I wanted to compress a few files from the current directory in a zip file using the 7z.exe command-line version of 7zip.

The trick is about finding where 7z.exe is as the directory containing 7z.exe is not in the Windows PATH.

Notes:

setlocal
call SortDateTime.bat
echo %SortDateTime% %SortDate%-%SortTime%

for /f "usebackq tokens=2* delims= " %%c in (`reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path`) do (
  set sevenzExe="%%d7z.exe"
)
endlocal & if exist %sevenzExe% %sevenzExe% a -tzip _my-build.%SortDate%-%SortTime%.zip MyServer.exe MyServer.map MyClient.exe MyClient.map

pause

–jeroen

Posted in Batch-Files, Development, Power User, Scripting, Software Development | Leave a Comment »

defrag.exe: tracking an already in progress operation can be done from non-admin session

Posted by jpluimers on 2017/03/17

When you want to defrag.exe (the built-in Windows one, not the SysInternals Windows NT4 one, so make sure SysInternals comes last in your path) a volume, you have to run it with an elevated UAC Admin token.

But I just found out that you can do this without an Admin token:

C:\Windows\System32>Defrag.exe C: /t /v /u
Microsoft Drive Optimizer
Copyright (c) 2013 Microsoft Corp.

Tracking operation on (C:)...


Performing pass 2:
        Free Space Consolidation:  31% complete...

This makes it much easier to separate monitoring scripting from execution.

–jeroen

Posted in Batch-Files, Development, Scripting, Software Development | Leave a Comment »

Windows 10 – language neutral batch file to start Windows

Posted by jpluimers on 2017/02/22

A while ago, I bitched that Microsoft moved away the Windows Update out of the Control panel into a language depended place (in Windows 10 1511 update broke the Hyper-V networking – Fix network connection issues).

Since then I had to maintain too many locales running Windows 10. So here is the batch file:

for /f "delims=" %%A in ('PowerShell -Command "(Get-Culture).Name"') do explorer "%LocalAppData%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\%%A\AAA_SystemSettings_MusUpdate_UpdateActionButton.settingcontent-ms"

It uses these tricks:

  1. Set output of a command as a variable (in this case a for loop variable)
  2. Execute PowerShell script in a .bat file
  3. PowerShell Get-Culture (which gets a .NET CultureInfo instance)
  4. CultureInfo.Name property (which has the nl-NL, en-US, etc codes in it)

It replaced this simple batch-file which has worked for like 10 years:

%windir%\System32\rundll32.exe url.dll,FileProtocolHandler wuapp.exe

–jeroen

via: Windows Update Shortcut – Create in Windows 10 – Windows 10 Forums

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, Batch-Files, CommandLine, Development, Power User, PowerShell, Scripting, Software Development, Windows, Windows 10 | Leave a Comment »

Windows batch file – setting space as delimiter when parsing files

Posted by jpluimers on 2017/01/04

for /f "tokens=* delims= " %%f in (myfile) do

If you put delims as the last parameter, then an ending space will be included as delimiter (at the start or in the middle it won’t).

A great tip by jeb and Joey in an answer for windows – Batch file FOR /f tokens – Stack Overflow

–jeroen

Posted in Batch-Files, Pingback, Scripting, Software Development, Stackoverflow | Leave a Comment »

 
%d bloggers like this: