Link to home
Start Free TrialLog in
Avatar of xchar
xchar

asked on

How to set environmental variable %windir% (Win 7)

How can I set environmental (system?) variable %windir% to be C:\Windows, globally and permanently?  (Windows 7 64b)

My PC is having multiple problems, which I suspect are all due to windir somehow getting unset.  If I type  set windir  in a cmd-line window, it says:
Environment variable windir not defined.

If I go to Computer>Properties>Advanced system settings it says:
Windows cannot find %windir%\System32\systempropertiesadvanced.exe.
I get a similar "cannot find" if I try to use System Restore.

If I try to install anything, or try to Run regedit, msconfig, taskmgr, etc:
The system could not find the environment option that was entered.

I can  set windir=C:\Windows  in a cmd-line window, but it is in effect only within that window, and is gone on reboot.

Thanks for any suggestions...bearing in mind that I cannot use regedit, System Restore, or systempropertiesadvanced.exe.

--Charles
SOLUTION
Avatar of ashraf882
ashraf882
Flag of Bangladesh image

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
Avatar of xchar
xchar

ASKER

@ashraf882--
If you mean Advanced system settings in Control Panel, that just gives me:
Windows cannot find %windir%\System32\systempropertiesadvanced.exe.
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
Go to C:\Windows\System32 and click systempropertiesadvanced.exe.
Avatar of xchar

ASKER

@Dustin Loftis--
Running C:\Windows\System32\sysdm.cpl gives this, twice:
C:\Windows\System32\SystemPropertiesComputerName.exe.
The system could not find the environment option that was entered.

@ashraf882--
Clicking on C:\Windows\System32\systempropertiesadvanced.exe gives:
C:\Windows\System32\SystemPropertiesAdvanced.exe.
The system could not find the environment option that was entered.
You may need to set that variable in that CMD prompt.  Then you should be able to run those commands, at least from within that prompt.
Avatar of xchar

ASKER

@Dustin Loftis:
If by "that variable" you mean %windir%, no soap.  I set windir to C:\Windows, and it shows up as C:\Windows via echo or set or cd, but running sysdm.cpl still gives the same result as above. :-(
Same for SystemPropertiesAdvanced.exe.
Is your %systemroot% variable set properly?

Is your Path variable set?
Avatar of xchar

ASKER

@Dustin Loftis:
SystemRoot=C:\Windows
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\;C:\c;C:\U0.D;C:\U1.D;C:\U2.D;C:\U3.D;c:\SE3;c:\se4
(All those strange items at the end of the Path are ones I put there long ago, but I don't remember how and I don't know where they're stored.)
If you use Windows+R (Run), then type %windir% and enter, does it bring up your windows directory?  If so, this is no the issue!  
Avatar of xchar

ASKER

@JonLambert--
Windows+R %windir% gives:
Windows cannot find '%windir%'. Make sure you typed the name correctly, then try again.
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
Avatar of xchar

ASKER

@JonLambert--
Nope, see 3rd paragraph of original question.  I can't get to the Env Vbls button.
try running c:\Windows\Syswow64\SystemPropertiesAdvanced.exe

lol.  He can't do that, either.

Try running %systemroot%, xchar.
Avatar of xchar

ASKER

No go with System64 or %systemroot%.

Unlike %windir%, %systemroot% does show up as C:\Windows.  
So does that suggest that %windir% is not the (only) problem?
 When I get the error message
"The system could not find the environment option that was entered."
maybe it's something unknown that's missing.
I saying to run the 32 bit verion in SYSWOW (i.e. not System32) .. he hasn't tried that as far as the thread goes.

Anyhow, how about setting windir in the registry in the following key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
Avatar of xchar

ASKER

@JonLambert--

I cd'd into C:\WIndows\SysWOW64 and then typed systempropertiesadvanced.exe. Did you have something else in mind?

The only way I know to modify the Registry is with regedit--which doesn't work for me now. Is there another way?
yep ... use REG.EXE .. the following should do the trick

Reg ADD HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment /v WINDIR /t REG_EXPAND_SZ /d C:\Windows
Avatar of xchar

ASKER

@JonLambert--

Thanks, that's just what I needed to know.  Should prove useful in the future.

BUT...when I copied and pasted your Reg ADD line into a cmd line, it said:
 ERROR: Invalid syntax. Type "REG ADD /?" for usage.

The example given by REG ADD /? seems to match the syntax of yours, so I'm perplexed.
Sorry I didn't try it, put quotes around the reg path i.e. Reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v WINDIR /t REG_EXPAND_SZ /d C:\Windows
Avatar of xchar

ASKER

Jon--
THanks for keeping after this.  With quotes added, I get:
ERROR: Axxwaa is denied..
Avatar of xchar

ASKER

[typos corrected]
Jon--
THanks for keeping after this.  With quotes added, I get:
ERROR: Access is denied..
I'd run a repair on Windows.
Try running it from an elevated command prompt (i.e. Type CMD in the Windows search bar, right click, run as administrator .. not saying you don't know already .. just avoiding another post just in case !)
Avatar of xchar

ASKER

@JonLambert--

I'm grateful to you for spelling out the steps--and I'm sure that others who are, like me, nonexperts will be too when they stumble onto this discussion.  Saves me a LOT of googling for further info.  I would never have guessed how to get an elevated command prompt.  I'm learning a lot more than I expected to when I posed a question that I thought would be real simple to answer.

Nevertheless, clicking on CMD, then on "Run as administrator" gives me the same fail:
C:\Windows\System32\cmd.exe.
The system could not find the environment option that was entered.

Heck, the system must know which option it can't find--why doesn't it just tell me which one?
Avatar of xchar

ASKER

@Dustin_Loftis--

You said: "I'd run a repair on Windows."  Did you mean Startup Repair, which I got to via f8 during bootup?
It found nothing to fix.  (While I was on the System Recovery page, I also tried Windows
Memory Diagnosis--nothing found.  And I tried System Restore several times, using
recent and older dates--in all cases, it "Did not complete successfully. Files & settings
not changed.")

Or did you mean to use more daunting procedures, such as described here?:
http://www.sevenforums.com/tutorials/3413-repair-install.html
I've done a bit of googling on your issue and it looks like a lot of people have had this problem, and it suspected that malware has caused the issue.  The only resolution anyone has is to do a complete rebuild of the computer.  Sorry it's not good news!
Avatar of xchar

ASKER

@JonLambert--

Well, that's depressing. :-(  But thanks for the summary.  What search terms did you use?  Can you give me an URL or 2 that discuss the problem?

Does "a complete rebuild of the computer" mean reformatting the hard disk and then reinstalling Windows 7?  Or is there more to it?  Or less?

I'll wait a day or so to see if anyone shows up here with a less drastic suggestion.  Then I'll distribute points to everyone who has tried to help. Even though my problem was not solved simply, I've learned a lot.  Thanks!
Do a google search on "The system could not find the environment option that was entered", you will find many people in your situation. ... None I coudl find with a resolution.
ASKER CERTIFIED 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
Glad to hear you didn't need to go down the rebuild path!
I'm also having this issue , exactly as @xchar, Unfortunately , I can't boot into safemode, My PC gets stuck at CALSSPNP.SYS  Please help
Avatar of xchar

ASKER

@jeremiah Ajiboye--

As I said back in 2010, I don't really know how I cured my pc. You say you can't boot into safemode.  Can you boot into Windows normally? If yes, I'd suggest trying the msconfig route that I used.

First run msfconfig, by typing it into either the Run box or at a Cmd prompt.  Then:

"I typed  msconfig .  A tabbed menu popped up and I clicked the Tools tab. I found System Properties in the long list and Launched it.  Then: Advanced system settings > Advanced > Environmental Variables (at the bottom) > System variables > New > windir C:\Windows.  Ditto for User variables."

[Note: There was a typo in my posted comments--should be C:\Windows, not C; .]

   --Charles