PS: Behavior of Environment Variable Prioritization

Priority handling when there are conflicting and/or same variables at both Machine and User level: PS C:> $a = [Environment]::GetEnvironmentVariable("Temp","Machine") PS C:> echo $a C:WindowsTEMP PS C:> $a = [Environment]::GetEnvironmentVariable("Temp","User") PS C:> echo $a C:UsersgovardhanAppDataLocalTemp PS C:> $a = [Environment]::GetEnvironmentVariable("Temp") PS C:> echo $a C:UsersGOVARD~1AppDataLocalTemp PS C:> In case of a conflict, Windows and thus PS refers to User level variable under a user session.   The weird behavior is sometimes, you environment variables aren’t read as either type “User” or “Machine” but can be read without any type specification. PS C:> $a = [Environment]::GetEnvironmentVariable("appdata","User") PS C:> echo $a PS […]

Read more

VBscript to Send Key Strokes (Auto Response) to the Windows Applications

Here is a very simple and quick VBscript that can automated press OK on your Windows Run prompt. If you have any of the command types in your Run box, that gets executed simply by running this script. set shell = createobject("wscript.shell") wscript.sleep 200 success = shell.appactivate("Run") if success then shell.sendkeys "{tab}" wscript.sleep 400 shell.sendkeys "{enter}"   Steps: Open the Run, (use Windows key + R) Type cmd in the Run box Open the Explorer where you have the above code saved as .vbs script Double click on the .vbs script file for it to run That’s it will see […]

Read more

PS: Using GetEnvironmentVariable to Manage Environment Variables

Here’s a quick tip on working with Windows PowerShell. These are published every week for as long as we can come up with new tips. If you have a tip you’d like us to share or a question about how to do something, let us know. Find more tips in the Windows PowerShell Tip of the Week archive. Creating and Modifying Environment Variables Most people know how easy it is to use Windows PowerShell to retrieve information about environment variables. Want to see all your environment variables and their values? This command should do the trick: Copy Get-ChildItem Env: In […]

Read more