kevan79 Posted March 23, 2005 Share Posted March 23, 2005 Ok, basically I'm looking for a script that pops up a message box with yes/no boxes, if they click no, the user is logged off before they can actually get 'into' the OS. If yes, then it proceds and logs them onto the network. I know how to get the message box, but not sure how to code the yes/no and log off portion.Thanks,Kevan Link to comment Share on other sites More sharing options...
IcemanND Posted March 23, 2005 Share Posted March 23, 2005 Set WshShell = WScript.CreateObject("Wscript.Shell")intReturn = MsgBox ("If you agree click ok to continue", vbOKCancel + vbExclamation, "Alert")if intReturn = 2 then WshShell.Run "shutdown -l" ,,Trueif intReturn = 1 then wscript.quit Link to comment Share on other sites More sharing options...
kevan79 Posted March 25, 2005 Author Share Posted March 25, 2005 Thanks alot, that works nicely...changed the Okcancel to Yesno and it is great...one question though...My text is too long to fit on one line, actually takes several...how do I wrap this so I don't get errors?Use & _ and then restart " and close with " again? Haven't had time to test it...just curious.Thanks again. Link to comment Share on other sites More sharing options...
IcemanND Posted March 25, 2005 Share Posted March 25, 2005 MsgBox ("If" & VBCRLF & "you" & VBCRLF & "agree" & VBCRLF & _ "click" & VBCRLF & "ok" & VBCRLF & "to" & _ VBCRLF & "continue", vbOKCancel + vbExclamation, "Alert") Link to comment Share on other sites More sharing options...
kevan79 Posted March 27, 2005 Author Share Posted March 27, 2005 Ok...this is going to sound crazy...but...I've got the code working...thank you alot for that...but is there a limit as too how many characters you can put into a message box? Reason being, it's cutting off my message right int he middle of a word. It works, but I just need more space...any tips/ideas?Thanks. Link to comment Share on other sites More sharing options...
IcemanND Posted March 28, 2005 Share Posted March 28, 2005 post your code and let us take a look at it. Link to comment Share on other sites More sharing options...
kevan79 Posted March 28, 2005 Author Share Posted March 28, 2005 Here it is Set WshShell = WScript.CreateObject("Wscript.Shell")intReturn = MsgBox ("THIS IS A DEPARTMENT OF DEFENSE COMPUTER SYSTEM. THIS COMPUTER SYSTEM, INCLUDING ALL RELATED EQUIPMENT,NETWORKS AND" & VBCRLF & _"NETWORK DEVICES (SPECIFICALLY INCLUDING INTERNET ACCESS), ARE PROVIDED ONLY FOR AUTHORIZED U.S. GOVERNMENT USE." & VBCRLF & _"DOD COMPUTER SYSTEMS MAY BE MONITORED FOR ALL LAWFUL PURPOSES, INCLUDING TO ENSURE THAT THEIR USE IS AUTHORIZED, FOR" & VBCRLF & _"MANAGEMENT OF THE SYSTEM, TO FACILITATE PROTECTION AGAINST UNAUTHORIZED ACCESS, AND TO VERIFY SECURITY PROCEDURES," & VBCRLF & _"SURVIVABILITY AND OPERATIONAL SECURITY. MONITORING INCLUDES ACTIVE ATTACKS BY AUTHORIZED DOD ENTITIES TO TEST OR" & VBCRLF & _"VERIFY THE SECURITY OF THIS SYSTEM. DURING MONITORING, INFORMATION MAY BE EXAMINED, RECORDED, COPIED AND USED FOR" & VBCRLF & _"AUTHORIZED PURPOSES. ALL INFORMATION, INCLUDING PERSONAL INFORMATION, PLACED ON OR SENT OVER THIS SYSTEM MAY BE" & VBCRLF & _"MONITORED. USE OF THIS DOD COMPUTER SYSTEM, AUTHORIZED OR UNAUTHORIZED, CONSTITUTES CONSENT TO MONITORING OF THIS" & VBCRLF & _"SYSTEM. UNAUTHORIZED USE MAY SUBJECT YOU TO CRIMINAL PROSECUTION. EVIDENCE OF UNAUTHORIZED USE COLLECTED DURING" & VBCRLF & _"MONITORING MAY BE USED FOR ADMINISTRATIVE, CRIMINAL OR OTHER ADVERSE ACTION. USE OF THIS SYSTEM CONSTITUTES CONSENT TO" & VBCRLF & _"MONITORING FOR THESE PURPOSES.", vbYesNo + vbExclamation, "DOD Consent to Monitoring")if intReturn = 2 then WshShell.Run "shutdown -l" ,,Trueif intReturn = 1 then wscript.quitIt didn't post as nice in here...sorry about that...but as it stands right now, the message box cuts off the test towards the end at 'col' in the word collected.Thanks for helping out with this.Kevan Link to comment Share on other sites More sharing options...
kevan79 Posted March 28, 2005 Author Share Posted March 28, 2005 Attachment of the file in .txt format...wouldn't let me upload the vbs file itself.test.txt Link to comment Share on other sites More sharing options...
IcemanND Posted March 28, 2005 Share Posted March 28, 2005 Yep, you ran into the and I quote "The maximum length of prompt is approximately 1024 characters, depending on the width of the characters used." limit. In your case 1175 characters including spaces.Why not have this as a prompt before they login? Reword it that by entering a password and logging in they agree to the terms.run gpedit.mscComputer Configuration\Windows Settings\Security Settings\Local Policies\Security OptionsInteractive Logon: Message text for users attempting to logonInteractive Logon: Message title for users attempting to logon Link to comment Share on other sites More sharing options...
kevan79 Posted March 29, 2005 Author Share Posted March 29, 2005 Ah, so there is a limit...oh well.I knew about the interactive logon thing you were talking about, but that just gives the user the "OK" box, I'll have to talk to my bosses some more to see if it is ok to break the orginal message into 2 message boxes.Anyhow, Thanks alot for your help and I'm sure I'll be back on here asking more questions.Thanks again,Kevan Link to comment Share on other sites More sharing options...
kevan79 Posted March 31, 2005 Author Share Posted March 31, 2005 Ok question.The script isn't logging people off...it works on my personal laptop at home. But it isn't logging off people off on Windows 2k3 Server or XP Pro laptops that are a member of the domain for some reason?ALso, in Group Policy, logon scripts are set to run synchrously (sp) but on XP domain members the scripts are running synchrously, i.e. the client boots all the way up into Windows, and they can just ignore the Yes/No boxes and click nothing.Any ideas on this?THanks,Kevan Link to comment Share on other sites More sharing options...
un4given1 Posted April 1, 2005 Share Posted April 1, 2005 Why not give this a try? http://www.winguides.com/registry/display.php/22/Windows has what you are looking for built in. Link to comment Share on other sites More sharing options...
un4given1 Posted April 1, 2005 Share Posted April 1, 2005 Actually.. just found out it's bound to 1024 characters too.. Link to comment Share on other sites More sharing options...
kevan79 Posted April 1, 2005 Author Share Posted April 1, 2005 Ok I figured out why it's not logging off...I changed the orginal script Iceman posted from vbOkCancel to vbYesNo, and this makes the boxes Yes/No, but then the script does not act as it should, i.e. log people off...so, is there a 'correct' way to make the yes/no boxes so that it will log off people?If not, I guess Ok/Cancel will have to work, but Yes/No would be alot nicer.Thanks,Kevan Link to comment Share on other sites More sharing options...
IcemanND Posted April 1, 2005 Share Posted April 1, 2005 Change:if intReturn = 2 then WshShell.Run "shutdown -l" ,,Trueif intReturn = 1 then wscript.quitto:if intReturn = 7 then WshShell.Run "shutdown -l" ,,Trueif intReturn = 6 then wscript.quitReturn codes for MSGBOX:1 OK 2 Cancel 3 Abort 4 Retry 5 Ignore 6 Yes 7 No 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