[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1813
  • Last Modified:

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
0
jeremyjared74
Asked:
jeremyjared74
  • 3
  • 3
  • 2
  • +2
2 Solutions
 
sshah254Commented:
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
 
jeremyjared74Author Commented:
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
 
FeebleminderCommented:
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
johnb6767Commented:
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
 
FeebleminderCommented:
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
 
Bill PrewCommented:
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
 
jeremyjared74Author Commented:
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
 
johnb6767Commented:
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
 
Bill PrewCommented:
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
 
jeremyjared74Author Commented:
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
 
Bill PrewCommented:
Thanks.

~bp
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now