这是我们必须使用的代码来构建这个批处理文件,它将连接到我们将用于MongoDB的服务器。*是我的用户名帐户,不想与任何人分享。
sc.exe create MongoDB binPath =
"C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\bin\mongod.exe
--service --config=\"C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\mongodb.cfg\""
DisplayName= "MongoDB" start= "auto"老师不肯帮助我们,他也不知道问题出在哪里。我开始通过谷歌搜索,但我能找到的唯一事情是,我需要改变环境变量,它被设置为所有。
错误是:
'sc.exe' is not recognized as an internal or external command, operable program or batch file.我怎么能让这件事
发布于 2015-09-09 16:35:10
尝试where sc.exe搜索它在哪里。然后使用该命令的完整路径。
sc.exe create MongoDB binPath = "C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\bin\mongod.exe
--service --config=\"C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\mongodb.cfg\""
DisplayName= "MongoDB" start= "auto"您必须处理双引号/单引号("和')。不确定您是否可以使用\ in路径执行此操作,因为在您的示例中,它可以被解释为文件夹。试试插入符号(^)或双引号中的单引号
在您的示例中,正确的语法应该是:
C:\Windows\System32\sc.exe create MongoDB ^
binPath="'C:\*****\mongod.exe' --service --config=^
'C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\mongodb.cfg'" ^
DisplayName="MongoDB" start="auto"注:在这里插入(^)是为了逃避车厢返回。
或者是一行:
C:\Windows\System32\sc.exe create MongoDB binPath="'C:\*****\mongod.exe' --service --config='C:\Users\****\Desktop\FanshaweCollege\semester3\Servers\mongodb.cfg'" DisplayName="MongoDB" start="auto"发布于 2015-09-09 12:59:05
您需要将sc.exe的位置添加到环境变量"Path“中。
https://stackoverflow.com/questions/32479935
复制相似问题