PrintUI (CMD)

Add and remove local printer and driver through the command line. Can be used in scripts or packages. Before adding the printer, setup port and restart the Print Spooler service.

rundll32 printui.dll PrintUIEntry /if /b "ETIAM Print-in" /f "%ProgramFiles%\Etiam\Print-In\Driver\Print-in.inf" /r "PrintIn Port" /m "ETIAM Print-in" /q
rundll32 printui.dll PrintUIEntry /Xs /n "ETIAM Print-in" comment "ETIAM virtual printer" location "http://www.etiam.com" /q
rundll32 printui.dll PrintUIEntry /dl /n "ETIAM Print-in" /q
rundll32 printui.dll PrintUIEntry /dd /m "ETIAM Print-in" /q

Multiple Commands in one line (CMD)

Run multiple commands in one line with Windows Command Shell.

START /W CMD.EXE /C & C: & CD\ & DEL /F /S /Q "[filename]" >"%temp%\delete.log"
START /W CMD.EXE /C & DEL /F /Q "[path][filename]" >"%temp%\delete.log"

You can use the special characters listed in the following table to pass multiple commands.

CharacterSyntaxDefinition
& […]command1 & command2Use to separate multiple commands on one command line. Cmd.exe runs the first command, and then the second command.
&& […]command1 && command2Use to run the command following && only if the command preceding the symbol is successful. Cmd.exe runs the first command, and then runs the second command only if the first command completed successfully.
|| […]command1 || command2Use to run the command following || only if the command preceding || fails. Cmd.exe runs the first command, and then runs the second command only if the first command did not complete successfully (receives an error code greater than zero).
( ) […]( command1 & command2)Use to group or nest multiple commands.
; or ,command1 parameter1;parameter2Use to separate command parameters.

Note: The ampersand (&), pipe (|), and parentheses ( ) are special characters that must be preceded by the escape character (^) or quotation marks when you pass them as arguments

Note: This method can also be used in a .MSI package, through a Custom Action

Source: Microsoft

ICACLS examples (CMD)

Here are a few examples of the most common Icacls commands, that I use in Command Shell, to give further access.

icacls.exe "[folder]" /grant *S-1-5-32-545:(OI)(CI)F
icacls.exe "[folder]" /grant *S-1-5-32-545:(OI)(CI)M
icacls.exe "[path][file]" /grant *S-1-5-32-545:F
icacls.exe "[path][file]" /grant *S-1-5-32-545:M

For a complete list of ‘Well-known security identifiers’ (SIDs) please visit Microsoft.

Note: Icacls are build into Windows Vista, Windows 7 & Windows 8 and equivalent Windows Servers

SetACL examples (CMD)

Here are a few examples of the most common SetACL commands, that I use in Command Shell, to give further access.

SetACL.exe -on "[folder][file]" -ot file -actn ace -ace "n:S-1-5-32-545;p:change;s:y"
SetACL.exe -on "[folder][file]" -ot file -actn clear -clr "dacl,sacl"
SetACL.exe -on "[key]" -ot reg -actn ace -ace "n:S-1-5-32-545;p:full;s:y"
SetACL.exe -on "[service]" -ot svr -actn ace -ace "n:S-1-5-32-545;p:start_stop;s:y"

For a complete list of ‘Well-known security identifiers’ (SIDs) please visit Microsoft.