Link to home
Start Free TrialLog in
Avatar of jeremyjared74
jeremyjared74Flag for United States of America

asked on

Set Windows 7 "WINDIR" Environment Variable using Command Line

Hi experts, I've been having some issues with my PC (Windows 7 Home Professional). I believe I've removed the virus after sever hours of trial and error. I had almost everything working correct except some of the settings for my user account wouldn't save.

I'm very good ad web code/script, but when it comes to OS related scripting I'll be the first to admit
it ain't pretty
. So the first thing that came to mind is "I need to change the environment variables". Why? I have no idea, maybe lack of sleep.

The Problem:
I mad an error entering the WINDIR path, and now I can't fix it. The links that you would normally use to change the environment variable are now rendered useless. I've been trying for a few hours to figure out how to fix it using the command prompt, but no luck. And I just don't have the time it seems it will take to actually learn rather than copy paste.

Do you know how to fix it? Also, this isn't required but if you have any pointers on why certain things won't save to my user profile (start menu items, toolbar items, etc), I'd be very thankful for a nudge in the right directions.

Regards,
Jeremy Jared
Avatar of sshah254
sshah254

The correct way to set environment variables is by going to "Computer - Properties - Advanced Settings - Environment variables" and you can set it under either user, or system.

If you are not able to make changes to your profile, then I have a feeling that you still have the virus.

I would boot up from a clean system and do a virus scan of the whole C: drive before doing anything if I were you.

Good Luck.

SS
Avatar of jeremyjared74

ASKER

I mentioned in the question that I set the variable to an incorrect value. I was able to use the method you spoke of, but now the link gives an error. Just my luck, I get the one wrong that goes to the link I'd use to fix it.
These are the PATH variables that are in my ENV VAR that are basic. Below is pasted others that I have

PATH=PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Sys
tem32\WindowsPowershell\v1.0\;C:\Program Files (x86)\Java\jdk1.6.0_25\bin\


PATH=PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\Sys
tem32\WindowsPowershell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\To
ols\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files
\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Java\jdk1.6.0_25\bin\
;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Fil
es (x86)\Microsoft SQL Server\90\Tools\binn\

Hope these help!

Advise otherwise.

Thanks
Avatar of johnb6767
If you can get to regedit, go to the PATH value here and modify it...

Hklm/System/CurrentControlSet/Control/Session Manager/Environment

Course, more details on the actual problems might help if you need other assistance..
By the way remove the

PATH=PATH=

from the equation. I was wondering why mine was flopped when I pressed CMD in run.

Thanks by the way??

Advise if you need more help?/?
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, I'm getting closer. I'm seeing that the code is working. Before when I entered the paths I either received an error, or it would just return another blank line in the command prompt. The code above seems to have somewhat fixed it:
C:\Windows\System32\setx.exe PATH "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"

Open in new window


Anything that requires elevated permissions (RUN as: System administrator), such as regedit, or anything that requires being ran as system admin.

The specific error I'm getting when I go to Computer, right click, properties, advanced system settings, I get the error:
Windows cannot find
'%C:\system32%\system32%\system32\systempropertiesadvanced.exe'

Open in new window

Make sure you typed the mane correctly and try again.

If I try to access regedit I get the error:
Windows cannot find
 'C:\Windows\regedit.exe'

Open in new window


I'm not sure what to do. If I could just get access to the set environment variables link in Advanced System Settings I could fix it the simple way.

Thanks in advanced for your help.
If I try to access regedit I get the error:
Windows cannot find

'C:\Windows\regedit.exe'

Can you please post a screenshot of this? Wondering if your .exe file association is hijacked.....
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for every ones help with this. I'm awarding the points to billprew since his solution was the only one I could get to do anything. It's possible that other solutions would have worked in a different situation, but I've messed the settings up beyond repair.

I eventually reformatted the hard drive and re-installed Windows 7. I believe I removed the Virus, but in doing so I deleted or changed settings, which created a situation that wasn't worth the trouble to fix.

Thanks for the assistance.
Thanks.

~bp