I have been trying to get a VBS script to work for a while now with msgbox. When I use a single msgbox statement, it works. As soon as I start adding conditional input options, then it doesn't work.
I posted this question on Super User and I was told to use the "dim" statement, and to post on this website, and I have done both now. Here is some of the code I am trying that works. (Please ignore my example.)
Option Explicit
Dim vbsmsg, vbsyes, vbsno
vbsmsg=MsgBox("Proceeding will wipe the contents of your C: Drive. Proceed?", 1+48, "Format Drive C:")
When I run the above code via a shortcut I get a dialog like this:
But if I add the following, I get a run-time error when clicking "OK" or "Cancel"
If vbsmsg=1 Then
vbsyes=MsgBox("The contents of your C: Drive could not be successfully deleted.", 0+64, "Error Formatting Drive C: - System Error 5")
If vbsmsg=2 Then
vbsno=MsgBox("Not all of the contents of your C: Drive were successfully deleted. Please try again.", 0+64, "Error Formatting Drive C: - System Error 303")
The line/character in the error is between the "0" and "3" in "System Error 303"
I have tried a great deal of troubleshooting already. I have tried altering the dim statement, adding option explicit, using 1 and 2 instead of 6 and 8, etc... nothing seems to work. When I commented out the 2nd part, instead of getting an error after executing the file, it just closed on me. I am positive all of my syntax is correct and in the right format. I changed 1 and 2 to vbOK and vbCancel and when I changed it back it wouldn't work at all and gave me the error pictured on this page right away.
If anyone knows what is wrong with my examples, I would greatly appreciate it. I am fairly new to working with VBS files, but I have been working with .bat files for a long time and none of those principles seem to be working here,
I would appreciate any assistance, even if it is small,