oscar_nysushi Posted March 1, 2009 Share Posted March 1, 2009 I am sure this will be very easy for you clever scripting guys out there, here's a couple of questions.I have wrote this little script for some wireless laptops that we are not going to join our domain, but we'd like our students to access to thier home drives, and shared resources.===============================echo offnet use z: /deletenet use t: /deleteecho Please type your Year Group below and press enter (7,8,9,10 or 11)set /p Group=if "%Group%" == "7" set intake=2008if "%Group%" == "8" set intake=2007if "%Group%" == "9" set intake=2006if "%Group%" == "10" set intake=2005if "%Group%" == "11" set intake=2004echo Please Type your Username (example astudent120589) set /p usern=echo Now please Type your Passwordset /p password=net use Z: "\\Server\User Storage\Pupils\%intake%\%usern%" /User:mydomain\%usern% %password% /PERSISTENT:NOnet use T: "\\Server\student$" /User:mydomain\%usern% %password% /PERSISTENT:NO===============================1. It works but i'd prefer to hide the password as they type it? is it possible?2. Also is it possible to add a line that to set the path of MY documents to Z: drive, so applications trying to save will pick z: as it's default location.Any help or suggestions on how to improve this script would be great. Thank you.Steve, Chaucer BEC, Sheffield UK www.chaucer.sheffield.sch.uk Link to comment Share on other sites More sharing options...
jaclaz Posted March 1, 2009 Share Posted March 1, 2009 See here:http://www.msfn.org/board/index.php?showtopic=126348jaclaz Link to comment Share on other sites More sharing options...
Yzöwl Posted March 1, 2009 Share Posted March 1, 2009 echo offnet use z: /deletenet use t: /deleteecho Please type your Year Group below and press enter (7,8,9,10 or 11)set /p Group=if "%Group%" == "7" set intake=2008if "%Group%" == "8" set intake=2007if "%Group%" == "9" set intake=2006if "%Group%" == "10" set intake=2005if "%Group%" == "11" set intake=2004echo Please Type your Username (example astudent120589) set /p usern=echo Now please Type your Passwordset /p password=net use Z: "\\Server\User Storage\Pupils\%intake%\%usern%" /User:mydomain\%usern% %password% /PERSISTENT:NOnet use T: "\\Server\student$" /User:mydomain\%usern% %password% /PERSISTENT:NOFor now I think you should ignore the password visibility issue and look at your code structure. The first thing I notice is that you go straight into deleting two drive mappings, you have not checked to see if they exist already, or even if they are already mapped to the intended destinations. If they are already mapped to another location you may need to make a note of that location and re-map them to an alternative letter. Then you ask for user input, which I suggest should be your first task, but fail to check any of the input. If the user types 5 for their Year Group your code would continue needlessly with an invalid figure, the same could be said for Username, ideally it needs to be checked for validity.As far as the hiding of password entry is concerned, I'd suggest you use vbscript / html|hta solution, which could either be directly scripted or created and run directly from the batch file.As a final thought, due to possible limitations in your chosen scripting method, you may need to also to ensure that invalid / poison characters are not used, especially with the password input. Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 1, 2009 Share Posted March 1, 2009 Here a example of a HTA with a masked textbox <TITLE>Submit Password</TITLE> <HTA:APPLICATION ID='PWSubmit' Scroll='No' SCROLLFLAT ='No' SingleInstance='Yes' SysMenu='Yes' ShowInTaskBar='No' MaximizeButton='No' MinimizeButton='No' Border='Thin' BORDERSTYLE ='complex' INNERBORDER ='Yes' Caption='Yes' WindowState='Normal' APPLICATIONNAME='SubmitPW' Icon='%SystemRoot%\explorer.exe'> <STYLE Type="text/css"> Body { Font-Size:8.05pt; Font-Weight:Bold; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Color:#001254; BackGround-Color:Transparent; Filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#fdf7f1',endColorStr='#d1cbc5'); Margin-Top:1; Margin-Bottom:1; Margin-Left:4; Margin-Right:4; Padding-Top:3; Padding-Bottom:3; Padding-Left:4; Padding-Right:4; Text-Align:Center; Vertical-Align:Top; Border-Top:2px Solid #a6a29e; Border-Bottom:3px Solid #cbc7c3; Border-Left:2px Solid #b2aeaa; Border-Right:3px Solid #bcb8b4; } BUTTON { Width:51PT; Height:15PT; Cursor:Hand; Font-Size:7.95pt; Font-Weight:Bold; filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#FEFDFC',endColorStr='#D7D9D7'); Margin-Top:1; Margin-Bottom:1; Margin-Left:3; Margin-Right:3; Padding-Top:1; Padding-Bottom:1; Border-left: 1px Ridge; Border-right: 1px Groove #bcb8b4; Border-top: 1px Ridge; Border-Bottom: 1px Groove #bcb8b4; } .TxBox { Height:15PT; Font-Size:7.95pt; Font-Weight:Bold; Font-Family:Arial,Tahoma,Comic Sans MS,Segoe Ui; Color:#1e1e1e; filter:progid:DXImageTransform.Microsoft.Gradient (StartColorStr='#FEFDFC',endColorStr='#D7D9D7'); Margin-Top:1; Margin-Bottom:1; Margin-Left:3; Margin-Right:3; Padding-Top:1; Padding-Bottom:1; Border-left: 1px Ridge; Border-right: 1px Groove #bcb8b4; Border-top: 1px Ridge; Border-Bottom: 1px Groove #bcb8b4; } </STYLE> <script language="VBScript">'-> Resize Window Dim Wth :Wth = int(349) Dim Hht :Hht = int(125) window.ResizeTo Wth, Hht MoveTo ((Screen.Width / 2) - (Wth / 2)),((Screen.Height / 2) - (Hht / 2))'-> Btn01 Function Function PwAction() If TB1.value = "" Then alert("Error No Password") Else alert(TB1.value) End If End Function'-> Btn02 Function Function CloseAction() window.close() End Function </SCRIPT><BODY Scroll='No'> <!-- Text --> <DIV Style='Margin-Top:3pt;Margin-Bottom:5pt;'>Type in your password, then press the Submit Button.</DIV> <!-- Password Textbox --> <TABLE> <INPUT Type='Password' Class='TxBox' Name='TB1' SIZE=18 MAXLENGTH=18> </TABLE> <!-- Buttons --> <TABLE> <BUTTON ID='Btn01' OnClick='PwAction()'>Submit</BUTTON> <BUTTON ID='Btn02' OnClick='CloseAction()'>Close</BUTTON> </TABLE> Link to comment Share on other sites More sharing options...
Yzöwl Posted March 1, 2009 Share Posted March 1, 2009 and here's a batch file which writes a vbs and uses a html for obtaining the data.@Echo off>%TEMP%\_$.vbs (Echo/wsh.echo "You entered: ", _ Echo/ join^(passwordbox^("Enter UID and password", "Testing"^), ", "^) Echo/ Echo/' A function to present a Password dialog in a VBS ^(WSF^) script Echo/' Requires WScript version 5.1^+ Echo/' Tom Lavedas ^<tlave...@hotmail.com^> Echo/Function PasswordBox^(sPrompt, sDefault^) Echo/ set oIE = CreateObject^("InternetExplorer.Application"^) Echo/ With oIE Echo/ .ToolBar = False Echo/ .RegisterAsDropTarget = False : .Navigate^("about:blank"^) Echo/ While .Busy : WScript.Sleep 100 : Wend Echo/ With .document Echo/ With .ParentWindow Echo/ if Instr^(.navigator.appVersion, "MSIE 6"^) = 0 Then Echo/ oIE.FullScreen = True Echo/ .resizeto 400,180 Echo/ .moveto .screen.width/2-200, .screen.height/2-90 Echo/ else Echo/ .resizeto 400,230 Echo/ .moveto .screen.width/2-200, .screen.height/2-115 Echo/ End if Echo/ End With Echo/ .Write^("<html><head><" ^& "script>bboxwait=true;</" ^& "script>" _ Echo/ ^& "<title>Password _____________________________ </title>" _ Echo/ ^& "</head><body bgColor=Silver scroll=no language=vbs" _ Echo/ ^& " onkeypress=""if window.event.keycode=13 Then" _ Echo/ ^& " bboxwait=false""><center><b> " ^& sPrompt ^& "<b> <p>" _ Echo/ ^& "<table><tr><td> <b>User:</b></td><td>" _ Echo/ ^& "<input type=text id=user value='" ^& sDefault ^& "'>" _ Echo/ ^& "</td><tr><td> <b>Password:</b></td><td>" _ Echo/ ^& "<input type=password id=pass></td></tr></table><br>" _ Echo/ ^& "<button onclick=""bboxwait=false;""> Submit </button>" _ Echo/ ^& "</center></body></html>"^) Echo/ .ParentWindow.document.body.style.borderStyle = "outset" Echo/ .ParentWindow.document.body.style.borderWidth = "3px" Echo/ .all.user.focus Echo/ On Error Resume Next Echo/ Do While .parentWindow.bBoxWait Echo/ oIE.Visible = True Echo/ if Err Then Exit Do Echo/ WScript.Sleep 100 Echo/ Loop Echo/ oIE.Visible = False Echo/ if Err Then Echo/ PasswordBox = Array^("CANCELLED"^) Echo/ Else Echo/ PasswordBox = Split^(.all.user.value ^& "|" _ Echo/ ^& .all.pass.value, "|"^) Echo/ End if Echo/ On Error Goto 0 Echo/ End With ' document Echo/ End With ' IE Echo/End Function)Cscript //NoLogo %TEMP%\_$.vbsDel %TEMP%\_$.vbsPause Link to comment Share on other sites More sharing options...
oscar_nysushi Posted March 3, 2009 Author Share Posted March 3, 2009 gunsmokingman.Thank for your reply, I can't see how a web page can control drive mapping?Yzowl.Thank for your reply, but i just need to hide the password, so it's looks like I need to go down the VBS route.I am not that bother about error checking the batch file, if they type something wrong, the script fails and they don't get connected.I have tried the code in a batch file, but I got this error.Any further suggestions?Thank you for your help.SteveE:\>{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\froman\fcharset0 Times New Roman;}{\f1\fswiss\fcharset0 Arial;}}The system cannot find the path specified.E:\>{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\sb100\sa100\f0\fs24 @Echo off\line (Echo/wsh.echo "You entered: ", _\line Echo/ join(passwordbox("Enter UID and password", "Testing"), ", ")\line Echo/\line Echo/' A function topresent a Password dialog in a VBS (WSF) script\line Echo/' Requires WScript version 5.1+\line Echo/' Tom Lavedas <tlave...@hotmail.com>\line Echo/Function PasswordBox(sPrompt, sDefault)\line Echo/ set oIE = CreateObject("InternetExplorer.Application")\line Echo/ With oIE\line Echo/ .ToolBar = False\line Echo/ .RegisterAsDropTarget = False : .Navigate("about:blank")\line Echo/ While .Busy : WScript.Sleep 100 : Wend\line Echo/ With .document\line Echo/ With .ParentWindow\lineEcho/ if Instr(.navigator.appVersion, "MSIE 6") = 0 Then\line Echo/ oIE.FullScreen = True\line Echo/ .resizeto 400,180\line Echo/ .moveto .screen.width/2-200, .screen.height/2-90\line Echo/ else\line Echo/ .resizeto 400,230\line Echo/ .moveto .screen.width/2-200, .screen.height/2-115\line Echo/ End if\line Echo/ End With\line Echo/ .Write("<html><head><" & "script>bboxwait=true;</" & "script>" _\line Echo/ & "<title>Password _____________________________ </title>" _\line Echo/ & "</head><body bgColor=Silver scroll=no language=vbs" _\line Echo/ & " onkeypress=""if window.event.keycode=13 Then" _\line Echo/ & " bboxwait=false""><center><b> " & sPrompt & "<b> <p>" _\line Echo/ & "<table><tr><td> <b>User:</b></td><td>" _\line Echo/ & "<input type=text id=user value='" & sDefault & "'>" _\lineEcho/ & "</td><tr><td> <b>Password:</b></td><td>" _\line Echo/ & "<input type=password id=pass></td></tr></table><br>" _\line Echo/ & "<button onclick=""bboxwait=false;""> Submit </button>" _\line Echo/ & "</center></body></html>")\line Echo/ .ParentWindow.document.body.style.borderStyle = "outset"\line Echo/ .ParentWindow.document.body.style.borderWidth = "3px"\line Echo/ .all.user.focus\line Echo/ On Error Resume Next\line Echo/ Do While .parentWindow.bBoxWait\line Echo/ oIE.Visible = True\line Echo/ if Err Then Exit Do\line Echo/ WScript.Sleep 100\line Echo/ Loop\line Echo/ oIE.Visible = False\line Echo/ if Err Then\line Echo/ PasswordBox = Array("CANCELLED")\line Echo/ Else\line Echo/ PasswordBox = Split(.all.user.value & "|" _\line Echo/ & .all.pass.value, "|")\line Echo/ End if\lineEcho/ On Error Goto 0\line Echo/ End With ' document\line Echo/ End With ' IE\line Echo/End Function)\line Cscript //NoLogo c:\Windows\Temp\\_$.vbs\line Del c:\Windows\Temp\\_$.vbs\line Pause\par 1>c:\Windows\Temp\\_$.vbsThe system cannot find the path specified.E:\>\pard\f1\fs20\parThe system cannot find the path specified.E:\>}'}' is not recognized as an internal or external command,operable program or batch file. Link to comment Share on other sites More sharing options...
jaclaz Posted March 3, 2009 Share Posted March 3, 2009 Any further suggestions?READ the thread I gave a link to AND links in there:http://www.msfn.org/board/index.php?showtopic=126348jaclaz Link to comment Share on other sites More sharing options...
IcemanND Posted March 3, 2009 Share Posted March 3, 2009 Why not just let the Net Use command collect the password? Granted it is not the prettiest, but it doesn't echo anything to the screen.net use n: \\myserver\mystorage /user:domain\userThen it asks for the password for the specified user to connect with. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now