Blog One Column

Windows Environment Variables

Every now and then you will need to create a script or group policy object to automate tasks. 

Enviroment variables make it easier to put in paths. Here are the most commonly used variables. 

Standard (built-in) Environment Variables

Variable Volatile
(Read-Only)
Default value in Windows 7/10/2008 (assuming the system drive is C: )
ALLUSERSPROFILE   C:\ProgramData
APPDATA   C:\Users\{username}\AppData\Roaming
CD Y The current directory (string).
ClientName Y Terminal servers only - the ComputerName of a remote host.
CMDEXTVERSION Y The current Command Processor Extensions version number. (NT = "1", Win2000+ = "2".)
CMDCMDLINE Y The original command line that invoked the Command Processor.
CommonProgramFiles   C:\Program Files\Common Files
COMMONPROGRAMFILES(x86)   C:\Program Files (x86)\Common Files
COMPUTERNAME   {computername}
COMSPEC   C:\Windows\System32\cmd.exe or if running a 32 bit WOW - C:\Windows\SysWOW64\cmd.exe
DATE Y The current date using same region specific format as DATE.
ERRORLEVEL Y The current ERRORLEVEL value, automatically set when a program exits.
FPS_BROWSER_APP_PROFILE_STRING
FPS_BROWSER_USER_PROFILE_STRING
 
  Internet Explorer
Default
These are undocumented variables for the Edge browser in Windows 10.
HighestNumaNodeNumber Y (hidden) The highest NUMA node number on this computer.
HOMEDRIVE Y C:
HOMEPATH Y \Users\{username}
LOCALAPPDATA   C:\Users\{username}\AppData\Local
LOGONSERVER   \\{domain_logon_server}
NUMBER_OF_PROCESSORS Y The Number of processors running on the machine.
OS Y Operating system on the user's workstation.
PATH User and
System
C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths}
PATHEXT   .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .MSC
The syntax is like the PATH variable - semicolon separators.
PROCESSOR_ARCHITECTURE Y AMD64/IA64/x86 This doesn't tell you the architecture of the processor but only of the current process, so it returns "x86" for a 32 bit WOW process running on 64 bit Windows. See detecting OS 32/64 bit
PROCESSOR_ARCHITEW6432   =%ProgramFiles% (only available on 64 bit systems)
PROCESSOR_IDENTIFIER Y Processor ID of the user's workstation.
PROCESSOR_LEVEL Y Processor level of the user's workstation.
PROCESSOR_REVISION Y Processor version of the user's workstation.
ProgramW6432   =%PROCESSOR_ARCHITECTURE% (only available on 64 bit systems)
ProgramData   C:\ProgramData
ProgramFiles   C:\Program Files or C:\Program Files (x86)
ProgramFiles(x86) 1   C:\Program Files (x86)
PROMPT   Code for current command prompt format,usually $P$G
C:>
PSModulePath   %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
Public   C:\Users\Public
RANDOM Y A random integer number, anything from 0 to 32,767 (inclusive).
%SessionName%   Terminal servers only - for a terminal server session, SessionName is a combination of the connection name, followed by #SessionNumber. For a console session, SessionName returns "Console".
SYSTEMDRIVE   C:
SYSTEMROOT   By default, Windows is installed to C:\Windows but there's no guarantee of that, Windows can be installed to a different folder, or a different drive letter.
systemroot is a read-only system variable that will resolve to the correct location.
NT 4.0, Windows 2000 and Windows NT 3.1 default to C:\WINNT
TEMP and TMP User Variable C:\Users\{Username}\AppData\Local\Temp
Under XP this was \{username}\Local Settings\Temp
TIME Y The current time using same format as TIME.
UserDnsDomain Y
User Variable
Set if a user is a logged on to a domain and returns the fully qualified DNS domain that the currently logged on user's account belongs to.
USERDOMAIN   {userdomain}
USERDOMAIN_roamingprofile   The user domain for RDS or standard roaming profile paths. Windows 8/10/2012 (or Windows 7/2008 with Q2664408)
USERNAME   {username}
USERPROFILE   %SystemDrive%\Users\{username}
This is equivalent to the $HOME environment variable in Unix/Linux
WINDIR  

%WinDir% pre-dates Windows NT and seems to be superseded by %SystemRoot%
Set by default as windir=%SystemRoot%
%windir% is a regular variable and can be changed, which makes it less robust than %systemroot%

1 Only on 64 bit systems, is used to store 32 bit programs.

Unless stated otherwise, all the variables above are System variables

Environment variables are stored in the registry:

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

By default, files stored under Local Settings do not roam with a roaming profile.

Dynamic environment variables are read-only and are computed each time the variable is expanded. When all variables are listed with SET, these will not appear in the list. Do not attempt to directly SET a dynamic variable.  

Undocumented Dynamic variables (read only)

%__APPDIR__%   The directory path to the current application .exe, terminated with a trailing backslash. (Global) - discuss
%__CD__%   The current directory, terminated with a trailing backslash. (Global)
%=C:%   The current directory of the C: drive.
%=D:%   The current directory of the D: drive if drive D: has been accessed in the current CMD session.
%DPATH%   Related to the (deprecated) DPATH command.
%=ExitCode%   The most recent exit code returned by an external command, such as CMD /C EXIT n, converted to hex.
%=ExitCodeAscii%   The most recent exit code returned by an external command, as ASCII. (Values 0-32 do not display because those map to ASCII control codes.)
%FIRMWARE_TYPE% The boot type of the system: Legacy ,UEFI,Not implemented ,Unknown Windows 8/2012.
%KEYS%   Related to the (deprecated) KEYS command.
More detail on these undocumented variables can be found in this stackoverflow answer from Dave Benham.

Undocumented Dynamic variables (read/write)

%__COMPAT_LAYER%   Set the ExecutionLevel to either RunAsInvoker (asInvoker), RunAsHighest(highestAvailable) or RunAsAdmin(requireAdministrator) for more see elevation and Q286705 / Application Compatibility Toolkit for other Compatibility Layers (colours,themes etc).

Pass variables between batch scripts

Read more

Abundance Prayer

Hi, everyone its Ramon White with Xtream IT Solutions in west palm beach Florida. If you are having trouble manifesting money in your life I suggest you try this prayer. I have been using it for some months now and it does work for me. Say it like you mean it and watch it do the same for you.

From The Light of God that We Are.

From The Love of God that We Are.

 

From The Power of God that We Are.

From The Heart of God that We Are.

Lets Decree-

We dwell in the midst of Infinite Abundance. The Abundance of God is our Infinite Source.

The River of Life never stops flowing. It flows through us into lavish expression. Good comes to us through unexpected avenues and God works in a myriad of ways to bless us.

We now open our minds to receive our good. Nothing is too good to be true. Nothing is too wonderful to have happened. With God as our Source, Nothing amazes us.

We are not burdened by thoughts of past or future. One is gone. The other is yet to come.

By the power of our belief, coupled with our purposeful fearless actions and our deep rapport with God, our future is created and our abundance made manifest.

We ask and accept that We are lifted in this and every moment into Higher Truth. Our minds are quiet.

From this day forward We give freely and fearlessly into life and Life gives back to us with magnificent increase. Blessings come in expected and unexpected ways. God provides for us in wondrous ways for the work that we do.

I AM indeed grateful.

Read more

I had to include this because I kept getting these errors on my clients 

windows server 2008 r2 box. 

 

After hours of running this through event viewer and searching google here we have it:

If your doing a FILE copy the name of the SOURCE FILE needs to be supplied and the name of the destination file needs to be stated.

NOT WORKING:

Source file \\servername\sharename\filename

Destination file %desktopdir%\

The above is a PATH not a FILE

You will get a file not found issue. It makes sense thought to copy this file from this spot to this directory.

However, you need to specify the source filename and the destination file name.

WORKING:

Source file \\servername\sharename\filename

Destination file %desktopdir%\filename

Example:

Source \\server1\share1\filename1.bat

Destination \\%desktopdir%\filename1.bat

I found if you did *.extension or *.* it worked fine as well.

If you enter a explicit file name in the source directory it did not.

I've tested and it works correctly now.

Tips:

Use User Configuration GPP

In Common select "Run in logged-on user's security context" ( this is the most important step)

In destination file press F3 you will get a menu to choose variables from. I can't confirm but I read that you can't use system variables, as they are different then GPP variables. IE %desktop% (system) vs %desktopdir% (GPP).

Hope this helps.

Read more

Adding Captcha To Webforms in Drupal 7

Read more
Every need  quick solution to drop all those blocked bots from your Drupal Users table? Here is one..

Read more

Craigslist Best Practices Guide

Tired of getting your Ads deleted, ghosted or blacklisted. Then you will want to read this guide!

Read more

How do I add a custom CSS style sheet to certain pages(nodes) in Drupal?

Every now and then a client may ask me,"How do I customize certain pages(nodes) to be different from the rest of the nodes/pages in Drupal?" While there are many methods to do this I prefer using a few snippets of code that will tell Drupal to add

Read more

Pages

ABOUT knowledg3

Ramon White (knowledg3), is a Drupal theme(r), programmer and graphic designer for Xtream Solutions. He founded the company at the tender age of seventeen in West Palm Beach, Florida. Outside of computers he does consulting for the home furnishing industry and the durable goods & manufacturing industries. His part-time passion includes reading natural medicine research papers, and the outdoors in sunny south florida. Ramon can be reached at ramon[at]xtreamsolution[dot]com.

TABBED WIDGET

FLICKR WIDGET