March 23, 200521 yr 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
March 23, 200521 yr 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
March 25, 200521 yr Author 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.
March 25, 200521 yr MsgBox ("If" & VBCRLF & "you" & VBCRLF & "agree" & VBCRLF & _ "click" & VBCRLF & "ok" & VBCRLF & "to" & _ VBCRLF & "continue", vbOKCancel + vbExclamation, "Alert")
March 27, 200521 yr Author 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.
March 28, 200521 yr Author 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
March 28, 200521 yr Author Attachment of the file in .txt format...wouldn't let me upload the vbs file itself.test.txt
March 28, 200521 yr 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
March 29, 200521 yr Author 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
March 31, 200521 yr Author 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
April 1, 200521 yr Why not give this a try? http://www.winguides.com/registry/display.php/22/Windows has what you are looking for built in.
April 1, 200521 yr Author 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
April 1, 200521 yr 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
Create an account or sign in to comment