From wiki
Revision as of 08:07, 9 December 2019 by Hdridder (talk | contribs) (Errors and solutions)
Jump to: navigation, search

Things I learned that may come in handy whenever I'm forced to go windows.

Command files

%1, %2
Positional parameters (like $1,$2 in unix shells)


SET /A <name>=<a><operator><b>
Assign the value of the arithmetic operation to <name>


call:do_it hi bye

zip -r %bckdir%\ %a%\test
echo Passed parameters %~1% and %~2%


NOTE: The exact positions (what follows :~) depend on the date format set on your system. Check what echo %date% and echo %time% return.

To avoid the resulting string to have spaces (e.g. for hours) replace them with 0.

SET YYYY=%date:~-4,4%
SET DD=%date:~-7,2%
SET MM=%date:~-10,2%
SET HR=%time:~0,2%
SET MIN=%time:~3,2%
SET SEC=%time:~6,2%
SET timestamp=%YYYY%%MM%%DD%_%HR%%MIN%%SEC%
SET timestamp=%timstamp: =0%

Recursively find files

for /R  %%D in (*) DO ( 
	echo full path: "%%D"
	echo fil ename: "%%~nxD"

Errors and solutions

CMD does not support UNC paths as current directories.

You get this when you try to cd to a UNC path (\\server\dir\dir\)

pushd <UNCpath>
This works.

Unable to delete files

takeown /f <file name> /d y
icacls <file name> /grant administrators:F

Found running a python program

"System.Messaging.MessageQueueException: Insufficient resources to perform operation."
There are insufficient resources to perform the migration, and this is specific to the MSMQ. The size of the MSMQ itself is limited to 4MB, requests have to be within that limit.
  • Open 'Server Manager'
  • Go to the "Features" tab - under the Features tab, right-click 'Message Queueing'
  • Select "Properties"
  • On the "General" tab, un-tick 'Storage limits'


  • Go to Tools - 'Computer Management'
  • Go to 'Services and Applications'
  • Open the 'Message Queuing' properties, un-tick 'Storage limits'