What are the undocumented features and limitations of the Windows FINDSTR command?

Preface Much of the information in this answer has been gathered based on experiments run on a Vista machine. Unless explicitly stated otherwise, I have not confirmed whether the information applies to other Windows versions. FINDSTR output The documentation never bothers to explain the output of FINDSTR. It alludes to the fact that matching lines … Read more

What is the reason for “X is not recognized as an internal or external command, operable program or batch file”?

A) How does Windows command processor search for commands? Windows command processor searches for a COMMAND to execute which is not an internal command of cmd.exe and is just specified with file name without file extension and without path for a file matching the pattern command.* and having a file extension listed in local environment … Read more

How do I get current date/time on the Windows command line in a suitable format for usage in a file/folder name?

See Windows Batch File (.bat) to get current date in MMDDYYYY format: @echo off For /f “tokens=2-4 delims=/ ” %%a in (‘date /t’) do (set mydate=%%c-%%a-%%b) For /f “tokens=1-2 delims=/:” %%a in (‘time /t’) do (set mytime=%%a%%b) echo %mydate%_%mytime% If you prefer the time in 24 hour/military format, you can replace the second FOR line … Read more

Why is no string output with ‘echo %var%’ after using ‘set var = text’ command in cmd? [duplicate]

Assigning a value/string to an environment variable It is best to use following syntax with command extensions enabled to define or modify an environment variable: set “var=text” The command is set and the parameter is “variable=value”. The parameter string can be enclosed in double quotes as on all commands as long as command extensions are … Read more

How does the Windows Command Interpreter (CMD.EXE) parse scripts?

We performed experiments to investigate the grammar of batch scripts. We also investigated differences between batch and command line mode. Batch Line Parser: Here is a brief overview of phases in the batch file line parser: Phase 0) Read Line: Phase 1) Percent Expansion: Phase 2) Process special characters, tokenize, and build a cached command … Read more

Arrays, linked lists and other data structures in cmd.exe (batch) script

Ok. I’ll try to be as clear as possible to not be misunderstood… In Windows Batch files a variable name should begin with a letter and may include any valid character, where valid characters are: #$'()*+,-.?@[]_`{}~ besides letters and digits. This means that from the cmd.exe point of view, SET NORMAL_NAME=123 is exactly the same … Read more

Monitor all print queue job

Use the classes in the System.Printing namespace, for example: Local: Add-Type -AssemblyName “System.Printing” [System.Printing.LocalPrintServer]::GetDefaultPrintQueue() Or remote: Add-Type -AssemblyName “System.Printing” [System.Printing.PrintServer]::new(“\\$computerName”, [System.Printing.PrintSystemDesiredAccess]::AdministrateServer) You can also use the PrintManagement PowerShell module: Import-Module “PrintManagement” $printers = Get-Printer -ComputerName $computerName Get-PrintJob -ComputerName $computerName -PrinterName $printers[0].Name