Windows Environment Variables

Windows Environment Variables

Environment variables are mainly used within batch files, they can be created, modified and deleted using the SET command.

Variables can be displayed using either SET or ECHO.

Variables have a percent sign on both sides: %ThisIsAVariable%
The variable name can include spaces, punctuation and mixed case: %_Another Ex.ample%
(This is unlike Parameter variables which only have one % sign and are always one character long: %A )

In a batch file the default behaviour is to read and expand variables one line at a time, for example:

 SET /P _price=”Enter the price: ”
ECHO %_price%

The above will work, but the version below will fail because %_price% will remain undefined until processing reaches the next line, this behaviour can be changed using SETLOCAL EnableDelayedExpansion

 SET /P _price=”Enter the price: ” & ECHO %_price%
ECHO That didnt work!

Standard (built-in) Environment Variables

Variable Default value:
Windows XP
Default value:
Windows 7/2008
%ALLUSERSPROFILE% C:\Documents and Settings\All Users C:\ProgramData
%APPDATA% C:\Documents and Settings\{username}\Application Data C:\Users\{username}\AppData\Roaming
%CommonProgramFiles% C:\Program Files\Common Files C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files C:\Program Files (x86)\Common Files
%COMPUTERNAME% {computername} {computername}
%COMSPEC% C:\Windows\System32\cmd.exe C:\Windows\System32\cmd.exe
%HOMEDRIVE% C: C:
%HOMEPATH% \Documents and Settings\{username} \Users\{username}
%LOCALAPPDATA%

N/A

(but can be manually addedLOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data)

C:\Users\{username}\AppData\Local
%LOGONSERVER% \\{domain_logon_server} \\{domain_logon_server}
%PATH% C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths} C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths}
%PATHEXT% .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .MSC
%ProgramData% N/A C:\ProgramData
%ProgramFiles% C:\Program Files C:\Program Files
%ProgramFiles(x86)% 1 C:\Program Files (x86) C:\Program Files (x86)
%PROMPT% Code for current command prompt format,usually $P$G
C :>
Code for current command prompt format,usually $P$G
C :>
%PSModulePath% N/A %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
%Public% N/A C:\Users\Public
%SYSTEMDRIVE% C: C:
%SYSTEMROOT% C:\Windows C:\Windows
%TEMP% and %TMP% C:\Documents and Settings\{username}\Local Settings\Temp C:\Users\{Username}\AppData\Local\Temp
%USERDOMAIN% {userdomain} {userdomain}
%USERNAME% {username} {username}
%USERPROFILE% %SystemDrive%\Documents and Settings\{username} %SystemDrive%\Users\{username}
%WINDIR% C:\Windows C:\Windows

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

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

%ERRORLEVEL% is a dynamic variable that is automatically set when a program exits.

Dynamic Variables

There are also 6 dynamic environment variables, these are computed each time the variable is expanded.
n.b. you should not attempt to directly SET a dynamic variable.

%CD% – The current directory (string).

%DATE% – The current date using same region specific format as DATE.

%TIME% – The current time using same format as TIME.

%RANDOM% – A random decimal number between 0 and 32767.

%CMDEXTVERSION% – The current Command Processor Extensions version number.

%CMDCMDLINE%
 – The original command line that invoked the Command Processor.

Pass a variable from one batch script to another

Where one batch script CALLs another it is recommended that you SETLOCAL in both scripts to prevent any possible naming conflicts, so each script should start with:
@ECHO OFF
SETLOCAL

Then to pass a value back to the original calling script, finish the script with a line like:

ENDLOCAL & SET _output=%_variable%

In the line above %_variable% is a local variable used and visible within just that one batch script
%_output% is an output variable that is passed back to the original calling script

“Men may be convinced, but they cannot be pleased against their will. But though taste is obstinate, it is very variable, and time often prevails when arguments have failed” – Samuel Johnson

Related:

CALL – Evaluate environment variables
SET – Display, set, or remove variables
Q100843 – The four types of environment variable
Q286705 – Set compatibility variables
Q242557 – Registry Settings for Folder Redirection
Managing Roaming User Data Deployment Guide – Microsoft.com (Word Doc)

ที่มา : http://ss64.com

http://ss64.com

แก้ปัญหาเมนูเป็นภาษาต่างดาวบน Win7 [3ds max 2009]

แก้ปัญหาเมนูเป็นภาษาต่างดาวบน Win7 [3ds max 2009] แบบเกรียนๆ

ไปcopy font ใน windows xp มาลงทับ font บน Win7 ให้หมด แค่นี้ก็ได้และครับ : )

มาใช้งาน Windows XP Mode ใน Windows 7 กันดีกว่า!!!

หลานท่านคงเคยประสบปัญหาเกี่ยวกับการใช้งานหรือโปรแกรมต่างๆบน  Windows 7 กันมาบ้างแล้ว เพราะโปรแกรมต่างๆบางโปรแกรม
ยังไม่รองรับ  Windows 7 หรือในกรณีที่เราอยากเล่นโปรแกรมหรือเกมส์เก่าๆบน  Windows 7 ก็ไม่สามารถเล่นได้

ความจริงวิธีใช้งาน  Windows XP Mode ใน Windows 7 ก็สามารถทำได้หลายแบบ แต่วันนี้ผมขอแนะนำอีก 1วิธี
ซึ่งไม่ค่อยมีใครเขียนหรือพูดถึงมากเท่ากับ Virual PC สำหรับวิธีอื่นๆก็หากันเอาเองครับ :]]

 

1. เริ่มแรกให้เราหาโปรแกรม VMware Workstation มาก่อน (จะหามาด้วยวิธีไหนก็แล้วแต่คุณ) เมื่อหาโปรแกรมได้แล้ว

ให้ทำการติดตั้ง
จากนั้นให้เราทำการเปิดโปรแกรม VMware ขึ้นมา แล้วทำการสร้าง New Virual Machine ขึ้นมาใหม่

https://i0.wp.com/image.free.in.th/z/ik/hn7n1.jpg?resize=580%2C326

 

2. เลือก Typical (หรืออื่นๆ ถ้าคุณ Advance พอ)
คลิก next

https://i0.wp.com/image.free.in.th/z/ic/9fy52.jpg?resize=580%2C326

 

3. เลือก source ของตัวติดตั้ง Windows XP จะใช้จาก VCD หรือไฟล์ ISO ก็ตามแต่
คลิก next

https://i0.wp.com/image.free.in.th/z/if/ye8u3.jpg?resize=580%2C326

 

4. เลือกตามรูปเลยครับ
คลิก next

https://i0.wp.com/image.free.in.th/z/ib/q4hi4.jpg?resize=580%2C326

 

5. ใส่ CD key เข้าไป (หรือไม่ไส่ก็ได้ครับ ไม่เป็นปัญหา)
ใส่ชื่อผู้ใช้
คลิก next

https://i0.wp.com/image.free.in.th/z/in/mqr65.jpg?resize=580%2C326

 

6. ตั้งชื่อ Virual Machine ของเรา แล้วเลือกที่เก็บ
คลิก next

https://i0.wp.com/image.free.in.th/z/ig/zqp66.jpg?resize=580%2C326

 

7. เลือกขนาดของ Hard disk ที่จะใช้
คลิก next

https://i0.wp.com/image.free.in.th/z/ij/8uq37.jpg?resize=580%2C326

 

8. สำหรับขั้นตอนนี้ ถ้าเราจะเพิ่มแรมหรือตัดอุปกรณ์จำลองต่างๆ  ให้คลิกที่ Customize Hardware
แล้วก็ปรับสิ่งที่ต้องการ เมื่อพอใจแล้วให้คลิก OK
คลิก Finish

สำหรับขั้นตอนการติดตั้ง Windows XP ผมขอไม่พูดถึง แต่ให้ไปอ่านกันเองที่ http://www.dld.go.th/ict/article/soft/soft02.html

https://i0.wp.com/image.free.in.th/z/is/awqm8.jpg?resize=580%2C326

 

9. เมื่อเราลง Windows XP เสร็จเรียบร้อย ให้ทำการเปิดขึ้นมาครับแล้วลงโปรแกรมบน Windows XP ที่เราต้องการลงไปครับ
เมื่อลงโปรแกรมที่ต้องการครบแล้ว ให้ไปที่ View >> Unity หรือดูตามรูปครับ
เมื่อคลิกแล้ว โปรแกรมก็จะย่อตัวเองอัตโนมัต ก็ไม่ต้องไปยุ่งกับมันครับ

https://i0.wp.com/image.free.in.th/z/in/u1459.jpg?resize=580%2C326

 

10. จะเห็นได้ว่า เมื่อเรานำเมาส์ไปชี้บริเวณปุ่ม Start ของ windows 7 ขะมีปุ่ม Windows XP โผล่ขึ้นมา
ให้เราคลิกเข้าไปเพื่อเริ่มใช้งานได้เลยครับ

https://i0.wp.com/image.free.in.th/z/id/8dy10.jpg?resize=580%2C326

 

11. ทดสอบเปิดโปรแกรม Windows Media Player 9 จาก Windows XP ครับ

https://i0.wp.com/image.free.in.th/z/ip/51d11.jpg?resize=580%2C326

 

12. เมื่อเราต้องการเลิกใช้งาให้ขยายหน้าต่าง VMware ขึ้นมาครับ แล้วคลิกที่ Exit Unity เพื่อออกจากโหมด

https://i0.wp.com/image.free.in.th/z/ii/mph12.jpg?resize=580%2C326

อย่างที่บอกครับ การใช้งาน Windows XP บน  windows 7 สามารถทำได้หลายแบบ แต่สำหรับผม
ผมชอบวิธีนี้นะ ทำง่ายและสะดวกดี อีกอย่างมันก็ขึ้นอยู่กับความชอบส่วนบุคคลด้วยแหละครับ :]]

By Sornram9254

แก้ปัญหา Log Off แล้วติด Password ของ Windows XP

แก้ปัญหา Log Off แล้วติด Password ของ Windows XP
เนื่อง มาจากที่วิทยาลัยผมใช้ windows xp ของ sKz อยู่ แต่มีปัญหาตรงที่ เวลา Logoff พอจะกลับเข้าไปใหม่ กลับติด Password ซะงั้น ผมก็เลยลองหาวิธี Reset password มั่วๆ แต่ก็เจอจนได้ อิอิ
วิธี Reset password
กด win + R >> พิมพ์ lusrmgr.msc >> ดับเบิลคลิกที่ Users >> คลิกขวาที่ Administrator >> เลือก Set Password… >> กด Proceed >> ใส่ Password ที่ต้องการลงไป >> กด OK

ทิปเล็กๆน้อยๆ ที่ผมใช้ประจำ และได้ผล ถ้าใครทราบแล้ว ก็ขออภัยด้วยนะครับ ^________^

By : Sornram9254