Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Cannot get vbscripting working


  • Please log in to reply
8 replies to this topic

#1 JohnBobSmith

JohnBobSmith

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:03:18 AM

Posted 23 May 2013 - 07:08 PM

I can't get a simple msgbox script working in windows 8. So I am wondering what is required to get visual basic scripting working in windows 8. My windows 7 machine handles the same thing just fine. The problem is the code doesnt open. Any help is appreciated! if you need more info, shout.  



BC AdBot (Login to Remove)

 


#2 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:05:18 AM

Posted 24 May 2013 - 10:05 AM

Can you post your script?

#3 JohnBobSmith

JohnBobSmith
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:03:18 AM

Posted 24 May 2013 - 10:34 AM

I want to have a just a message box for now so this is the code for that:

 

 Test = MsgBox("Do you wish to continue.", vbYesNoCancel + vbQuestion)

Select Case Test
Case vbYes
MsgBox "You chose Yes"
Case vbNo
MsgBox "You chose No"
Case vbCancel
MsgBox "You chose Cancel"

 

and then a .vbscript that makes the pc say welcome when I log on

 

 

Dim speaks, speech
speaks="Welcome to your PC, John Bob Smith"
Set speech=CreateObject("sapi.spvoice")
speech.Speak speaks

 

The message box code I eventually want to have variables with for another mini-game while I learn how to code, but thats it for now. I will test it again and make sure that it doesnt open as I haven't tested it in a little while. Both codes dont open/work at the time of this post.  



#4 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:05:18 AM

Posted 24 May 2013 - 11:28 AM

Both work fine on Windows 8 for me. You are missing a line in the messagebox example though. It should be:

Test = MsgBox("Do you wish to continue.", vbYesNoCancel + vbQuestion)

Select Case Test
Case vbYes
MsgBox "You chose Yes"
Case vbNo
MsgBox "You chose No"
Case vbCancel
MsgBox "You chose Cancel"
End Select
Notice the End Select at the end.

Are you saving them as a vbs file. For example test.vbs? How are you trying to launch them? Just double-clicking on the file to launch?

#5 JohnBobSmith

JohnBobSmith
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:03:18 AM

Posted 24 May 2013 - 12:10 PM

Im double clicking on them to launch. They are saved as .vbs with the .vbs icon appearing when they are saved. They wont open. I will inquire into why they wont work for me. 



#6 AceInfinity

AceInfinity

  • Members
  • 30 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:02:18 AM

Posted 25 May 2013 - 01:16 AM

Perhaps you don't have the default file handler for .vbs file extensions set to wscript for some reason? What do you mean by "they won't open"?

mvp.png
Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


#7 JohnBobSmith

JohnBobSmith
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:03:18 AM

Posted 25 May 2013 - 12:42 PM

Like when you double click on them, nothing happens. 



#8 Grinler

Grinler

    Lawrence Abrams


  • Admin
  • 43,593 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:05:18 AM

Posted 03 June 2013 - 10:22 AM

Sorry for the delay in getting back to you.

On the Windows 8 start screen, type default programs and when it appears in the search results, click on it.

You will now be at the desktop where the Default Programs control panel will be open. Click on the Associate a file type of protocol with a program option. When the screen opens, scroll down till you see the .vbs extension and left-click on it once to highlight it. Then click on the Change program... button. You will now be shown a list of options to select. You want to select Microsoft Windows base script host.

If that does not appears, click on the More Options button and then Look for another app on this PC. Then browse to c:\windows\system32\wscript.exe and select that.

Once .vbs is assigned to wscript, your vbs scripts should work normally when you double-click on them.

#9 JohnBobSmith

JohnBobSmith
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Local time:03:18 AM

Posted 04 June 2013 - 01:17 AM

Ah no worries on the delay. I will try that and see if it works and get back to you if it did! thanks! 

 

EDIT: Nope, didnt work. The .vbs extension was already assigned to microsoft windows base script host. I also tried assigning the .vbs extension to wscript.exe, but nothing happened. I'm not sure what the problem is. :( I will do some more google searching and see if I can't figure out why .vbs files are not working. Thanks for the help! 


Edited by JohnBobSmith, 04 June 2013 - 09:21 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users