HOME environment variable 解决方法

今天一位朋友,在Windows上安装好metasploit-framework后,当启动的时候却出现主要错误,如下:

HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)

中文翻译

必须设置HOME环境变量(或HOMEDRIVE和HOMEPATH)并指向目录(RuntimeError)

 

详细错误却如下:

Traceback (most recent call last):
        20: from G:/metasploit-framework/bin/../embedded/framework/msfconsole:49:in `<main>'
        19: from G:/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:in `start'
        18: from G:/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in `start'
        17: from G:/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:62:in `driver'
        16: from G:/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:62:in `new'
        15: from G:/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:74:in `initialize'
        14: from G:/metasploit-framework/embedded/framework/lib/msf/ui/console/driver.rb:598:in `choose_readline'
        13: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
        12: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
        11: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
        10: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/backports-3.14.0/lib/backports/std_lib.rb:9:in `require_with_backports'
         9: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/backports-3.14.0/lib/backports/std_lib.rb:9:in `require'
         8: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/rb-readline-0.5.5/lib/readline.rb:8:in `<top (required)>'
         7: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/rb-readline-0.5.5/lib/readline.rb:10:in `<module:Readline>'
         6: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `require'
         5: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
         4: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:274:in `block in require'
         3: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/backports-3.14.0/lib/backports/std_lib.rb:9:in `require_with_backports'
         2: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/backports-3.14.0/lib/backports/std_lib.rb:9:in `require'
         1: from G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:17:in `<top (required)>'
G:/metasploit-framework/embedded/lib/ruby/gems/2.5.0/gems/rb-readline-0.5.5/lib/rbreadline.rb:1097:in `<module:RbReadline>': HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)

HOME environment variable (or HOMEDRIVE and HOMEPATH) must be set and point to a directory (RuntimeError)

 

解决方法

我解决问题一贯的原则是:必须知道因果关系,有因才有果。

从报错可以清楚的得到这样一个原因:我们没有正确设置HOME环境变量(HOMEDRIVE和HOMEPATH)并指向目录。

 

既然这样,就好办多了。

Windows可以在cmd命令窗口用“set HOME”查看是否设置正确?正确的效果如下:

C:\Users\fujie>set HOME
HOMEDRIVE=C:
HOMEPATH=\Users\fujie

set HOME

 

1、我的这位朋友出错,是因为他的“HOMEPATH=\Users\余温”,后面是中文,我推测是这个原因引起来的,但是也说不准。

如何正确设置自己的HOME、HOEMDRIVE以及HOMEPATH呢?只需要在cmd命令窗口输入以下命令:

SETX HOMEDRIVE %SYSTEMDRIVE% -m
SETX HOMEPATH \Users\%username% -m
SET HOME=%SYSTEMDRIVE%\Users\%USERNAME%
SETX HOME "%HOME%"
SET TEMP=%HOME%\Local Settings\Temp
SETX TEMP "%TEMP%"
SETX TMP "%TEMP%"

 

2、如果你发现你在cmd窗口下用了“set home"命令,设置也是正确的话,那么,请查看你是否是以管理员身份登陆的?可以用命令“net user" 和 “net user 用户名“来具体看详情。

最后的结果是,我的这位朋友是以“WDAGUtilityAccount账户”登陆的,根本不是“Administrator管理员”身份。

net user

 

总结:虽然说用户名是中文我是推测的,但我的推测也不一定对,也可以忽略这条。因为windows总体来说对中文支持还是很友好的,也不区分大小写,不像Linux对吧!

最后我的这位朋友由“WDAGUtilityAccount账户”换成了“Administrator账户”就OK了。

    A+
发布日期:2019年05月20日 17:37:40  所属分类:经验
最后更新时间:2019-05-20 17:37:40
评分: (1 票;平均数5.00 ;最高评分 5 ;用户总数1;总得分 5;百分比100.00)
付杰
wp discux 帝国 dedecms phpcms等快速建站
wp discux 帝国 dedecms phpcms等快速建站
  • ¥ 99.9元
  • 市场价:499.9元
刷流量 刷人气 刷点击 刷收藏 刷APP关键词
刷流量 刷人气 刷点击 刷收藏 刷APP关键词
  • ¥ 1.0元
  • 市场价:9.9元
SEO顾问 中小型网站 单站最低99.9元 全方位优化
SEO顾问 中小型网站 单站最低99.9元 全方位优化
  • ¥ 99.9元
  • 市场价:5000元
服务器管理面板/主机控制面板“安装”服务
服务器管理面板/主机控制面板“安装”服务
  • ¥ 9.9元
  • 市场价:49.9元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: