China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-06 02:00
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » {Closed} Use VBS password in BAT View 1,820 Replies 14
Original Poster Posted 2006-11-17 17:57 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
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 ]
Floor 2 Posted 2006-11-18 00:09 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
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.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 3 Posted 2006-11-19 16:45 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Is there really no other way?
Floor 4 Posted 2006-11-20 13:54 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
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.
Floor 5 Posted 2006-11-22 22:06 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
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``````
Floor 6 Posted 2006-11-23 07:26 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
[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.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 7 Posted 2006-11-23 12:59 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
Using the password input box of IE

@echo off
title Password

: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 .write "<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. Password: %pass%
echo.
echo Please wait...
goto loop
exit


You can replace "set /p pass=Please enter password:" with the above (modify appropriately)
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
chainliq +2 2006-11-23 21:38
Floor 8 Posted 2006-11-23 21:38 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
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 ]
Floor 9 Posted 2006-11-23 22:12 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
Hehe, alright, friend, thank you!~~!
Floor 10 Posted 2006-11-23 22:14 ·  中国 吉林 四平 联通
高级用户
★★★
Credits 859
Posts 413
Joined 2006-08-14 21:55
19-year member
UID 60532
Status Offline
Paying attention, has value for learning
Floor 11 Posted 2006-11-23 22:20 ·  中国 广西 贵港 电信
高级用户
★★
学无尽止
Credits 635
Posts 244
Joined 2006-04-15 05:07
20-year member
UID 53857
Gender Male
From 广西贵港
Status Offline
@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!
Floor 12 Posted 2006-11-23 22:56 ·  中国 广东 广州 天河区 电信
中级用户
★★
Credits 259
Posts 112
Joined 2006-09-18 04:55
19-year member
UID 62928
Gender Male
Status Offline
Hehe, finally figured it out!!
Floor 13 Posted 2007-02-18 20:35 ·  中国 广东 深圳 福田区 电信
初级用户
Credits 27
Posts 11
Joined 2006-03-16 07:21
20-year member
UID 52148
Status Offline
Hee hee
Floor 14 Posted 2007-02-19 05:32 ·  中国 黑龙江 牡丹江 电信
中级用户
★★
Credits 216
Posts 129
Joined 2007-02-14 07:26
19-year member
UID 79469
Gender Male
Status Offline
Floor 15 Posted 2007-10-10 14:12 ·  中国 山东 青岛 联通
初级用户
★★
Credits 146
Posts 86
Joined 2007-10-01 11:27
18-year member
UID 98691
Gender Male
Status Offline
Forum Jump: