![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Script Here is a script I am working on. It works fine except for the restore part. If you hit yes all works fine, but when the second message box comes up with Would you like to make a Restore Point and you hit No, it should ship the restore part, and continue running the 'No restore run this part of the script, but it does not it runs the whole script. I would like it when you hit no at the second message box, it will just run the last part of the script that reads, 'No restore Run This. 'Fast Menu Display Dim WshShell, Message If WScript.Arguments.length = 0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", """" & _ WScript.ScriptFullName & """" &_ " RunAsAdministrator", , "runas", 1 Else Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ & "Adding information can unintentionally change or delete values" & vbCr _ & "and cause components to stop working correctly." & vbCr _ & "If you do not trust the source of this information, do not add it to the registry." & vbCr & vbCr _ & "Would you like to continue?" M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") If M = 6 Then Message = "Would you like to make a Restore Point?" If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> vbYes) Then End If Set WshShell = WScript.CreateObject("WScript.Shell") 'Make a Restore Point Result = WshShell.Popup("Creating a Restore Point, this will take about 10 seconds.", 2, "AutoRestore", 65) Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") msg = "New Restore Point successfully created." & vbCr _ & "It is listed as: " _ & "Automatic Restore Point " & vbCr & Date & " at " & Time _ & vbCr & vbCr & "Hit OK to Continue" If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then MsgBox msg Else MsgBox "Restore Point creation Failed!" End If 'No restore Run This WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" MsgBox Message , 64 ,"Done" End If End If |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Script "PaulM" <paul@xxxxxx> wrote in message news:uKOOU93DJHA.1180@xxxxxx Quote: > Here is a script I am working on. It works fine except for the restore > part. If you hit yes all works fine, but when the second message box comes > up with Would you like to make a Restore Point and you hit No, it should > ship the restore part, and continue running the 'No restore run this part > of the script, but it does not it runs the whole script. > I would like it when you hit no at the second message box, it will just > run the last part of the script that reads, 'No restore Run This. > > > > 'Fast Menu Display > > Dim WshShell, Message > > If WScript.Arguments.length = 0 Then > Set objShell = CreateObject("Shell.Application") > objShell.ShellExecute "wscript.exe", """" & _ > WScript.ScriptFullName & """" &_ > " RunAsAdministrator", , "runas", 1 > Else > Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ > & "Adding information can unintentionally change or delete values" & vbCr > _ > & "and cause components to stop working correctly." & vbCr _ > & "If you do not trust the source of this information, do not add it to > the registry." & vbCr & vbCr _ > & "Would you like to continue?" > > M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") > If M = 6 Then > > Message = "Would you like to make a Restore Point?" > If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> vbYes) > Then > > End If > Set WshShell = WScript.CreateObject("WScript.Shell") > > 'Make a Restore Point > Result = WshShell.Popup("Creating a Restore Point, this will take about 10 > seconds.", 2, "AutoRestore", 65) > Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") > msg = "New Restore Point successfully created." & vbCr _ > & "It is listed as: " _ > & "Automatic Restore Point " & vbCr & Date & " at " & Time _ > & vbCr & vbCr & "Hit OK to Continue" > > If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then > MsgBox msg > Else > MsgBox "Restore Point creation Failed!" > End If > 'No restore Run This > WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" > > Message = "Fast Menu Display Enabled!" > MsgBox Message , 64 ,"Done" > End If > End If > Message = "Would you like to make a Restore Point?" Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") If (Response = vbNo) Then Wscript.Quit End If ' Code to create restore point. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Script Thanks, but that does not work. When you press no for no restore point it will exit out without running this part of the script. 'No restore Run This WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" MsgBox Message , 64 ,"Done" End If End If "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:uZ$3vW4DJHA.3624@xxxxxx Quote: > > "PaulM" <paul@xxxxxx> wrote in message > news:uKOOU93DJHA.1180@xxxxxx Quote: >> Here is a script I am working on. It works fine except for the restore >> part. If you hit yes all works fine, but when the second message box >> comes up with Would you like to make a Restore Point and you hit No, it >> should ship the restore part, and continue running the 'No restore run >> this part of the script, but it does not it runs the whole script. >> I would like it when you hit no at the second message box, it will just >> run the last part of the script that reads, 'No restore Run This. >> >> >> >> 'Fast Menu Display >> >> Dim WshShell, Message >> >> If WScript.Arguments.length = 0 Then >> Set objShell = CreateObject("Shell.Application") >> objShell.ShellExecute "wscript.exe", """" & _ >> WScript.ScriptFullName & """" &_ >> " RunAsAdministrator", , "runas", 1 >> Else >> Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ >> & "Adding information can unintentionally change or delete values" & vbCr >> _ >> & "and cause components to stop working correctly." & vbCr _ >> & "If you do not trust the source of this information, do not add it to >> the registry." & vbCr & vbCr _ >> & "Would you like to continue?" >> >> M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") >> If M = 6 Then >> >> Message = "Would you like to make a Restore Point?" >> If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> vbYes) >> Then >> >> End If >> Set WshShell = WScript.CreateObject("WScript.Shell") >> >> 'Make a Restore Point >> Result = WshShell.Popup("Creating a Restore Point, this will take about >> 10 seconds.", 2, "AutoRestore", 65) >> Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") >> msg = "New Restore Point successfully created." & vbCr _ >> & "It is listed as: " _ >> & "Automatic Restore Point " & vbCr & Date & " at " & Time _ >> & vbCr & vbCr & "Hit OK to Continue" >> >> If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then >> MsgBox msg >> Else >> MsgBox "Restore Point creation Failed!" >> End If >> 'No restore Run This >> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" >> >> Message = "Fast Menu Display Enabled!" >> MsgBox Message , 64 ,"Done" >> End If >> End If >> > I would suggest something like: > > Message = "Would you like to make a Restore Point?" > Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") > > If (Response = vbNo) Then > Wscript.Quit > End If > > ' Code to create restore point. > > -- > Richard Mueller > MVP Directory Services > Hilltop Lab - http://www.rlmueller.net > -- > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Script It is somewhat difficult to determine precisely what your intention is in this script. Based on your response to Richard below, I suspect what you need is either an if-then-else-endif structure or a select-case-endselect structure. I would strongly recommend that you use a "pseudo code" approach to developing your scripts. This generally involves noting *what* your script is to do, not *how* it is to do it. For example, the initial pseudo-code for your script might have contained something like this: askuser "continue?" if yes then askuser "make restore point?" if yes then attempt to make the restore point if success then write success message else write failure message end if else write to registry and advise user fast menu is enabled. end if end if Once you have this skeleton built, you flesh it out by adding the actual code, and converting the pseudo-code to comments. Note that the indenting tends to make it clearer which endif belongs to which if, and what the alternate paths through the code might be. The blank lines separating the code that actually does something from the code that just decides which code to execute are similarly useful. That said, I am a bit concerned about this part of your original script: Message = "Would you like to make a Restore Point?" If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> vbYes) Then End If If you respond to the msgbox dialog by clicking on the YES button, the code between "then" and "end if" will be skipped - if you click any other button, the code will be executed. Since the code consists of zero lines of code, the end result will be virtually the same regardless which button you click. /Al "PaulM" <paul@xxxxxx> wrote in message news:O7Vt%23U5DJHA.3624@xxxxxx Quote: > Thanks, but that does not work. When you press no for no restore point it > will exit out without running this part of the script. > 'No restore Run This > WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" > Message = "Fast Menu Display Enabled!" > MsgBox Message , 64 ,"Done" > End If > End If > > > > "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in > message news:uZ$3vW4DJHA.3624@xxxxxx Quote: >> >> "PaulM" <paul@xxxxxx> wrote in message >> news:uKOOU93DJHA.1180@xxxxxx Quote: >>> Here is a script I am working on. It works fine except for the restore >>> part. If you hit yes all works fine, but when the second message box >>> comes up with Would you like to make a Restore Point and you hit No, it >>> should ship the restore part, and continue running the 'No restore run >>> this part of the script, but it does not it runs the whole script. >>> I would like it when you hit no at the second message box, it will just >>> run the last part of the script that reads, 'No restore Run This. >>> >>> >>> >>> 'Fast Menu Display >>> >>> Dim WshShell, Message >>> >>> If WScript.Arguments.length = 0 Then >>> Set objShell = CreateObject("Shell.Application") >>> objShell.ShellExecute "wscript.exe", """" & _ >>> WScript.ScriptFullName & """" &_ >>> " RunAsAdministrator", , "runas", 1 >>> Else >>> Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ >>> & "Adding information can unintentionally change or delete values" & >>> vbCr _ >>> & "and cause components to stop working correctly." & vbCr _ >>> & "If you do not trust the source of this information, do not add it to >>> the registry." & vbCr & vbCr _ >>> & "Would you like to continue?" >>> >>> M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") >>> If M = 6 Then >>> >>> Message = "Would you like to make a Restore Point?" >>> If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> vbYes) >>> Then >>> >>> End If >>> Set WshShell = WScript.CreateObject("WScript.Shell") >>> >>> 'Make a Restore Point >>> Result = WshShell.Popup("Creating a Restore Point, this will take about >>> 10 seconds.", 2, "AutoRestore", 65) >>> Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") >>> msg = "New Restore Point successfully created." & vbCr _ >>> & "It is listed as: " _ >>> & "Automatic Restore Point " & vbCr & Date & " at " & Time _ >>> & vbCr & vbCr & "Hit OK to Continue" >>> >>> If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then >>> MsgBox msg >>> Else >>> MsgBox "Restore Point creation Failed!" >>> End If >>> 'No restore Run This >>> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, >>> "REG_SZ" >>> >>> Message = "Fast Menu Display Enabled!" >>> MsgBox Message , 64 ,"Done" >>> End If >>> End If >>> >> I would suggest something like: >> >> Message = "Would you like to make a Restore Point?" >> Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") >> >> If (Response = vbNo) Then >> Wscript.Quit >> End If >> >> ' Code to create restore point. >> >> -- >> Richard Mueller >> MVP Directory Services >> Hilltop Lab - http://www.rlmueller.net >> -- >> >> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Script Thanks for the info. I will give it a try and get back to you. "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:efxHP6SEJHA.3996@xxxxxx Quote: > It is somewhat difficult to determine precisely what your intention is in > this script. Based on your response to Richard below, I suspect what you > need is either an if-then-else-endif structure or a select-case-endselect > structure. > > I would strongly recommend that you use a "pseudo code" approach to > developing your scripts. This generally involves noting *what* your script > is to do, not *how* it is to do it. For example, the initial pseudo-code > for your script might have contained something like this: > > askuser "continue?" > if yes then > askuser "make restore point?" > if yes then > > attempt to make the restore point > > if success then > > write success message > > else > > write failure message > > end if > else > > write to registry and advise user fast menu is enabled. > > end if > end if > > Once you have this skeleton built, you flesh it out by adding the actual > code, and converting the pseudo-code to comments. > > Note that the indenting tends to make it clearer which endif belongs to > which if, and what the alternate paths through the code might be. The > blank lines separating the code that actually does something from the code > that just decides which code to execute are similarly useful. > > > That said, I am a bit concerned about this part of your original script: > > Message = "Would you like to make a Restore Point?" > If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> > vbYes) Then > > End If > > If you respond to the msgbox dialog by clicking on the YES button, the > code between "then" and "end if" will be skipped - if you click any other > button, the code will be executed. Since the code consists of zero lines > of code, the end result will be virtually the same regardless which button > you click. > > > > /Al > > "PaulM" <paul@xxxxxx> wrote in message > news:O7Vt%23U5DJHA.3624@xxxxxx Quote: >> Thanks, but that does not work. When you press no for no restore point it >> will exit out without running this part of the script. >> 'No restore Run This >> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" >> Message = "Fast Menu Display Enabled!" >> MsgBox Message , 64 ,"Done" >> End If >> End If >> >> >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:uZ$3vW4DJHA.3624@xxxxxx Quote: >>> >>> "PaulM" <paul@xxxxxx> wrote in message >>> news:uKOOU93DJHA.1180@xxxxxx >>>> Here is a script I am working on. It works fine except for the restore >>>> part. If you hit yes all works fine, but when the second message box >>>> comes up with Would you like to make a Restore Point and you hit No, it >>>> should ship the restore part, and continue running the 'No restore run >>>> this part of the script, but it does not it runs the whole script. >>>> I would like it when you hit no at the second message box, it will just >>>> run the last part of the script that reads, 'No restore Run This. >>>> >>>> >>>> >>>> 'Fast Menu Display >>>> >>>> Dim WshShell, Message >>>> >>>> If WScript.Arguments.length = 0 Then >>>> Set objShell = CreateObject("Shell.Application") >>>> objShell.ShellExecute "wscript.exe", """" & _ >>>> WScript.ScriptFullName & """" &_ >>>> " RunAsAdministrator", , "runas", 1 >>>> Else >>>> Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ >>>> & "Adding information can unintentionally change or delete values" & >>>> vbCr _ >>>> & "and cause components to stop working correctly." & vbCr _ >>>> & "If you do not trust the source of this information, do not add it to >>>> the registry." & vbCr & vbCr _ >>>> & "Would you like to continue?" >>>> >>>> M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") >>>> If M = 6 Then >>>> >>>> Message = "Would you like to make a Restore Point?" >>>> If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> >>>> vbYes) Then >>>> >>>> End If >>>> Set WshShell = WScript.CreateObject("WScript.Shell") >>>> >>>> 'Make a Restore Point >>>> Result = WshShell.Popup("Creating a Restore Point, this will take about >>>> 10 seconds.", 2, "AutoRestore", 65) >>>> Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") >>>> msg = "New Restore Point successfully created." & vbCr _ >>>> & "It is listed as: " _ >>>> & "Automatic Restore Point " & vbCr & Date & " at " & Time _ >>>> & vbCr & vbCr & "Hit OK to Continue" >>>> >>>> If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then >>>> MsgBox msg >>>> Else >>>> MsgBox "Restore Point creation Failed!" >>>> End If >>>> 'No restore Run This >>>> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, >>>> "REG_SZ" >>>> >>>> Message = "Fast Menu Display Enabled!" >>>> MsgBox Message , 64 ,"Done" >>>> End If >>>> End If >>>> >>> >>> I would suggest something like: >>> >>> Message = "Would you like to make a Restore Point?" >>> Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") >>> >>> If (Response = vbNo) Then >>> Wscript.Quit >>> End If >>> >>> ' Code to create restore point. >>> >>> -- >>> Richard Mueller >>> MVP Directory Services >>> Hilltop Lab - http://www.rlmueller.net >>> -- >>> >>> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Script Here is the updated script: On Error Resume Next Dim WshShell, Message, Input, sInput Set WshShell = WScript.CreateObject("WScript.Shell") If WScript.Arguments.length = 0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", """" & _ WScript.ScriptFullName & """" &_ " RunAsAdministrator", , "runas", 1 Else Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ & "Adding information can unintentionally change or delete values" & vbCr _ & "and cause components to stop working correctly." & vbCr _ & "If you do not trust the source of this information, do not add it to the registry." & vbCr & vbCr _ & "Do you wish to continue?" Input = MsgBox(Message, vbYesNo + vbInformation , "Notice") If (Input = vbYes) Then sInput = "Would you like to make a Restore Point?" sInput = MsgBox(sInput, vbYesNo + vbInformation , "Notice") If (sInput = vbYes) Then Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") Msg = "New Restore Point successfully created." & vbCr _ & "It is listed as: " _ & "Automatic Restore Point " & Date & " at " & Time _ If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then MsgBox Msg, 64, "Press 'Ok' to Continue with this script" else MsgBox "Restore Point creation Failed!" end if else WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" & vbCr & vbCr MsgBox Message , 64 ,"Done" end if end if end if The yes/ no works all right, but if you say yes to restore and it is successful the box comes up telling you this, but when to press ok to continue with the script to write to registry and advise user fast menu is enabled. The script will skip over the part of the code and exit. Thanks. "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:efxHP6SEJHA.3996@xxxxxx Quote: > It is somewhat difficult to determine precisely what your intention is in > this script. Based on your response to Richard below, I suspect what you > need is either an if-then-else-endif structure or a select-case-endselect > structure. > > I would strongly recommend that you use a "pseudo code" approach to > developing your scripts. This generally involves noting *what* your script > is to do, not *how* it is to do it. For example, the initial pseudo-code > for your script might have contained something like this: > > askuser "continue?" > if yes then > askuser "make restore point?" > if yes then > > attempt to make the restore point > > if success then > > write success message > > else > > write failure message > > end if > else > > write to registry and advise user fast menu is enabled. > > end if > end if > > Once you have this skeleton built, you flesh it out by adding the actual > code, and converting the pseudo-code to comments. > > Note that the indenting tends to make it clearer which endif belongs to > which if, and what the alternate paths through the code might be. The > blank lines separating the code that actually does something from the code > that just decides which code to execute are similarly useful. > > > That said, I am a bit concerned about this part of your original script: > > Message = "Would you like to make a Restore Point?" > If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> > vbYes) Then > > End If > > If you respond to the msgbox dialog by clicking on the YES button, the > code between "then" and "end if" will be skipped - if you click any other > button, the code will be executed. Since the code consists of zero lines > of code, the end result will be virtually the same regardless which button > you click. > > > > /Al > > "PaulM" <paul@xxxxxx> wrote in message > news:O7Vt%23U5DJHA.3624@xxxxxx Quote: >> Thanks, but that does not work. When you press no for no restore point it >> will exit out without running this part of the script. >> 'No restore Run This >> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" >> Message = "Fast Menu Display Enabled!" >> MsgBox Message , 64 ,"Done" >> End If >> End If >> >> >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:uZ$3vW4DJHA.3624@xxxxxx Quote: >>> >>> "PaulM" <paul@xxxxxx> wrote in message >>> news:uKOOU93DJHA.1180@xxxxxx >>>> Here is a script I am working on. It works fine except for the restore >>>> part. If you hit yes all works fine, but when the second message box >>>> comes up with Would you like to make a Restore Point and you hit No, it >>>> should ship the restore part, and continue running the 'No restore run >>>> this part of the script, but it does not it runs the whole script. >>>> I would like it when you hit no at the second message box, it will just >>>> run the last part of the script that reads, 'No restore Run This. >>>> >>>> >>>> >>>> 'Fast Menu Display >>>> >>>> Dim WshShell, Message >>>> >>>> If WScript.Arguments.length = 0 Then >>>> Set objShell = CreateObject("Shell.Application") >>>> objShell.ShellExecute "wscript.exe", """" & _ >>>> WScript.ScriptFullName & """" &_ >>>> " RunAsAdministrator", , "runas", 1 >>>> Else >>>> Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ >>>> & "Adding information can unintentionally change or delete values" & >>>> vbCr _ >>>> & "and cause components to stop working correctly." & vbCr _ >>>> & "If you do not trust the source of this information, do not add it to >>>> the registry." & vbCr & vbCr _ >>>> & "Would you like to continue?" >>>> >>>> M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") >>>> If M = 6 Then >>>> >>>> Message = "Would you like to make a Restore Point?" >>>> If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> >>>> vbYes) Then >>>> >>>> End If >>>> Set WshShell = WScript.CreateObject("WScript.Shell") >>>> >>>> 'Make a Restore Point >>>> Result = WshShell.Popup("Creating a Restore Point, this will take about >>>> 10 seconds.", 2, "AutoRestore", 65) >>>> Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") >>>> msg = "New Restore Point successfully created." & vbCr _ >>>> & "It is listed as: " _ >>>> & "Automatic Restore Point " & vbCr & Date & " at " & Time _ >>>> & vbCr & vbCr & "Hit OK to Continue" >>>> >>>> If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then >>>> MsgBox msg >>>> Else >>>> MsgBox "Restore Point creation Failed!" >>>> End If >>>> 'No restore Run This >>>> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, >>>> "REG_SZ" >>>> >>>> Message = "Fast Menu Display Enabled!" >>>> MsgBox Message , 64 ,"Done" >>>> End If >>>> End If >>>> >>> >>> I would suggest something like: >>> >>> Message = "Would you like to make a Restore Point?" >>> Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") >>> >>> If (Response = vbNo) Then >>> Wscript.Quit >>> End If >>> >>> ' Code to create restore point. >>> >>> -- >>> Richard Mueller >>> MVP Directory Services >>> Hilltop Lab - http://www.rlmueller.net >>> -- >>> >>> > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Script This is my seconds replay. This is the only way I could get the script to work the way I wanted it to. On Error Resume Next Dim WshShell, Message, Input, sInput Set WshShell = WScript.CreateObject("WScript.Shell") If WScript.Arguments.length = 0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", """" & _ WScript.ScriptFullName & """" &_ " RunAsAdministrator", , "runas", 1 Else Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ & "Adding information can unintentionally change or delete values" & vbCr _ & "and cause components to stop working correctly." & vbCr _ & "If you do not trust the source of this information, do not add it to the registry." & vbCr & vbCr _ & "Do you wish to continue?" Input = MsgBox(Message, vbYesNo + vbInformation , "Notice") If (Input = vbYes) Then sInput = "Would you like to make a Restore Point?" sInput = MsgBox(sInput, vbYesNo + vbInformation , "Notice") If (sInput = vbYes) Then Result = WshShell.Popup("Creating a Restore Point, this will take about 10 seconds.", 2, "AutoRestore", 65) Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") Msg = "New Restore Point successfully created." & vbCr _ & "It is listed as: " _ & "Automatic Restore Point " & Date & " at " & Time _ If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then MsgBox Msg, 64, "Press 'Ok' to Continue with this script" 'Extra code here to get it to work WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" & vbCr & vbCr MsgBox Message , 64 ,"Done" else MsgBox "Restore Point creation Failed!" 'End here end if else WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" & vbCr & vbCr MsgBox Message , 64 ,"Done" end if end if end if "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:efxHP6SEJHA.3996@xxxxxx Quote: > It is somewhat difficult to determine precisely what your intention is in > this script. Based on your response to Richard below, I suspect what you > need is either an if-then-else-endif structure or a select-case-endselect > structure. > > I would strongly recommend that you use a "pseudo code" approach to > developing your scripts. This generally involves noting *what* your script > is to do, not *how* it is to do it. For example, the initial pseudo-code > for your script might have contained something like this: > > askuser "continue?" > if yes then > askuser "make restore point?" > if yes then > > attempt to make the restore point > > if success then > > write success message > > else > > write failure message > > end if > else > > write to registry and advise user fast menu is enabled. > > end if > end if > > Once you have this skeleton built, you flesh it out by adding the actual > code, and converting the pseudo-code to comments. > > Note that the indenting tends to make it clearer which endif belongs to > which if, and what the alternate paths through the code might be. The > blank lines separating the code that actually does something from the code > that just decides which code to execute are similarly useful. > > > That said, I am a bit concerned about this part of your original script: > > Message = "Would you like to make a Restore Point?" > If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> > vbYes) Then > > End If > > If you respond to the msgbox dialog by clicking on the YES button, the > code between "then" and "end if" will be skipped - if you click any other > button, the code will be executed. Since the code consists of zero lines > of code, the end result will be virtually the same regardless which button > you click. > > > |
My System Specs![]() |
| | #8 (permalink) |
| | Re: Script "PaulM" <paul@xxxxxx> wrote in message news:er1xVBUEJHA.4900@xxxxxx Quote: > This is my seconds replay. > > This is the only way I could get the script to work the way I wanted it > to. points in a nested conditional structure is better than trying to twist the nested stucture around so the logically different paths through it share a single copy of these identical chunks of code. Sometimes, though, it makes sense to take those common chunks of code and put one copy in a subroutine and call it from wherever it is needed. But more important for your purposes is: do you understand why the original script did not work the way you had anticipted it should, and do you understand why it works now? /Al <snip> |
My System Specs![]() |
| | #9 (permalink) |
| | Re: Script My 3rd reply. Re did the script and got it to work this way. What do you think? Set WshShell = WScript.CreateObject("WScript.Shell") If WScript.Arguments.length =0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", """" & _ WScript.ScriptFullName & """" &_ " RunAsAdministrator", , "runas", 1 Else Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ & "Adding information can unintentionally change or delete values" & vbCr _ & "and cause components to stop working correctly." & vbCr _ & "If you do not trust the source of this information, do not add it to the registry." & vbCr & vbCr _ & "Do you wish to continue?" Input = MsgBox(Message, vbYesNo + vbInformation , "Notice") If (Input = vbYes) Then uInput = "Would you like to create a Restore Point before you continue?" uInput = MsgBox(uInput, vbYesNo + vbQuestion , "Notice") If (uInput = vbYes) Then Result = WshShell.Popup("It will take about 10 seconds to create the Restore Point." ,2, "Creating Restore Point", 64) Set SRP = getobject("winmgmts:\\.\root\default:Systemrestore") sDesc = "Auto Restore Point" sOut = SRP.createrestorepoint ( sDesc ,0,100) MsgBox "New Restore Point successfully created on" & " " & Date & " at " & Time & vbCr & vbCr & "Press 'Ok' to continue." ,64, "Done" If sOut <> 0 Then MsgBox "Restore Point creation Failed!" else end if else end if WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" Message = "Fast Menu Display Enabled!" & vbCr & vbCr MsgBox Message , 64 ,"Done" end if end if Thanks "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:efxHP6SEJHA.3996@xxxxxx Quote: > It is somewhat difficult to determine precisely what your intention is in > this script. Based on your response to Richard below, I suspect what you > need is either an if-then-else-endif structure or a select-case-endselect > structure. > > I would strongly recommend that you use a "pseudo code" approach to > developing your scripts. This generally involves noting *what* your script > is to do, not *how* it is to do it. For example, the initial pseudo-code > for your script might have contained something like this: > > askuser "continue?" > if yes then > askuser "make restore point?" > if yes then > > attempt to make the restore point > > if success then > > write success message > > else > > write failure message > > end if > else > > write to registry and advise user fast menu is enabled. > > end if > end if > > Once you have this skeleton built, you flesh it out by adding the actual > code, and converting the pseudo-code to comments. > > Note that the indenting tends to make it clearer which endif belongs to > which if, and what the alternate paths through the code might be. The > blank lines separating the code that actually does something from the code > that just decides which code to execute are similarly useful. > > > That said, I am a bit concerned about this part of your original script: > > Message = "Would you like to make a Restore Point?" > If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> > vbYes) Then > > End If > > If you respond to the msgbox dialog by clicking on the YES button, the > code between "then" and "end if" will be skipped - if you click any other > button, the code will be executed. Since the code consists of zero lines > of code, the end result will be virtually the same regardless which button > you click. > > > > /Al > > "PaulM" <paul@xxxxxx> wrote in message > news:O7Vt%23U5DJHA.3624@xxxxxx Quote: >> Thanks, but that does not work. When you press no for no restore point it >> will exit out without running this part of the script. >> 'No restore Run This >> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, "REG_SZ" >> Message = "Fast Menu Display Enabled!" >> MsgBox Message , 64 ,"Done" >> End If >> End If >> >> >> >> "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in >> message news:uZ$3vW4DJHA.3624@xxxxxx Quote: >>> >>> "PaulM" <paul@xxxxxx> wrote in message >>> news:uKOOU93DJHA.1180@xxxxxx >>>> Here is a script I am working on. It works fine except for the restore >>>> part. If you hit yes all works fine, but when the second message box >>>> comes up with Would you like to make a Restore Point and you hit No, it >>>> should ship the restore part, and continue running the 'No restore run >>>> this part of the script, but it does not it runs the whole script. >>>> I would like it when you hit no at the second message box, it will just >>>> run the last part of the script that reads, 'No restore Run This. >>>> >>>> >>>> >>>> 'Fast Menu Display >>>> >>>> Dim WshShell, Message >>>> >>>> If WScript.Arguments.length = 0 Then >>>> Set objShell = CreateObject("Shell.Application") >>>> objShell.ShellExecute "wscript.exe", """" & _ >>>> WScript.ScriptFullName & """" &_ >>>> " RunAsAdministrator", , "runas", 1 >>>> Else >>>> Message = "This script will Speed up the Menu Display." & vbCr & vbCr _ >>>> & "Adding information can unintentionally change or delete values" & >>>> vbCr _ >>>> & "and cause components to stop working correctly." & vbCr _ >>>> & "If you do not trust the source of this information, do not add it to >>>> the registry." & vbCr & vbCr _ >>>> & "Would you like to continue?" >>>> >>>> M = MsgBox(Message, vbYesNo + vbInformation, "Fast Menu") >>>> If M = 6 Then >>>> >>>> Message = "Would you like to make a Restore Point?" >>>> If (MsgBox(Message, vbYesNo + vbInformation , "Restore Point") <> >>>> vbYes) Then >>>> >>>> End If >>>> Set WshShell = WScript.CreateObject("WScript.Shell") >>>> >>>> 'Make a Restore Point >>>> Result = WshShell.Popup("Creating a Restore Point, this will take about >>>> 10 seconds.", 2, "AutoRestore", 65) >>>> Set srp = getobject("winmgmts:\\.\root\default:Systemrestore") >>>> msg = "New Restore Point successfully created." & vbCr _ >>>> & "It is listed as: " _ >>>> & "Automatic Restore Point " & vbCr & Date & " at " & Time _ >>>> & vbCr & vbCr & "Hit OK to Continue" >>>> >>>> If (srp.createrestorepoint("Automatic Restore Point", 0, 100)) = 0 Then >>>> MsgBox msg >>>> Else >>>> MsgBox "Restore Point creation Failed!" >>>> End If >>>> 'No restore Run This >>>> WshShell.RegWrite "HKCU\Control Panel\Desktop\MenuShowDelay", 1, >>>> "REG_SZ" >>>> >>>> Message = "Fast Menu Display Enabled!" >>>> MsgBox Message , 64 ,"Done" >>>> End If >>>> End If >>>> >>> >>> I would suggest something like: >>> >>> Message = "Would you like to make a Restore Point?" >>> Response = MsgBox(Message, vbYesNo + vbInformation , "Restore Point") >>> >>> If (Response = vbNo) Then >>> Wscript.Quit >>> End If >>> >>> ' Code to create restore point. >>> >>> -- >>> Richard Mueller >>> MVP Directory Services >>> Hilltop Lab - http://www.rlmueller.net >>> -- >>> >>> > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: Script Yes I understand why it works now and why it did not work. Like I said thanks for the help. "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:uKQ3JvWEJHA.3476@xxxxxx Quote: > > "PaulM" <paul@xxxxxx> wrote in message > news:er1xVBUEJHA.4900@xxxxxx Quote: >> This is my seconds replay. >> >> This is the only way I could get the script to work the way I wanted it >> to. > It sometimes happens that including identical snippets of code at > different points in a nested conditional structure is better than trying > to twist the nested stucture around so the logically different paths > through it share a single copy of these identical chunks of code. > > Sometimes, though, it makes sense to take those common chunks of code and > put one copy in a subroutine and call it from wherever it is needed. > > But more important for your purposes is: do you understand why the > original script did not work the way you had anticipted it should, and do > you understand why it works now? > > /Al > > <snip> > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Logon Script Causing Laptops To Hang - Problems in script? | VB Script | |||
| problem passing args to script 'There is no script engine for file extenstion' | VB Script | |||
| Include another script, keep variables in included script? | PowerShell | |||
| Script file has 'OS Handle' error when run from script | PowerShell | |||
| Can you drag-n-drop a file on top of a PS script to run the script? | PowerShell | |||