Solved

Set Windows 7 "WINDIR" Environment Variable using Command Line

Posted on 2011-09-08
11
1,399 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
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 9

Expert Comment

by:sshah254
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 66

Expert Comment

by:johnb6767
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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 51

Assisted Solution

by:Bill Prew
Bill Prew earned 500 total points
Comment Utility
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
Comment Utility
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 51

Expert Comment

by:Bill Prew
Comment Utility
Thanks.

~bp
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

One of the features I've come to appreciate about Windows 7 and Windows Server 2008 R2 is the ability to pin applications to the task bar. As useful a feature as I've found this, it does have some quirks.  For example, have you ever tried pinning an…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This Micro Tutorial will give you basic overview of the control panel section on Windows 7. It will depth in Network and Internet, Hardware and Sound, etc. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will go in depth within Systems and Security in Windows 7 and will go into detail regarding Action Center, Windows Firewall, System, etc. This will be demonstrated using Windows 7 operating system.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now