为什么这个密码不起作用 - 批处理

时间:2022-11-15 13:18:08

Hello i have this in a batch:

你好,我有一个批次:

:passw022
title batch :: Password
if exist util2.txt del util2.txt
cls
echo Please enter your name:
echo.
Set name=
set /p name=Name: 
echo %name%>> util.txt
echo.
echo Please enter a password you like to have:
echo.
Set passw=
<nul: set /p passw=Password: 
for /f "delims=" %%i in ('cscript /nologo mask.vbs') do set passwd=%%i
echo %passw%>> base.txt
goto login

Mask.vbs contains:

Set oScriptPW = CreateObject("ScriptPW.Password")
strPassword = oScriptPW.GetPassword()
Wscript.StdOut.WriteLine strPassword

it isn't working. At 'Please enter a password you like to have' it keeps giving an error. It might be possible because the .txt file is not there, but should be created and some text should be in there. But by 'name' it is working.

它不起作用。在'请输入您想要的密码'时,它会一直出错。这可能是因为.txt文件不在那里,但是应该创建,并且应该有一些文本。但是,通过“名称”它是有效的。

It gives the following error message: 'Mask.vbs: Compile mistake: invalid character'

它给出以下错误消息:'Mask.vbs:编译错误:无效字符'

2 个解决方案

#1


Recheck your mask.vbs file (including a hex dump if necessary). It's likely that you've inserted some strange character into it.

重新检查mask.vbs文件(如有必要,包括十六进制转储)。很可能你已经插入了一些奇怪的角色。

That code works fine for me. The only problem with it is that you store the output from the VBScript file into passwd and then echo passw to base.txt but that's not the source of your compilation error. Once that's fixed and the goto login is removed (no such label in the snippet given, I assume it's part of a bigger program), the script runs perfectly.

该代码对我来说很好。它唯一的问题是你将VBScript文件的输出存储到passwd然后将passw存储到base.txt,但这不是编译错误的来源。一旦修复并删除了goto登录(在给出的代码片段中没有这样的标签,我认为它是更大程序的一部分),脚本运行完美。

You might also want to try (from the command line):

您可能还想尝试(从命令行):

cscript /nologo mask.vbs

on its own to ensure it's the VBScript file at fault rather than the cmd file.

单独确保它是错误的VBScript文件而不是cmd文件。

#2


Got it to work now.

现在就开始工作了。

Still don't know exactly the problem, but on whatever reason, when i copy and paste the code in the VBS from the website i found this, it does again.

仍然不知道确切的问题,但无论出于何种原因,当我从网站上复制并粘贴代码时,我发现了这一点,它又一次。

I was not able to find any stupid thing.

我无法找到任何愚蠢的事情。

It's crazy but it works now.

这很疯狂,但它现在有效。

It might be a space or something like that...

它可能是一个空间或类似的东西......

#1


Recheck your mask.vbs file (including a hex dump if necessary). It's likely that you've inserted some strange character into it.

重新检查mask.vbs文件(如有必要,包括十六进制转储)。很可能你已经插入了一些奇怪的角色。

That code works fine for me. The only problem with it is that you store the output from the VBScript file into passwd and then echo passw to base.txt but that's not the source of your compilation error. Once that's fixed and the goto login is removed (no such label in the snippet given, I assume it's part of a bigger program), the script runs perfectly.

该代码对我来说很好。它唯一的问题是你将VBScript文件的输出存储到passwd然后将passw存储到base.txt,但这不是编译错误的来源。一旦修复并删除了goto登录(在给出的代码片段中没有这样的标签,我认为它是更大程序的一部分),脚本运行完美。

You might also want to try (from the command line):

您可能还想尝试(从命令行):

cscript /nologo mask.vbs

on its own to ensure it's the VBScript file at fault rather than the cmd file.

单独确保它是错误的VBScript文件而不是cmd文件。

#2


Got it to work now.

现在就开始工作了。

Still don't know exactly the problem, but on whatever reason, when i copy and paste the code in the VBS from the website i found this, it does again.

仍然不知道确切的问题,但无论出于何种原因,当我从网站上复制并粘贴代码时,我发现了这一点,它又一次。

I was not able to find any stupid thing.

我无法找到任何愚蠢的事情。

It's crazy but it works now.

这很疯狂,但它现在有效。

It might be a space or something like that...

它可能是一个空间或类似的东西......