views:

124

answers:

2

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.

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

+1  A: 

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

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.

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.

paxdiablo
yeah... it gives the same error. So now i know it's the VBS file.
YourComputerHelpZ
Cut and paste the three lines from your question into a brand new file and use that instead. That's what I did to test it.
paxdiablo
A: 

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...

YourComputerHelpZ
I'm pretty certain your VBS file had rubbish in it. If you still have it, you can load it up in gVIM and choose "Tools", "Convert to hex" or download the frhed hex editor and load it up. That's if you care. If you're just happy it's working feel free to ignore the ramblings of an old man that likes doing root cause analysis :-)You may have cut'n'pasted too much from the website the first time you did it.
paxdiablo