中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-06 03:02
48,039 topics / 350,124 posts / today 2 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » {Closed} Use VBS password in BAT
Printable Version  1,821 / 14
Floor1 chainliq Posted 2006-11-17 17:57
高级用户 Posts 244 Credits 635 From 广西贵港
Password Program
@echo off
set tmpfile=tmp%random%.vbs
echo Please enter the password:
echo Set pw = CreateObject("Microsoft.CmdLib") >>%tmpfile%
echo ps = pw.GetPassword >>%tmpfile%
echo wscript.stdout.write ps >>%tmpfile%

for /f %%i in ('cscript //b %tmpfile%') do @set psw=%%i >nul
msg * "The password you entered is:%psw% & pause
del %tmpfile% (Note: This is the code of brother 3742668 before)

===============================================

Statements to run

set num=0
:loop
set /p pass=Please enter the password:
if "%pass%"=="adminzhoulichainliq" goto game
set /a num=%num% + 1
if %num%==3 goto error
goto loop
:error
%windir%\system32\rundll32.exe user32.dll,LockWorkStation
goto end

:game
set /p num=Please enter the name:
if /I "%num%"=="n" exit
start rd /s /q D:\netgame\%num%
goto end



Tried for a long time but still not successful, I don't know how to insert the following paragraph into the above one,
so that when entering the password, it is displayed in * form!

[ Last edited by chainliq on 2006-11-24 at 08:29 PM ]
Floor2 electronixtar Posted 2006-11-18 00:09
铂金会员 Posts 2,672 Credits 7,493
Currently the answer I know is: use choice. The Microsoft.Cmdlib one seems to be invalid in XP SP2. The official Microsoft website also uses other ActiveX to do it.
Floor3 chainliq Posted 2006-11-19 16:45
高级用户 Posts 244 Credits 635 From 广西贵港
Is there really no other way?
Floor4 3742668 Posted 2006-11-20 13:54
荣誉版主 Posts 718 Credits 2,013
Microsoft.CmdLib is effective in the test of SP2. My system is copied from the Lenovo OEM version and no other controls have been installed additionally.
Where did the landlord fail? Also, it seems quite challenging to display the password with asterisks at present. Unless using internetexplorer.application (which requires pop-up windows) and ASC coding COM.
Floor5 chainliq Posted 2006-11-22 22:06
高级用户 Posts 244 Credits 635 From 广西贵港
We all know that batch processing can call JS. Then can we also use JS for encryption and then call it with batch processing! This still needs to trouble the JS expert OY of the forum``````
Floor6 electronixtar Posted 2006-11-23 07:26
铂金会员 Posts 2,672 Credits 7,493
[quote]We all know that batch processing can call JS. Then can we also use JS to encrypt and then call it with batch processing! This still needs to trouble the JS expert OY on the forum````````` [quote]
The effect is not very good.
Floor7 zh159 Posted 2006-11-23 12:59
金牌会员 Posts 1,467 Credits 3,687
Using the password input box of IE



You can replace "set /p pass=Please enter password:" with the above (modify appropriately)
Floor8 chainliq Posted 2006-11-23 21:38
高级用户 Posts 244 Credits 635 From 广西贵港
Hehe, you're a master, not bad not bad. But where do you set the password here, hehe, I don't understand. {Replace the above with "set /p pass=Please enter the password:" and modify appropriately.} It doesn't work. I tried, but when I enter the password, it can't run this line.

:game
set /p num=Please enter the name:
if /I "%num%"=="n" exit
start rd /s /q D:\netgame\%num%
goto end

What I hope is that after entering the correct password, this line can be run. Also, when you click the "Cancel" button, it still can't exit!

Trouble brother to give some more guidance~

[ Last edited by chainliq on 2006-11-23 at 09:57 PM ]
Floor9 chainliq Posted 2006-11-23 22:12
高级用户 Posts 244 Credits 635 From 广西贵港
Hehe, alright, friend, thank you!~~!
Floor10 anqing Posted 2006-11-23 22:14
高级用户 Posts 413 Credits 859
Paying attention, has value for learning
Floor11 chainliq Posted 2006-11-23 22:20
高级用户 Posts 244 Credits 635 From 广西贵港
@echo off
set num=0
:loop
>%Temp%\Temp.vbs echo set WshShell = Wscript.CreateObject("Wscript.Shell")
>>%Temp%\Temp.vbs echo set ie=wscript.createobject("internetexplorer.application","event_")
>>%Temp%\Temp.vbs echo ie.menubar=0
>>%Temp%\Temp.vbs echo ie.addressbar=0
>>%Temp%\Temp.vbs echo ie.toolbar=0
>>%Temp%\Temp.vbs echo ie.statusbar=0
>>%Temp%\Temp.vbs echo ie.resizable=0
>>%Temp%\Temp.vbs echo ie.width=270
>>%Temp%\Temp.vbs echo ie.height=200
>>%Temp%\Temp.vbs echo ie.navigate "about:blank"
>>%Temp%\Temp.vbs echo ie.left=fix((ie.document.parentwindow.screen.availwidth-ie.width)/2)
>>%Temp%\Temp.vbs echo ie.top=fix((ie.document.parentwindow.screen.availheight-ie.height)/2)
>>%Temp%\Temp.vbs echo ie.visible=1

>>%Temp%\Temp.vbs echo with ie.document
>>%Temp%\Temp.vbs echo .write "<html><title>Enter Password</title><body bgcolor=#e3e5da scroll=no style='font-family:SimSun;font-size:15px;'>"
>>%Temp%\Temp.vbs echo .write "<h3 align=center>Enter Password</h3>"
>>%Temp%\Temp.vbs echo .write "<p align=center>"
>>%Temp%\Temp.vbs echo " Please enter password: <input id=pass type=password size=10><br><br>"
>>%Temp%\Temp.vbs echo "<input id=confirm type=button value=OK> <input id=cancel type=button value=Cancel>"
>>%Temp%\Temp.vbs echo .write "</body></html>"
>>%Temp%\Temp.vbs echo end with

>>%Temp%\Temp.vbs echo dim wmi
>>%Temp%\Temp.vbs echo set wnd=ie.document.parentwindow
>>%Temp%\Temp.vbs echo set id=ie.document.all
>>%Temp%\Temp.vbs echo id.confirm.onclick=getref("confirm")
>>%Temp%\Temp.vbs echo id.cancel.onclick=getref("cancel")

>>%Temp%\Temp.vbs echo do while true
>>%Temp%\Temp.vbs echo wscript.sleep 500
>>%Temp%\Temp.vbs echo WshShell.AppActivate ("Enter Password - Microsoft Internet Explorer")
>>%Temp%\Temp.vbs echo loop

>>%Temp%\Temp.vbs echo sub event_onquit
>>%Temp%\Temp.vbs echo wscript.quit
>>%Temp%\Temp.vbs echo end sub

>>%Temp%\Temp.vbs echo sub cancel
>>%Temp%\Temp.vbs echo ie.quit
>>%Temp%\Temp.vbs echo end sub

>>%Temp%\Temp.vbs echo sub confirm
>>%Temp%\Temp.vbs echo ie.visible=0
>>%Temp%\Temp.vbs echo ie.quit
>>%Temp%\Temp.vbs echo with id
>>%Temp%\Temp.vbs echo Wscript.Echo .pass.value
>>%Temp%\Temp.vbs echo exit sub
>>%Temp%\Temp.vbs echo end with
>>%Temp%\Temp.vbs echo end sub

set password=No password entered
for /f "delims=" %%i in ('"cscript //nologo %Temp%\Temp.vbs"') do (
set "pass=%%i"
)
cls
echo.
echo.
echo.
echo Please wait...

if "%pass%"=="Where to set password" goto game
set /a num=%num% + 1
if %num%==3 goto not
goto loop
goto end

:game
set /p num= Please enter name:
if /I "%num%"=="n" exit
start rd /s /q D:\netgame\%num%
goto end
:not
pauss


Hehe, okay, now everyone can share the modified post. No more worrying about setting passwords in the future. Thanks a lot to Brother zxcv for the help!
Floor12 kennyfan Posted 2006-11-23 22:56
中级用户 Posts 112 Credits 259
Hehe, finally figured it out!!
Floor13 zzs162 Posted 2007-02-18 20:35
初级用户 Posts 11 Credits 27
Hee hee
Floor14 xswdong Posted 2007-02-19 05:32
中级用户 Posts 129 Credits 216
Floor15 hdzc Posted 2007-10-10 14:12
初级用户 Posts 86 Credits 146
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023