Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Set Windows 7 "WINDIR" Environment Variable using Command Line

Posted on 2011-09-08
11
Medium Priority
?
1,742 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 58

Accepted Solution

by:
Bill Prew earned 2000 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 58

Assisted Solution

by:Bill Prew
Bill Prew earned 2000 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 58

Expert Comment

by:Bill Prew
ID: 36524951
Thanks.

~bp
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 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