Solved

Set Windows 7 "WINDIR" Environment Variable using Command Line

Posted on 2011-09-08
11
1,525 Views
Last Modified: 2013-11-25
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
0
Comment
Question by:jeremyjared74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 9

Expert Comment

by:sshah254
ID: 36508122
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
0
 
LVL 23

Author Comment

by:jeremyjared74
ID: 36508164
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.
0
 
LVL 5

Expert Comment

by:Feebleminder
ID: 36508250
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
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 66

Expert Comment

by:johnb6767
ID: 36508261
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..
0
 
LVL 5

Expert Comment

by:Feebleminder
ID: 36508268
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?/?
0
 
LVL 55

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 36510008
Keep in mind that you also have the SETX command that allows you to set system and user level environment variables from the command line.

So you could do something like this from a command line to get back to where you need to be:

C:\Windows\System32\setx.exe PATH "C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"

Open in new window

Adust the paths as needed.

~bp
0
 
LVL 23

Author Comment

by:jeremyjared74
ID: 36510332
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.
0
 
LVL 66

Expert Comment

by:johnb6767
ID: 36510440
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.....
0
 
LVL 55

Assisted Solution

by:Bill Prew
Bill Prew earned 500 total points
ID: 36510551
You may have a messed up USER path as well.  You could try running the program you are trying to get to from Start, Accessories, Run and entering in:

C:\Windows\System32\SystemPropertiesAdvanced.exe

~bp
0
 
LVL 23

Author Closing Comment

by:jeremyjared74
ID: 36524503
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.
0
 
LVL 55

Expert Comment

by:Bill Prew
ID: 36524951
Thanks.

~bp
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
A quick guide on how to use Group Policy to create a custom power plan and set it active on Windows 7.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question