Glossary of terms used on this site

Search for glossary terms (regular expression allowed)
Begin with Contains Exact term

Glossaries

Term Definition
SC

SC.exe

Service Control - Create, Start, Stop, Query orDelete any Windows SERVICE. The command options for SC are case sensitive.

 
SCHTASKS

SCHTASKS

Create / edit a Scheduled Job/Task. The job can be created on the local or a remote computer.

 
SET

SET

Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.

 
SETLOCAL

SETLOCAL

Set options to control the visibility of environment variables in a batch file.

 
SetSPN

SETSPN.exe (Windows 2003+ or via AD DS)

Read, modify, or delete the Service Principal Names (SPN) for an Active Directory service account.

Syntax SETSPN [modifiers switch] [accountname]Key accountname The name or domainame of the target computer or user account Edit Mode Switches: -R = reset HOST ServicePrincipalName Usage: setspn -R accountname -A = add arbitrary SPN  Usage: setspn -A SPN accountname -S = add arbitrary SPN after verifying no duplicates exist Usage: setspn -S SPN accountname -D = delete arbitrary SPN Usage: setspn -D SPN accountname -L = list SPNs registered to target account Usage: setspn [-L] accountname  Edit Mode Modifiers: -C = accountname is a computer account -U = accountname is a user account  Note: -C and -U are exclusive. If neither is specified, setspn will interpret accountname as a computer name if such a computer exists, and a user name if it does not. Query Mode Switches: -Q = query for existence of SPN Usage: setspn -Q SPN -X = search for duplicate SPNs Usage: setspn -X

searching for duplicates, especially forestwide, can takea long period of time and a large amount of memory.
-Q will executeon each target domain/forest.
-X will return duplicates that existacross all targets. SPNs are not required to be unique across forests,but duplicates can cause authentication issues when authenticatingcross-forest.

 Query Mode Modifiers: -P = suppress progress to the console, use when redirecting output to a file or  in an unattended script. There will be no output until the command is complete. -F = perform queries at the forest, rather than domain level -T = perform query on the specified domain or forest (when -F is also used) Usage: setspn -T domain (switches and other parameters) "" or * can be used to indicate the current domain or forest.

Note: these modifiers can be used with the -S switch in order to specifywhere the check for duplicates should be performed before adding the SPN.Note: -T can be specified multiple times.

SPNs are set up automatically when a computer joins a domain (and when some services are installed). Some services and applications (e.g. SharePoint) require manual modification of a service account's SPN information to authenticate correctly.

If the computer name or Alias is changed, the SPNs for installed services must be changed to match.

Use Setspn -S in preference to Setspn -A, the -S will verify that there are no duplicate SPNs. However, on Windows Server 2003, the -S switch is only available if you update to the SetSPN version from Q970536. Alternatively verify manually that there are no duplicates by running Setspn -L

setspn must be run from an elevated command prompt.

Administrators with only delegated authority (non domain administrators) will require the Validated write to service principle name permission to configure service principal names (SPNs).

Duplicate SPNs will cause Kerberos to fail and fall back to NTLM, run setspn -x periodically to check for this.

SPN Format

When you manipulate SPNs with setspn, the SPN must be entered in the correct format. The format of an SPN is serviceclass/host:port/servicename, in which each item represents a name or value.
Unless the service name and port are non standard, you do not have to enter them.

For example, the default SPNs for a server named Server64 that is providing remote desktop (RDP) services (TERMSRV) over the default port (TCP 3389) register the following two SPNs in its own Active Directory computer object:
TERMSRV/Server64
TERMSRV/Server64.ss64.com

Examples

View a list of the SPNs that the computer server64 has registered with Active Directory from a command prompt:

setspn –l server64

View a list of the SPNs that the local computer has registered with Active Directory from a command prompt:

setspn –l hostname

Reset the SPNs for the computer server64 back to the default:

setspn -r server64

Add an SPN for LDAP to an AD domain controller with the host name dc1.ss64.com:

setspn -s ldap/dc1.ss64.com dc1

Delete the SPN for LDAP from an AD domain controller with the host name dc1.ss64.com:

setspn -d ldap/dc1.ss64.com dc1

Create an alias name for a server:

Create a CNAME record (not a normal Host(A) record.) in DNS:

Set the DisableStrictNameChecking key in the registry:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\LanmanServer\Parameters
DisableStrictNameChecking
Data type: REG_DWORD
Set Value: 1

On the server create SPN's for the flat name and the fully qualified name of the cname alias:
setspn -S host/your_ALIAS_name ServerName
setspn -S host/your_ALIAS_name.domain.com ServerName

Then reboot the Host.

“I have the world's worst taste in men, so now I simply have wonderful relationships of the friend kind, but trying to settle down with somebody? No, no, no, no, no, no, no. I'm beyond that” ~ Harvey Fierstein

Related commands:

RepAdmin - Diagnose Active Directory replication problems between domain controllers.
DcDiag - Analyze the state of domain controllers and report any problems.
DsMgt - Manage password operations over unsecured connections, AD Lightweight Directory Services application partitions, flexible single master operations (FSMO), and clean up AD metadata.
TechNet - Troubleshooting SPN Issues

ata-ad-slot="7649547908">
SETX

SETX.exe (Resource Kit, Windows 7)

Set environment variables permanently,SETX can be used to set Environment Variables for the machine (HKLM) or currently logged on user (HKCU):

Syntax SETX [/s Computer [Credentials]] Variable Value [/m] SETX [/s Computer [Credentials]] [Variable] /k RegistryPath [/m] SETX [/s Computer [Credentials]] /f FileName {[Variable] {/a L,T | /r oL,oT "SearchString"} [/m] | /x} [/d Delimiters]Key: /s Computer The name or IP address of a remote computer. Do not use backslashes. (default = the local computer) Credentials The username and password used to connect to Computer: /u [Domain\]UserName [/p [Password]]] /u [Domain\]UserName Run the script with the credentials of the specified user account. The default value is the system permissions. /p [Password] The password of the user account that is specified in the /u parameter. Variable The name of the environment variable that you want to set. Value The value to which you want to set the environment variable. /k RegistryPath Set the variable based on information from a registry key. The registry path consists of: \HIVE\KEY\...\Value For example: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName /f FileName The file that you want to read. /a L,T Get token T from line L in the file.  The L (line) and T (token) coordinates are numbered starting from 0. /r oL,oT "SearchString" Search the file for a token that matches SearchString, case insensitive. The offset oL (line) and oT (token) coordinates are numbered starting from 0. Negative numbers for oL & oT will count upwards and left respectively. If the token is not found, %errorlevel% will be set to 1. /m Set the variable in the system environment HKLM. (The default is the local environment HKCU) /x Display the file with coordinates against each token. /d Delimiters Specifies delimiters such as "," or "\" to be used in addition to the four built-in delimiters: SPACE, TAB, CR, and LINEFEED. Valid delimiters include any ASCII character. The maximum number of delimiters is 15, including built-in delimiters.

Because SETX writes variables to the master environment in the registry, edits will only take effect when a new command window is opened - they do not affect the current CMD or PowerShell session.

Environment variables are stored in the registry:

User Variables: HKEY_CURRENT_USER\Environment
System Variables: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

Machine variables are stored on the machine and will not follow a users roaming profile. To set a machine variable (/m) requires Administrator rights.

User variables are stored in the user profile and will follow the users roaming profile.

If variables with the same name are stored as both User and Machine Environment variables, the user variable will take precedence. If a Session variable is created that will take precedence over any User and/or Machine Environment variable with the same name.

To edit environment variables in the Windows GUI: Control Panel | System | Advanced | Environment Variables

To delete an environment variable either use the GUI (recommended) or delete the value from the registry with REG delete HKCU\Environment /V _myvar
Deleting a variable with REG will not take effect until next logon due to caching of registry data.
Setting value of "" (empty quotes) will appear to delete the variable - it's not shown by SET but the variable name will remain in the registry.

SETX can be used to set environment variables from one of three sources (modes): String Value Mode, Registry Mode, or File Mode.

String Value Mode

Setting environment variables equal to a simple string is the most basic and common usage of SetX.

Examples: (String Value mode)

Set the variable _car_park to be 'South' in the users environment:

SetX _car_park South

Set the variable _car_park to be 'North' in the MACHINE environment:

SetX _car_park North /m

Store the value of _car_park in a second environment variable
SetX _oldcarpark %_car_park%

Set the _car_park environment variable in the local environment to 'West' on a remote computer named Computer64:

SetX /s computer64 /u ss64dom\user64 /p P7BmqgWZ1a _car_park West

Set the _MyPath environment variable in the local environment to use the search path defined in the %PATH% environment variable:

SetX _MyPath %PATH%

Set the _MyPath environment variable in the local environment to use the search path defined in the %PATH% environment variable after replacing ~ with %:

SetX _MyPath ~PATH~

Set the _MyPath environment variable in the local environment to use the search path defined in the PATH environment variable on a remote computer named Computer64:

SetX /s computer64 /u ss64dom\user64 /p pa55w0rd _MyPath %PATH%

Registry Mode

In registry mode, SetX is an alternative to the REG QUERY command.

The only supported hives are: HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE.

REG_DWORD, REG_EXPAND_SZ, REG_SZ, and REG_MULTI_SZ are the valid RegKey data types.
When reading REG_MULTI_SZ values from the registry, only the first item will be extracted and used.
REG_DWORD registry values are extracted and used in hexadecimal mode.

Examples: (Registry mode)

Set the _TZone environment variable in the local environment to the value found in the HKLM...\StandardName registry key:

SetX _TZone /k HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName 

Set the _Build environment variable in the system environment to the value found in the HKLM\...\CurrentBuildNumber registry key:

SetX _Build /k "HKEY_LOCAL_MACHINE\Software\Microsoft\WindowsNT\CurrentVersion\CurrentBuildNumber" /m

File Mode

File mode supports the parsing of plain text files only, (with CR/LF line endings).

Examples: (File mode)

Display the tokens in a file:

C:__gt__ SetX /f filename.txt /x
(0,0 demo1)(0,1 demo2)(0,2 demo3)
(1,0 demoA)(1,1 demoB)(1,2 demoC)

Set the _ipaddr variable in the local environment to the value found at the coordinate 5,11 in the file Ipconfig.out, the variable will only be visible in a new command shell:

SetX _ipaddr /f ipconfig.out /a 5,11

When using SetX to extract values from a file, we can ignore the variable that is set and instead use FOR /F to grab the extracted token text into the current session. In this way we are using the SetX command more like Findstr.
So to obtain the fourth token in the 1st line of example.txt:

For /F "tokens=3" %%G in ('setx /F example.txt dummyVar /A 1^,4 ^|find "Extracted value"') do set _result=%%G:: remove the trailing periodset _result=%result:~0,1%Echo %_result%

Thanks to Aacini for suggesting improvements to this page over in the forum.

Early versions of SETX (XP) do not support the options /k,/u,/p or /s and have options prefixed with - instead of /.

"You are never dedicated to something you have complete confidence in. No-one is fanatically shouting that the sun is going to rise tomorrow. When people are fanatically devoted to political or religious faiths or any other kind of dogmas or goals, its always because these dogmas or goals are in doubt" ~ Robert M Pirsig

Related:

Syntax - Environment Variables - List of default variables
SET - Display, set, or remove environment variables for a session
REG - Delete keys or values from the registry
Q104011 - Modify variables by editing the Registry
StackOverflow - Storing a Newline in a variable
SETENV - Vincent Fatica's improved version
Powershell: Set-Variable - Set a variable and a value (set/sv)
Equivalent bash command (Linux): setenv - Display, set, or remove environment variables.

ata-ad-slot="7649547908">
SFC

SFC.exe (Windows XP, Server 2003, Win 7)

System File Checker

Syntax Sfc [/Scannow] [/Scanonce] [/Scanboot] [/Revert] [/Purgecache] [/Cachesize=x]Key /Scannow Scan all protected system files immediately and replace incorrect versions with correct Microsoft versions.  May require access to the Windows installation source files. /Scanonce Scan all protected system files one time when you restart your computer. May require access to the Windows installation source files when you restart the computer. The SfcScan DWORD value is set to 2 in the following registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /Scanboot Scan all protected system files every time you start your computer. May require access to the Windows installation source files every  time you start the computer. The SfcScan DWORD value is set to 1 in the following registry key  HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon /Revert Return scan to the default setting (do not scan protected files when you start the computer). The default cache size is not reset when you run this command. /Purgecache Purge the file cache and scan all protected system files immediately. May require access to the Windows installation source files. /Cachesize=x Set the file cache size to x megabytes (MB). The default size of the cache is 50 MB.  This command requires you to restart the computer, and then run the /purgecache command to adjust the size of the on-disk cache. This command sets the SfcQuota DWORD value to x in the following registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

SFC must be run from an elevated command prompt.

“Oh, yes, I've learned from my mistakes and I'm sure I could repeat them exactly” ~ Sir Arthur Streeb-Greebling (aka Peter Cook)

Related:

SLMGR - Software Licensing Management
WINMSD - Windows system diagnostics

ata-ad-slot="7649547908">
SHARE

Share.vbs (Resource Kit)

List or edit a file share or print share (on any computer)

Although missing from recent Resource Kits, this VBS script does still work under recent versions of Windows. The preferred method for creating shares is the RMTShare command, which can also grant permissions.

Syntax: List Shares Share.vbs /L [/S __lt__server__gt__] [/U __lt__username__gt__] [/W __lt__password__gt__] [/O __lt__outputfile__gt__]
Create a Share
Share.vbs /C /N __lt__name__gt__ /P __lt__path__gt__ [/T __lt__type__gt__] [/V __lt__description__gt__]
[/S __lt__server__gt__] [/U __lt__username__gt__] [/W __lt__password__gt__] [/O __lt__outputfile__gt__] Delete a Share
Share.vbs /D /N __lt__name__gt__
[/S __lt__server__gt__] [/U __lt__username__gt__] [/W __lt__password__gt__] [/O __lt__outputfile__gt__]Key:
/L List
/C Create
/D Delete /N name Name of the share to be created or deleted.
/P path Path of the share to be created.
/v description A description for the share.
/T type Type of the share to be created. (Disk, Printer, IPC or Special)
/S server A machine name.
/U username The current user's name.
/W password Password of the current user.
/O outputfile Output file name.

Examples:

List the shares on the machine \\Frodo

cscript Share.vbs /L /s Frodo

Create a file share called "scratch" on the local machine:

cscript Share.vbs /c scratch /p "c:\my shared files" /t Disk /v "project files"

Delete the share named "scratch" on the machine \\Frodo

cscript Share.vbs /d scratch /s Frodo

"The inherent vice of capitalism is the unequal sharing of blessings, the inherent vice of Socialism is the equal sharing of miseries" ~ Winston Churchill


Related:


CACLS - Display or modify Access Control Lists (ACLs) for files and folders
RMTShare - The preferred method for creating a file system share (it can also grant permissions)
RUNDLL32 - Run a DLL command (add/remove print connections)
Powershell: Get-WmiObject win32_share
Equivalent bash command (Linux): mount - Mount a file system

ata-ad-slot="7649547908">
ShellRunAs

ShellRunas (SysInternals tool)

Launch a program under a different user account (typically an Admin level account).

 
SHIFT

SHIFT

Change the position of command line arguments passed to a batch file.

 
SHORTCUT

SHORTCUT.exe (Windows 95 support tools and NT 4 Server Resource Kit)

Create a windows shortcut (.LNK file)

 
SHUTDOWN

SHUTDOWN.exe (for Terminal Services use: TsShutDn)

Shutdown the computer

 
SLEEP

SLEEP.exe (2003 Resource Kit)

Delay execution for a few seconds/minutes (for use within a batch file.)

 
SLMGR

slmgr.vbs (Windows7/2008)

Software Licensing Management Tool. Windows Activation and Key Management Service (KMS)

 
SORT

SORT

Sort will accept a redirected or piped file input and TYPE the file, sorted line by line.