Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

how restore damage environment variables

$
0
0

hi all, i damage in some way my environment variables and now im unable to run anything with elevation.

The only command that i use was:

[environment]::setenvironmentvariable("Path", thepathvariablethaticompute, "Machine")

before i make any change i save the content of the path variable because that was the variable that i want to modify. So after the things goes wrong i reestablish the order setting the Path to the old value. To my surprise that doesn't was enough and now every time i try to run something with elevation the system doesnt found the excutable.

Perhaps that some things still works, if i go to the execute (win+R) and write notepad, cmd, etc, they are executed normally. But if i want to explore the advances system options c:\windows\system32\systemPropertiesadvanced.exe then this message appear:

The System could not find the environment option that was entered.

To diagnose the problem in cmd i ask for the environment variables, this is the output:

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\voodoomsr\AppData\Roaming
CLASSPATH=.;C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=VOODOOMSRLAPTOP
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
FTP_PASSIVE=1
HOMEDRIVE=C:
HOMEPATH=\Users\voodoomsr
LOCALAPPDATA=C:\Users\voodoomsr\AppData\Local
LOGONSERVER=\\VOODOOMSRLAPTOP
MOZ_PLUGIN_PATH=C:\Program Files\Tracker Software\PDF Viewer\Win32
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
USERDOMAIN=voodoomsrlaptop
USERNAME=voodoomsr
USERPROFILE=C:\Users\voodoomsr

In the powershell i get different results when i ask for the path variable

if i do:

$env:path

the result is : %SystemRoot%\system32\WindowsPowerShell\v1.0\

if i do: [environment]::GetEnvironmentVariable("Path","User")

then i get all the correct path:

C:\Windows\system32\WindowsPowerShell\v1.0\;C:\Program Files\Common Files\Microsoft Sh
ared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:
\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\HTML Help Workshop;C:
\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin;C:\Program Files (x86)\Microsoft
 SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\x64;C:\Program Files (x86)\Microsoft SDKs\Wind
ows\v7.0A\bin\x64;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program
 Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL
 Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual St
udio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tool
s;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools;C:\
Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Performance Tools\x64;C:\P
rogram Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64;C:\Program Files (x86)\Mi
crosoft Visual Studio 10.0\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studi
o 2008 SDK\VisualStudioIntegration\Tools\Sandcastle\ProductionTools\;C:\Program Files
(x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86
)\MiKTeX 2.8\miktex\bin;C:\Program Files (x86)\PHP\;C:\Program Files\7-Zip;C:\Program
Files\Intel\WiFi\bin\;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Users
\voodoomsr\Valhala\GPS1C;C:\Users\voodoomsr\Valhala\ShortCuts;C:\Users\voodoomsr\Valha
la\Utilitarios\bin;C:\Users\voodoomsr\Valhala\Utilitarios\SysinternalsSuite;C:\Windows
;C:\Windows\Microsoft.NET\Framework64\v3.5;C:\Windows\Microsoft.NET\Framework64\v4.0.3
0319;C:\Windows\system32;C:\Windows\System32\Wbem;C:\Windows\system32\WindowsPowerShel
l\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\PostgreSQL\8
.4\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\
strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Users\voodoomsr
\Valhala\GAHKC;;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0;C:\Use
rs\voodoomsr\Valhala\Utilitarios\Q10

I get the same result using   [environment]::GetEnvironmentVariable("Path","Machine")

so i really don't understand what is happening, with the inspection everything appears to be normal except the path variable.Using .net appears fine but directly $env:path is incomplete. If i ask in cmd for path then it tellsme that is null.

Any helps is apreciated.

 

 

 


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>