The Wiert Corner – irregular stream of stuff

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

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

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

    Join 1,512 other followers

Archive for the ‘Batch-Files’ Category

Run cmd as elevated user (via: windows – How to run batch file command with elevated permissions? – Super User)

Posted by jpluimers on 2019/03/13

Based on [WayBack] windows – How to run batch file command with elevated permissions? – Super User:

powershell -command "Start-Process cmd.exe -Verb runas"

This works better than "runas /user:administrator cmd.exe" as that forces to use the specific Administrator account, whereas the PowerShell way allows you to specify the actual account during elevation.

–jeroen

Posted in Batch-Files, CommandLine, Console (command prompt window), Development, Power User, PowerShell, PowerShell, Scripting, Software Development, Windows | Leave a Comment »

msbuild: /p: or /property: but be ware of the equals sign

Posted by jpluimers on 2019/02/27

From [WayBackHow do I pass this common property to MSBuild using TeamCity? – Stack Overflow, I learned you can pass properties to msbuild using the /p:propertyname=value or /property:propertyname=value syntax (where you can quote "value" when needed):

I am using the TeamCity Visual Studio runner. I want to add a setting that is not accessible from Visual Studio./Property:FileAlignment=4096I typed that directly into the build step “Command line

However, when passing these parameters to batch files first, be aware that they can strip equals signs from parameters: [WayBack] windows – Preserving “=” (equal) characters in batch file parameters – Stack Overflow

I bumped into this when passing properties to https://bitbucket.org/jeroenp/wiert.me/src/tip/Run-Dependend-rsvars-From-Path.bat

–jeroen

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

Windows <= 10: batch file to open Windows Update panel

Posted by jpluimers on 2019/02/15

Up until Widows 8.1, you could use wuapp to start the Windows Update panel.

For a while, Windows 10 needed a cumbersome language specific workaround described at Windows 10 – language neutral batch file to start Windows.

That stopped working after a few builds, but I forgot to make a note in which build exactly. Already in Windows 10 build 10122, the icon in wucltux.dll, so this might have been shortly after the initial “RTM” (retroactively named 1507).

So for a while, I had this batch file:

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)

But now I have extended it to support old and new Windows versions:

if exist %windir%\System32\wuapp.exe (
  %windir%\System32\rundll32.exe url.dll,FileProtocolHandler wuapp.exe
) else (
  %windir%\explorer ms-settings:windowsupdate
)

–jeroen

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

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

In windows, can I redirect stdout to a (named) pipe in command line? – Super User

Posted by jpluimers on 2019/01/14

Interesting thought [WayBackIn windows, can I redirect stdout to a (named) pipe in command line? – Super User.

The only problem seems to be a good way of creating/removing those pipes.

–jeroen

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

List of Shell GUIDs for various Windows versions for use in shortcuts and batch files

Posted by jpluimers on 2019/01/09

In my search for starting the Windows Credential Manager from the console, I found [WayBackCredential Manager Shortcut – Create – Windows 7 Help Forums explaining:

%windir%\explorer.exe shell:::{1206F5F1-0569-412C-8FEC-3204630DFB70}

This reminded me of From batch file or shortcut: start Windows Update (via: Windows 7 Help Forums) and batch-file trick: Starting Windows Explorer and selecting a file (“explorer” commandline parameters “/n” “/e” “/select” “/root” “/start” site:microsoft.com).

The odd thing is that some of the GUID shortcuts works fine using the shell::: syntax, but fail with the /e:: syntax, for instance Windows Update until Windows 8.1:

%windir%\explorer.exe shell:::{36eef7db-88ad-4e81-ad49-0e313f0c35f8}
%windir%\explorer.exe /e,::{36eef7db-88ad-4e81-ad49-0e313f0c35f8}

One day I’ll create a table of permutations for various Windows versions and execute options.

For now these links need to suffice:

–jeroen

Posted in Batch-Files, Development, Power User, Scripting, Software Development, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows 9 | 1 Comment »

 
%d bloggers like this: