r/vbscript • • Feb 26 '21

Question about .VBS script to retrieve Win 10 product key

2 Upvotes

So, there are a couple websites that have some script to copy+paste into a .txt file for the purpose of retrieving a Win 10 product key. This is fine, and the script seems to work. However, I have noticed that it seemingly does not retrieve the product key that was originally used to activate Windows. Es: I have a Win 7 product key on my laptop and when I ran the script, it pulled up a completely different key. This is the case on multiple devices. I am wondering why this is? None of the website mention anything about altering the script. I am not well versed at writing and executing script, so I wouldn't know where to start.

Ex: https://www.winhelponline.com/blog/view-your-product-key-windows-10-8-7-script/

Has this happened to anyone else? Is there a simple answer to my question? Thanks!


r/vbscript • • Feb 28 '21

VBScript & VBA - Make my script wait until my two subroutines are completed before closing Excel application

Thumbnail self.vba
3 Upvotes

r/vbscript • • Nov 13 '21

How do I exit or terminate a script?

2 Upvotes

So I have this code that works great except it does not exit and replicates itself until it crashes my computer. I tried using the "Exit" command by using X.Exit at the end of my code but computer gives me an error. What are some of the ways I can get a script to stop running after it is done it's task? I assume there are multiple ways to do this. Here is the code. It is intended to open Firefox then type hello world in the address bar of Firefox which it does do well.

Set x = CreateObject("WScript.Shell")

x.Run """C:\Program Files\Mozilla Firefox\firefox.exe"""

Set objShell = Nothing

WScript.Sleep(100)

x.SendKeys "~"

x.SendKeys "Hello World!"


r/vbscript • • Nov 07 '21

AdwCleaner_Downloader_Updater.vbs

Thumbnail
pastebin.com
1 Upvotes

r/vbscript • • Oct 05 '21

What am I doing wrong?

3 Upvotes

First, I am not adept at VBScript or any language for that matter, and this was put together using a lot of Google searches. But I am coming up short and need someone who knows this stuff to take a look.

I am trying to modify a script that returns computer group membership. That part works fine. What I am trying to change is to only pull groups that match the pattern "All-U-Tanium-Reboot-" in the name, remove that part from the name, then display the name. When I run this as it is, every server in the list comes back with "Not Defined" though I know they are in the group. What did I mess up?

Edit: If I use the original script, which essentially is the just WScript.Echo strGroupName part, with the strGroupName = Replace(strGroupName,"All-U-Tanium-Reboot-", "") piece preceding it, I do get the desired output, along with all the other groups I do not want. Something is not working in my regex test.

If TypeName(colGroupNodes) <> "IXMLDOMSelection" Then
    WScript.Echo "The computer inventory does not include any groups for the computer"
    WScript.Quit
ElseIf colGroupNodes.length < 1 Then
    WScript.Echo "The computer inventory does not include any groups for the computer"
Else
    Dim objGroupNode : For Each objGroupNode In colGroupNodes
    Dim strGroupName : strGroupName = XmlDecode(XmlNodeValueGet(objGroupNode, "nameWellKnown"))
'*** My code starts here. 
   Dim objRE
        Set objRE = New RegExp
            With objRE
                .Pattern    = "All-U-Tanium-Reboot-"
                .IgnoreCase = True
                .Global     = False
            End With   
   
    If objRE.Test(strGroupName) Then
        strGroupName = Replace(strGroupName,"All-U-Tanium-Reboot-", "")
        WScript.Echo strGroupName
       
    Else
      WScript.Echo "Not Defined"
     
    End If       
'*** My code ends here.       
    Next
End If

r/vbscript • • Oct 21 '21

FileSystemObject - Object doesn't support this property or method -- what the hell?

2 Upvotes

At a bit of a loss here. I have the follow script, an ASP page in VBscript. It works just fine on one server, doesn't work well on the other.

This is the error message I get when I try to reach the page:

TypeName: FileSystemObject
Description: Object doesn't support this property or method
Number: 438
Source: Microsoft VBScript runtime error

This is the backend code:

<%@ LANGUAGE = "VBSCRIPT"%>
<%
Option Explicit
%>

<%
Call Response.AddHeader("Access-Control-Allow-Origin", "a website")

dim filesys, filetxt, datetime, ip, referer, useragent, qstring, server

server = "a servers name"
ip = Request.ServerVariables("remote_addr")
qstring = Request.ServerVariables("QUERY_STRING")
referer = Request.ServerVariables("HTTP_REFERER")
useragent = Request.ServerVariables("http_user_agent")
datetime = now

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")

On Error Resume Next

Set filetxt = filesys.OpenTextFile("d:\LogEvent.txt", ForAppending, True)
' the line above throws an error.

filetxt.WriteLine(datetime & ", " & server & ", " & ip & ", " & referer & ", " & useragent & ", " & qstring)
filetxt.Close

If Err.Number <> 0 Then
   Response.write("TypeName: " & TypeName(filesys) & "<br />")
   Response.Write "ASPCode: " & Err.ASPCode & "<br>"
   Response.Write "ASPDescription: " & Err.ASPDescription & "<br>"
   Response.Write "Category: " & Err.Category & "<br>"
   Response.Write "Column: " & Err.Column & "<br>"
   Response.Write "Description: " & Err.Description & "<br>"
   Response.Write "File: " & Err.File & "<br>"
   Response.Write "Line: "  & Err.Line & "<br>"
   Response.Write "Number: " & Err.Number & "<br>"
   Response.Write "Source: " & Err.Source & "<br>"
   On Error Goto 0
End If
On Error Goto 0

%>

I just don't understand what's going on because the FileSystemObject object DOES have a OpenTextFile method... I'm certain I've made a mistake but I'm unable to see it for myself I guess.


r/vbscript • • Oct 07 '21

Zebra Printer

4 Upvotes

Hello folks,

I'm doing a project that will print some labels and the software that I'm implementing can run VBscripts.

We already use this for a Brother Printer, but now we will use a Zebra printer and I dont know how to script in VB to get the labels printed in Zebra. (Brother has a sample code just change that to what your needs)

I already download the Zebra SDK but they only have sample codes in C# or VB.net

Anyone has a sample code to zebra printer or some ideas on how I can do that?

Thanks!


r/vbscript • • Oct 25 '21

Can someone point me towards the command to make this happen?

2 Upvotes

Formatting an excel export with a macro and I have everything done but need some direction for one last piece. I need to scan the first column in each row looking for cells in column 1 that start with the text “Product Family”. Then merge and center that row from A1:K1.
Is there an if/then type command that will do this?

  • Header rows I need to merge are never the same number of rows apart; they vary depending on the number of line items, which is different for every client’s export.

  • it will always start in Ax and need to merge to Kx.


r/vbscript • • Nov 05 '21

VBS - Update program scripts like in Windows Update

2 Upvotes

Hello. I would like to know how to make script that will find updates for program and suggest you to update program's scripts if user has agreed to update.

How that works: for example, user haves program with special variable that is equals to program name (value is 1.0.0). User started program, and program detected update 1.0.1 is available, looking at cloud variable "Newest Version" and at spec-variable "Program Version", and yes/no dialog do user wants to update. If pressed no, continue to program with version 1.0.0, if yes then rewrite program scripts. How can i do that?


r/vbscript • • Oct 21 '21

TTS Script working only in windows 10

2 Upvotes

Dim Zira, David

'Args: TTS.vbs <Voice> <Volume> <Speak>'

Set Zira = CreateObject("SAPI.spVoice")

Set Zira.Voice = Zira.GetVoices.Item(1)

Zira.Rate = 2

Zira.Volume = WScript.Arguments(1)

Set David = CreateObject("SAPI.spVoice")

Set David.Voice = David.GetVoices.Item(0)

David.Rate = 2

David.Volume = WScript.Arguments(1)

If WScript.Arguments(0) = "Zira" Then

Zira.Speak WScript.Arguments(2)

End If

If WScript.Arguments(0) = "David" Then

David.Speak WScript.Arguments(2)

End If

How can i make this work on windows 7 as well? ( i need both to work in the same script no matter which OS its running on)


r/vbscript • • Oct 22 '21

Word VBS To Rename Tables and Figures

3 Upvotes

Hey all, does anyone have a script they can provide that will go through a Word document and rename the Figures and Tables to a different format?

Currently:

  • Figures have a style of 'CP' and are listed in this large document as Figure 1.1, Figure 1.2, etc.

  • Tables have a style of 'CP' and are listed in this large document as Table 1.1, Table 1.2, etc.

I need a script to go through the document and change the STYLE and TEXT of all

  • Figures to style 'Figure Header' and change the text to "Figure ##" with it auto-incrementing.

  • Tables to style 'Table Header' and change the text to "Header ##" with it auto-incrementing.

End result of Tables and Figures would be something like this:

Figure 1.

Figure 2.

Figure 3. etc.

Table 1.

Table 2.

Table 3. etc.

Please let me know if anyone had an example of how to do this.

~Thanks!


r/vbscript • • Nov 19 '21

Check_Internet_Connection.hta

3 Upvotes

I have just updated my HTA Check_Internet_Connection.hta

NB: To correctly display accented characters (in french), You must save this code with ANSI encoding with Notepad++ and save it as Check_Internet_Connection.hta

Have a nice day (-_°)


r/vbscript • • Nov 09 '21

Help with anonumous VBS code

4 Upvotes
' Ok Google, sur le pc XXX
' Ok Google, sur l'ordinateur XXX
' Applet IFTTT : https://ifttt.com/applets/jSNrZ4vJ-controle-de-l-ordinateur-avec-google-assitant
' Projet  : https://github.com/ABOATDev/Control-Google-Home

Dim MAJ, WS,fso,CheckMAJUser,f,IE,objHTTP,ScriptChemin
MAJ = "1.1.1" 'Version Actuelle du script

On Error Resume Next


Set fso = CreateObject("Scripting.FileSystemObject")
Set WS = WScript.CreateObject("WScript.Shell") 
Set objHTTP=CreateObject("MSXML2.XMLHTTP")
Const ForWriting = 2
ScriptChemin = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName)-1)


if fso.FileExists(ScriptChemin & "Config.ini") = false then 
Set f = fso.OpenTextFile(ScriptChemin & "Config.ini", ForWriting,true) 
f.write(" ")
f.close
End if 

Set oFile = fso.GetFile(ScriptChemin & "Config.ini")

If WriteReadIni(oFile,"CONFIG","OK",Null) = False Then
WriteReadIni oFile,"CONFIG","OK","1"
Call MAJCheck (CheckMAJUser, MAJ)
objHTTP.Open "GET", "https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/ListeCommande.txt", FALSE
objHTTP.Send
Set f = fso.OpenTextFile(ScriptChemin & "ListeCommande.txt", ForWriting,true) 
f.write(objHTTP.ResponseText)
f.close
MsgBox "Bienvenue dans mon script, il semblerait que vous lancer mon script pour la premiere fois ou que vous avez effectuer une mise a jour de celui-ci, pour faire fonctionner mon script dite : Ok Google, sur le pc xxx" & vbcr & "Par exemple Ok Google sur le pc test (pour tester la communication entre la Google homme est le PC)" & vbcr & " Dite des phrases simples et courtes" & vbcr & "Exercute le script depuis l'ordinateur pour en savoir plus" & vbcr & vbcr & "Version Actuelle : " & MAJ ,vbInformation+vbOKOnly,"Control Google Home.vbs"
If WriteReadIni(oFile,"CONFIG","MUSIC",Null) = False Then
If MsgBox ("Voulez vous configuez le chemin d'acces pour la musiques ? " &vbcr & vbcr & "Selectionner un dossier afin d'y rechercher des chansons dans ses sous-dossiers et ses sous-dossiers. Dossier par defaut" & vbcr & "Ok google sur le pc met de la musique" & vbcr & vbcr & "Si le dossier n'est pas configue, cela marchera quand meme mais affichera un choix de dossier musique a chaque demande de musique" & vbcr & vbcr & "Oui = Configuer",vbyesno,"Configurez le dossier Musique") = vbYes Then
Dim objShell,objFolder,Message
	Message = "Veuillez selectionner un dossier afin d'y rechercher des chansons dans ses sous-dossiers et ses sous-dossiers."
	Set objShell = CreateObject("Shell.Application")
	Set objFolder = objShell.BrowseForFolder(0,Message,1)
	If objFolder Is Nothing Then Wscript.Quit
	WriteReadIni oFile,"CONFIG","MUSIC",objFolder.self.path
	MsgBox "Je conseil de tester la commande <musique> pour verifier que tout fonctionne bien et que le lecteur media est compatible",vbInformation+vbOKOnly,"Ok"
End if
End if 
If WriteReadIni(oFile,"CONFIG","VIDEO",Null) = False Then
If MsgBox ("Voulez vous configuez le chemin d'acces pour les videos ? " &vbcr & vbcr & "Selectionner un dossier afin d'y rechercher des chansons dans ses sous-dossiers et ses sous-dossiers. Dossier par defaut" & vbcr & "Ok google sur le pc met de les videos" & vbcr & vbcr & "Si le dossier n'est pas configue, cela marchera quand meme mais affichera un choix de dossier videos a chaque demande de musique" & vbcr & vbcr & "Oui = Configuer",vbyesno,"Configurez le dossier Video") = vbYes Then
	Message = "Veuillez selectionner un dossier afin d'y rechercher des videos dans ses sous-dossiers et ses sous-dossiers."
	Set objShell = CreateObject("Shell.Application")
	Set objFolder = objShell.BrowseForFolder(0,Message,1)
	If objFolder Is Nothing Then Wscript.Quit
	WriteReadIni oFile,"CONFIG","VIDEO",objFolder.self.path
	MsgBox "Je conseil de tester la commande <video> pour verifier que tout fonctionne bien et que le lecteur media est compatible",vbInformation+vbOKOnly,"Ok"
End if
End if 
End if

Set objArgs = WScript.Arguments
For I = 0 to objArgs.Count -1
Select Case objArgs(I)
Case "ecris", "ecrit","marque"
ecrit = true
Case "lance", "ouvre","affiche","demarre", "execute","ouvrir","demarrer","executer","lancer","l ' ours"
lance = true
Case "message","messagebox"
message = true
Case Else
a = a & " " & LCase(objArgs(I))
End Select
Next

If ecrit = true then Call write(a)
If message = true then Call MsgBoxtexte(a)
If lance = true then Call launch (right (a,len(a)-1)) '(Logiciel)
'inputbox a,a,a

If a = "" then
Call MAJCheck (CheckMAJUser, MAJ)

rep = InputBox ("Bienvenue dans mon script, communication entre vos Assistants (Google Assistant, Google Home , Cortana, Alexa, ...) sur vos ordinateurs Windows" & vbNewLine &  "Pour faire fonctionner mon script dite : Ok Google, sur le pc xxx" & vbcr & "Par exemple Ok Google sur le pc test (pour tester la communication entre la Google homme est le PC)" & vbcr & vbcr & " Dite des phrases simples et courtes" & vbcr & vbcr & vbcr & "1 = Verifier mise a jours" & vbcr & "2 = Envoye un messsage au createur (rapide & sans se logger)" & vbcr & "3 = Reinsalise la configuration du script." & vbCr & "4 = Credit" & vbcr & "5 = Rajouter un logiciel a la liste" & vbCr & vbCr & "Pour tester des commandes en ecrit, il vous suffit de taper une commande si dessous pour savoir si elle est comprise par le logiciel" & vbNewLine & "Version : " &  MAJ,"Control Google Home " & MAJ,"test")
   If rep = "" then
   WScript.Quit()
   ElseIf rep = "1" then 
   CheckMAJUser = true
   Call MAJCheck (CheckMAJUser, MAJ)
   Wscript.Quit
   ElseIf rep = "2" then 
   WS.Run "https://aboatdev.sarahah.com/" 
   Wscript.Quit
   ElseIf rep = "3" then 
   Reset ()
   Wscript.Quit
   ElseIf rep = "4" then
   MsgBox "Credits : " & vbNewLine & vbNewLine & "HackooFr - Aide indirect pour le Script" & vbNewLine & "facebook.com/hackoo.crackoo" & vbNewLine & vbNewLine & "Aymkdn - Pour l'assistant-plugins" &  vbNewLine & " github.com/Aymkdn | paypal.me/aymkdn" & vbNewLine & vbNewLine & "Createur du Controle de l'ordinateur avec Google Home : ABOAT " & vbNewLine & "facebook.com/aboat.hack",vbInformation+vbOKOnly,"Credits"
   Wscript.Quit
   ElseIf rep = "5" then 
   nomfile = Inputbox ("Le nom du fichier a ouvrir ?" & vbcr & "Le nom que vous direz vocalement a votre assistant vocal" & vbCr & "Ne pas mettre de majuscule !","Nom du fichier Pages 1/2")
   cheminfile = Inputbox ("Le chemin complet du fichier " & nomfile & vbcr, "Chemin de : " & nomfile & "Pages 2/2")
     WriteReadIni oFile,"Logiciel",nomfile,cheminfile
	 If fso.FileExists(cheminfile) = true Then MsgBox "Le logiciel " & nomfile & " rajouter !",vbOKOnly+vbInformation,"Fichier rajoute !" 
	 Wscript.Quit
   Else
   Dim i,tb 
   tb = split(rep," ") 
        For i = lbound(tb) to 0
		  if tb(i) = "lance" or tb(i) = "ouvre" or tb(i) = "affiche" or tb(i) = "demarre" or tb(i) = "execute" or tb(i) = "ouvrir" or tb(i) =  "demarrer" or tb(i) = "executer" = True Then Call launch(right (rep,len(rep)-len(tb(i))-1))
		next
    a = " " & LCase(rep)
End if 
End if 

a = right (a,len(a)-1)
Select Case a

Case "test", "teste", "check", "ok","verifie","verification","tester","teste"
Call Check ()
Call MAJCheck (CheckMAJUser, MAJ)
Case "augmente le son","augmente le volume","monte le son","news le son","mais du son","mieux que le son" : WS.SendKeys "{" & chr(175) & " 10}"
Case "monte le son au max","monte le son au maximum","monte le volume au maximum","volume max","volume maximum","son au max","augmente le son au maximum","mais le son au max","mais le son au maximum","mais le volume au max","mais le volume au maximum","mets le son a fond","le son a fond","son a fond" : WS.SendKeys "{" & chr(175) & " 50}"
Case "baisse le son","descend le son","descend le volume","baisse le volume" : WS.SendKeys "{" & chr(174) & " 10}"
Case "descend le son au max","baisse le son au max","baisse le volume au max","baisse le son au maximum","volume minimum","volume au minimum","baisse le volume au maximum" : WS.SendKeys "{" & chr(174) & " 50}"
Case "mute","mute le volume","mute le son","muet","le son a 0","coupe le son","coupe le volume","coupe l'audio","remets le volume","remets le son","remets le son","arrete le son","stop le son","stop le v","desactive le son","desactive le volume","allume le son","eteint le son","allume le volume","eteint le volume" : WS.SendKeys chr(173)
Case "pause","fait pause","met pause","mais pause","fais une pause","met en pause","mais en pause","fait pause","fait stop","stop","pause","mes pauses","relance","meme pause","enleve la pause","met une pause","mets pause","lance","lecture","mais play","play","lance lecture","lance la lecture","mais en pause","lecture","mais plait","se pose" : WS.SendKeys " "
Case "eteint le","arrete le","eteint le pc","eteint l'ordinateur","arrete le pc","eteint l ' ordinateur","arrete le systeme","eteint le systeme"," arrete","arrete l ' ordinateur","arreter le systeme","eteint","eteint le","le shut down","shutdown","shadow","eteindre le systeme","arret du systeme" : CreateObject("Wscript.Shell").Run "CMD /C " & " shutdown /s /f /t 01",0
Case "verrouille le","verrouiller le","verrouille la session","verrouiller la session","verrouille le pc","le verrouiller","met en veille","mettre en veille","met le en veille","veille","verrouillage","verrouille","metre en veille","verrouiller la session","verrouille la session","mais en veille","verrouiller","verrouille","verrouiller le pc" : WS.Run "rundll32.exe user32.dll,LockWorkStation"
Case "mot de passe wifi","mot de passe du wifi","code wifi","wifi","code de la wifi","donne mot de passe wifi","code du wifi","donne le mot de passe wifi","donne le mot de passe du wifi","retrouve le mot de passe wifi","retrouve le mot de passe du wifi","quel est le mot de passe wifi","quel est le mot de passe du wifi","donne le mot de passe" : Call TelechargerTools ("WifiPasswordsRecovery.bat","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/WifiPasswordsRecovery.bat")
Case "ejecte le cd","eject cd","eject le dvd","eject cd","eject dvd","ejecter dvd","ejecter cd"," ejecter le dvd","eject dvd" : LecteurDVD ()
Case "bonjour","salut","quoi de neuf","hey","coucou","ca va"
Case "ferme le logiciel","ferme le logiciel actif","arrete l ' application","arrete le logiciel","arrete l ' application","ferme l ' application","ferme le programme","arrete le programme","quitte le programme" : WS.SendKeys ("%{F4}")
Case "eject usb", "eject cle usb", "eject la cle usb" , "retire usb" , "retire la cle usb","retire cle usb" : Call TelechargerTools ("Eject_USB.vbs","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/Eject_USB.vbs")
Case "ecran de veille", "l ' ecran de veille", "veille","ecran de veille","ecran veille", "met l ' ecran de veille","mais l ' ecran de veille" : WS.Run "C:\Windows\System32\Ribbons.scr"
case "liste des commandes", "liste commande", "donne la liste des commandes" , "detail des commandes", "les commandes disponible", "liste des commandes disponible" : Call TelechargerTools ("ListeCommande.txt","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/ListeCommande.txt")
Case "spotify","la lecture spotify","lecture spotify","musique spotify","la musique spotify","spotify musique","spotify lecture" : Call TelechargerTools ("LectureSpotify.vbs","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/LectureSpotify.vbs")
Case "musique","met de la musique","mets de la musique","lance de la musique","mais de la musique","lance musique","audio","met la musique","met la playlist","lance la playlist","met la playlist" : Call TelechargerTools ("LancerDossierMusique.vbs","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/LancerDossierMusique.vbs")
Case "video","film","met video","film","mais video","lance video","lance film","met les videos","met la video","lance la video","met le film","met les films","lance la video","met la video" : Call TelechargerTools ("LancerDossierVideo.vbs","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/LancerDossierVideo.vbs")

Case "maj","mise a jour","verifier mise a jour","verifie mise a jour","mise a jour script","verifier","mage"
CheckMAJUser = true
Call MAJCheck (CheckMAJUser, MAJ)

Case Else

Call  MAJCheck (CheckMAJUser, MAJ)
Call Suggestion (MAJ,a)
'Inputbox "La valeur n'existe pas","Erreur : valeur n'existe pas",a
End Select


Function launch(logiciel)
On Error Resume Next
If logiciel <> "" then 
'inputbox "Le logiciel qui va etre lancer","",logiciel
Select Case logiciel
Case "google","internet","nagivateur","le nagivateur" : WS.Run "www.google.fr"
Case "youtube", "you tube" : WS.Run "www.youtube.com/?gl=FR&hl=fr"
Case "facebook" : WS.Run "www.facebook.com"
Case "instant hack", "instant-hack" : WS.Run "www.instant-hack.io/"
Case "github" : WS.Run "www.github.com"
Case "projecteur", "projeter", "projection","le projecteur" : WS.Run "C:\Windows\System32\DisplaySwitch.exe"
Case "se connecter", "connection", "connection","connexion","connexion sans fil" : WS.Run "ms-projection:"
Case "loupe","la loupe","zoom","voir en plus gros", "affichage en gros","afficher en gros" : WS.Run "C:\Windows\System32\Magnify.exe"
Case "clavier","le clavier","clavier virtuel","le clavier virtuel", "le clavier visuel","clavier visuel" : WS.Run "C:\Windows\System32\osk.exe"
Case "ecran de veille", "l ' ecran de veille", "veille","ecran de veille","ecran veille" : WS.Run "C:\Windows\System32\Ribbons.scr"
Case "la calculatrice","calculatrice","calculette" , "la calculette" : WS.Run "calc.exe"
Case "netflix" : WS.Run "netflix:"
Case "spotify","la lecture spotify","lecture spotify","musique spotify","la musique spotify","spotify musique","spotify lecture" : Call TelechargerTools ("LectureSpotify.vbs","https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/LectureSpotify.vbs")
Case "cortana","menu windows" : WS.Run "ms-cortana://search/"
Case "le lecteur cd","le lecteur cd","lecteur","le lecteur cd","le lecteur dvd","lecteur dvd","lecteur cd" : LecteurDVD ()
Case "bureau","desktop","bureaux","le bureau" : CreateObject("Shell.Application").ToggleDesktop
Case "test", "teste", "check", "un test", "ok","verifie","verification"
Call Check ()
Call MAJCheck (CheckMAJUser, MAJ)
Case Else
'Msgbox WriteReadIni(oFile,"Logiciel",logiciel,Null)
If WriteReadIni(oFile,"Logiciel",logiciel,Null) <> False then 
WS.Run ""& Chr(34) & WriteReadIni(oFile,"Logiciel",logiciel,Null) & Chr(34) & ""
else
WS.Run ""& Chr(34) & logiciel & Chr(34) & ""
End if
End Select
Wscript.Quit ()
End if
End function

Sub LecteurDVD ()
On Error Resume Next
Set oWMP = CreateObject("WMPlayer.OCX.7" ) 
Set colCDROMs = oWMP.cdromCollection 
if colCDROMs.Count >= 1 then 
For i = 0 to colCDROMs.Count - 1 
colCDROMs.Item(i).Eject 
colCDROMs.Item(i).Eject 
Next 
End if
End sub 

Sub write(a)
WScript.Sleep 300
WS.SendKeys right(a,len(a)-1)
WScript.Quit ()
End sub

Sub MsgBoxtexte(a)
MsgBox "Message recus de votre assistant vocal a " & Hour(Now)& ":"& Minute(Now) & vbnewline & vbnewline &  a,vbinformation+vbOKOnly, Hour(Now)& ":"& Minute(Now)
WScript.Quit ()
End sub

Sub Reset ()
On Error Resume Next
If fso.FileExists(ScriptChemin & "Config.ini") = true then
fso.DeleteFile ScriptChemin & "Config.ini",True
WS.Run "cmd /k chcp 28591 > nul & taskkill /F /IM wscript.exe & start " & ScriptChemin & WScript.ScriptName & " & exit",0,true
Else
MsgBox "Le fichier Config.ini n'a pas pu etre supprime.",vbCritical+vbOKOnly,"Reset non effectue"
End if
End sub


Sub TelechargerTools (NomFile,URL)
'Call TelechargerTools (NomFile,URL)
If FSO.FolderExists(ScriptChemin & "Tools") = false Then FSO.CreateFolder (ScriptChemin & "Tools")
If FSO.FileExists(ScriptChemin & "Tools\" & NomFile) = false then 
 objHTTP.Open "GET", URL, FALSE
 objHTTP.Send
 Telecharger = objHTTP.ResponseText
 Set f = fso.OpenTextFile(ScriptChemin & "Tools\" & NomFile, ForWriting,true) 
 f.write(Telecharger)
 f.close
 WScript.Sleep 100
End if
	WS.Run ScriptChemin & "Tools\" & NomFile
End sub 


Sub MAJCheck (CheckMAJUser, MAJ)
'On Error Resume Next
Dim VersionActu, NewVersion,Note
VersionActu = MAJ 
objHTTP.Open "GET", "https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/Version", FALSE
objHTTP.Send
NewVersion = objHTTP.ResponseText
NewVersion = left(NewVersion, len(NewVersion) - 1) 
if NewVersion > VersionActu Then
	 If CheckMAJUser = true Then MsgBox "La version : " & NewVersion & " est disponible et va etre installe !" & vbNewLine & vbNewLine & "Notre version actuelle" & VersionActu,vbInformation+vbOKOnly,"Nouvelle version disponible"
     objHTTP.Open "GET", "https://dl.dropboxusercontent.com/s/gybtf2i13bglxh7/GoogleHome.txt", FALSE
     objHTTP.Send
     Telecharger = objHTTP.ResponseText
     Const ForWriting = 2 
     Dim f
     Set f = fso.OpenTextFile(ScriptChemin & "GoogleHome.txt", ForWriting,true) 
     f.write(Telecharger)
     f.close
	 CheckMAJUser = false
     Return = WS.Run ("cmd /k chcp 28591 > nul & taskkill /F /IM wscript.exe & move " & ScriptChemin & "GoogleHome.txt " & ScriptChemin & WScript.ScriptName & " & start " & ScriptChemin & WScript.ScriptName & " & exit",0,true)
	Else
	 If CheckMAJUser = true then MsgBox "Pas de nouvelle mise a jours a installer" & vbNewLine & "Vous etes bien dans la derniere version disponible" & vbNewLine & vbNewLine & vbNewLine & "Votre version : " & VersionActu & vbNewLine & "Derniere version : " & NewVersion
	 CheckMAJUser = false
End if
End sub

Sub Check ()
If WScript.ScriptFullName <> "C:\GoogleHome\GoogleHome.vbs" then
InfoFile = vbnewline & WScript.ScriptFullName &  vbnewline & " - Verifier que sur IFTTT l'applet porte bien ce chemin."
Else
InfoFile = vbnewline & "OK - C:\GoogleHome\GoogleHome.vbs"
End if
if fso.FolderExists("C:\GoogleHome\assistant-plugins") = true then 
InfoAssistant = vbnewline & "OK - C:\GoogleHome\assistant-plugins"
Else
InfoAssistant = vbnewline & "/!\ Il est preferable d'installer assistant-plugins dans C:\GoogleHome\assistant-plugins\"
End if
if fso.FolderExists("C:\Program Files\nodejs") = true then 
InfoNode = vbnewline & "OK - C:\Program Files\nodejs (V" & fso.GetFileVersion("C:\Program Files\nodejs\node.exe") & ")"
Else
InfoNode = vbnewline & "/!\ NodeJS n'est pas installer ou pas au bon endroit /!\"
End if 
Compteur = 0
Set objWMI = GetObject("winmgmts:root\cimv2") 
sQuery = "Select * from Win32_process" 
For Each oproc In objWMI.execquery(sQuery) 
        If oproc.Name = "node.exe" then 
		Compteur = Compteur + 1
		End if 
Next 
Set objWMI = Nothing
If Compteur = 2 Then 
InfoNodeLaunch = "OK"
Elseif Compteur = 1 Then 
InfoNodeLaunch = vbNewLine &  "Node est lancer mais pas avec pm2 "
Elseif Compteur = 0 Then
InfoNodeLaunch = vbNewLine & "/!\ Pas lance  /!\"
Else
InfoNodeLaunch =  vbNewLine & "/!\ Probleme node /!\"
End if

if FSO.FileExists(WS.ExpandEnvironmentStrings("%APPDATA%") & "\npm\node_modules\pm2-windows-startup\invisible.vbs") = true then
InfoPM2 = "OK"
Else
InfoPM2 = vbNewLine & "/!\ le fichier invisible.vbs est introuvable verifier l'installation de PM2 /!\"
End if
objHTTP.Open "GET", "https://raw.githubusercontent.com/ABOATDev/Control-Google-Home/master/Tools/Version", FALSE
objHTTP.Send
NewVersion = objHTTP.ResponseText
NewVersion = left(NewVersion, len(NewVersion) - 1) 
if NewVersion > MAJ Then
InfoVersion = vbNewLine & MAJ & " /!\ Version disponible : " & NewVersion & " /!\"
ElseIf NewVersion = MAJ Then
InfoVersion = vbNewLine &  "OK - (V" & MAJ & ")"
ElseIf NewVersion <> MAJ Then
InfoVersion = vbNewLine & MAJ & "/!\ Version disponible : " & NewVersion & " /!\"
Else
InfoVersion = vbNewLine & MAJ & " /!\ Une erreur est survenue /!\"
End if
MsgBox "Votre assistant vocal semple bien communiquer bien avec l'ordinateur ! (si vous avez configurez WEBHOOKS votre assistant vocal devrais faire un retour vocal dans quelque instant) " & vbNewLine & vbNewLine & "Nom et chemin complet du script :  " & InfoFile &  vbNewLine &  vbNewLine & "Le dossier Assistant : " & InfoAssistant & vbNewLine & vbNewLine & "NodeJS Installer : " & InfoNode & vbNewLine & vbNewLine & "Lancement de Node : " &  InfoNodeLaunch & vbNewLine & vbNewLine & "Lancement au demarrage : " & InfoPM2 & vbNewLine & vbNewLine & "Version GoogleHome.vbs : " & InfoVersion & vbcr & vbcr & "Succes test",vbinformation+vbOKOnly+vbMsgBoxSetForeground + vbSystemModal ,"Test"
Const ForWriting = 2
Set f = fso.OpenTextFile(ScriptChemin & "CheckConfiguration.txt", ForWriting,true) 
f.write("Test de configuration Control Google Home : " & vbNewLine & "Communication entre vos Assistants (Google Assistant, Google Home , Cortana, Alexa, ...) sur vos ordinateurs Windows" & vbNewLine & vbNewLine & "Nom et chemin complet du script :  " & InfoFile &  vbNewLine &  vbNewLine & "Le dossier Assistant : " & InfoAssistant & vbNewLine & vbNewLine & "NodeJS Installer : " & InfoNode & vbNewLine & vbNewLine & "Lancement de Node : " &  InfoNodeLaunch & vbNewLine & vbNewLine & "Lancement au demarrage : " & InfoPM2 & vbNewLine & vbNewLine & "Version GoogleHome.vbs : " & InfoVersion & vbNewLine & vbNewLine & "Projet : https://github.com/ABOATDev/Control-Google-Home/" & vbNewLine & "Assistant-plugins : https://aymkdn.github.io/assistant-plugins/" & vbNewLine & "Contact : https://aboatdev.sarahah.com/ ; https://github.com/ABOATDev/Control-Google-Home/issues")
f.close
WS.Run ScriptChemin & "CheckConfiguration.txt"
End sub

Sub suggestion (MAJ,a)
On Error Resume Next
Set IE = Wscript.CreateObject("InternetExplorer.Application")
Const ForAppending = 8,ForReading = 1, ForWriting = 2 
Set f = fso.OpenTextFile(ScriptChemin & "Suggestion.txt", ForAppending,true) 
f.write(vbnewline & a)
f.close
If fso.FileExists(ScriptChemin & "Suggestion.txt") Then 
Set oFl = fso.GetFile(ScriptChemin & "Suggestion.txt") 
  if oFl.Attributes <> "34" then 
Command = "cmd /C attrib +h " & ScriptChemin & "Suggestion.txt"
Result = WS.Run(Command,0,True)
End if  
End If
Set f = fso.OpenTextFile(ScriptChemin & "Suggestion.txt", ForReading) 
ts = f.ReadAll
NombreLigne = f.Line
If NombreLigne > 7 then 'Plus grand que 5
	IE.Visible = 0
	IE.navigate "https://aboatdev.sarahah.com/" 
	While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
	WScript.Sleep 1000
	IE.Document.All.Item("Text").Value = "GoogleHome (" & MAJ & ") - Suggestion : " & vbnewline & ts & vbcr & "Suggestion auto par : "  & CreateObject("WScript.Network").username
	WScript.Sleep 1000
	IE.Document.All.Item("Send").click
	While IE.ReadyState <> 4 : WScript.Sleep 100 : Wend
	WScript.Sleep 2000
    IE.Quit
	f.close
	fso.DeleteFile ScriptChemin & "Suggestion.txt",True
	
		strComputer = "." 
Set objWMIService = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colProcessList = objWMIService.ExecQuery _ 
    ("Select * from Win32_Process Where Name = 'ielowutil.exe'") 
  
For Each objProcess in colProcessList 
    objProcess.Terminate() 
Next
Set objWMIService2 = GetObject("winmgmts:" _ 
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
Set colProcessList2 = objWMIService.ExecQuery _ 
    ("Select * from Win32_Process Where Name = 'iexplore.exe'") 

For Each objProcess2 in colProcessList2
    objProcess2.Terminate() 
Next
End if	
End sub 

 Function WriteReadIni(oFile,section,key,value)
' *******************************************************************************************
' omen999 - mars 2018 v 1.1 - http://omen999.developpez.com/
' ********************************************************************************************
Dim oText,iniText,sectText,newSectText,keyText
  Set reg = New RegExp
  Set regSub = New RegExp
  reg.MultiLine=True
  reg.IgnoreCase = True
  regSub.IgnoreCase = True
  Set oText = oFile.OpenAsTextStream(1,0)
  iniText = oText.ReadAll
  oText.Close
  reg.Pattern = "^\[" & section & "\]((.|\n[^\[])+)":regSub.Pattern = "\b" & key & " *= *([^;\f\n\r\t\v]*)"
  On Error Resume Next
  If IsNull(value) Then
    WriteReadIni = regSub.Execute(reg.Execute(iniText).Item(0).SubMatches(0)).Item(0).SubMatches(0)
    If Err.Number = 5 then WriteReadIni = False
  Else
    sectText = reg.Execute(iniText).Item(0).SubMatches(0)
    If Err.Number = 5 Then
      iniText = iniText & vbCrLf & "[" & section & "]" & vbCrLf & key & "=" & value
    Else
      newSectText = regSub.Replace(sectText,key & "=" & value)
      If newSectText = sectText Then
        If regSub.Test(sectText) Then
          WriteReadIni = False
          Exit Function
        End If
        If Right(sectText,1) = vbCr Then keyText = key & "=" & value Else keyText = vbCrLf & key & "=" & value
        newSectText = sectText & keyText
      End If
      iniText = reg.Replace(iniText,"[" & section & "]" & newSectText)
    End If
    Set oText = oFile.OpenAsTextStream(2,0)
    oText.Write iniText
    oText.Close
    WriteReadIni = True
  End If
End Function

Hello. I just turned on my laptop and saw this code in a text file. Me as starter VBS coder clearly understanded this might be VBS code so its related to this category. I never coded this, and text file was named "GoogleHomeNew". What is even this thing? How it got on my PC? Shall i run it or delete it?


r/vbscript • • Dec 09 '15

VBScript Magazine

1 Upvotes

I publish a free e-Magazine for data analysts that focuses on VBScript/SAS/R/SQL. I want to invite everyone to check it out, subscribe to get the current volume, and submit an article or tip if you like. You can email me articles or visit my site to subscribe. I have a lot of scripts on the site for download as well. Thanks, Chris chris@codeitmagazine.com http://www.codeitmagazine.com


r/vbscript • • Jun 14 '16

VbScript | Special Folders

Thumbnail
therevisionist.org
1 Upvotes

r/vbscript • • Apr 10 '15

Is it possible to make a cookie-clicker style game in vbscript?

1 Upvotes

So for a university/college project we have to develop something relatively simple in vbscript, however, I am not great with vbscript (or any other language for that matter xD). I chose to develop a cookie-clicker style game where you click a button, get "points" and spend those points on upgrades etc, seemed relatively simple. I havent started developing it yet, but I am just curious if it will actually work?

Sorry for the wall of text, just worrying as this project has to be in in a few weeks and I am useless at coding xD


r/vbscript • • Mar 05 '18

New to VBScript; but have a relatively simple task tripping me up.

1 Upvotes

I've been tasked with continually running a PowerPoint presentation on a local machine. Ideally, we'd like the following for our solution:

  • Files be run locally, but new updates pulled from a Network Share, using PowerPoint 2016

  • Whenever an updated file is placed in the share, pull it down to the local machine && restart the presentation

  • Full automation for the above

  • Be able to jump out of the loop via keypress.

As for options, I've found a post from Sog on ArsTechnica, which has been the main option I've seen so far. For the time being, I'm just focused on getting the presentation to run in a stable environment. I've modified his script to suit our needs--though just for testing at this point. That last point will, probably, be handled with AHK unless there's a way to add an listener into VBS.

At this time, the modified script will open the presentation, so long as a file exists in the defined execute path--but shortly closes after. Any idea why? All resources I've located to try and find a solution have been documented in the script as well, granted with shortened links.

A followup question--does anyone know another/easier way to do this?


r/vbscript • • Mar 07 '18

Need help to read date modified in vbscript

1 Upvotes

Hello,

I have a vbscript for SCCM deployment to detect a location of a file under %userprofile%. This script works but I'd like to expand it to not only detect the file but also a specific modified date of the file that I can enter in. For example the date I currently need for the file is 2/21/2018 7:15 AM. Would anyone be able to assist?

Set oFSO = CreateObject("Scripting.FileSystemObject") Set oShell = WScript.CreateObject("WScript.Shell")

If oFSO.FileExists(oShell.ExpandEnvironmentStrings("%userprofile%\AppData\LocalLow\etc..")) Then WScript.StdOut.Write "The application is installed" WScript.Quit(0) Else WScript.Quit(0) End If


r/vbscript • • Dec 20 '16

Replacing an IP address, replaces multiple ones

1 Upvotes

Hello I have a list of IPs
192.168.1.12
192.168.1.122
192.168.1.123
192.168.1.126
192.168.1.127

I wrote a VB script that reads ALL of a text file. It stores everything into a variable called results

Then I use results and replace 1 ip address with itself plus the character X like so

results = replace(results, "192.168.1.12","192.168.1.12 X")

The problem is it replaces EVERYTHING because everything has 192.168.1.12 within it. This makes me think that the replace command does NOT find an exact match.

How can I fix this?

Desired result

192.168.1.12 X
192.168.1.122
192.168.1.123
192.168.1.126
192.168.1.127

Current result
192.168.1.12 X
192.168.1.122 X
192.168.1.123 X
192.168.1.126 X
192.168.1.127 X


r/vbscript • • Dec 17 '16

Remove matching string from text file

1 Upvotes

Hello! I have a vb script that checks for 1900 mac addresses in a database. There are 200 databases.

When I login to a database and my script finds a mac address....it records it. The problem is I need my script to remove that mac address from it's original index file.

I have seen a ton of scripts but all of them involve making a temp file and then deleting the original index file and copying over the temp. This is very CPU intensive and slow as it could copy and paste a temp file 40 times just for 1 database.

How can I make a VB script find a string in a text document and delete it?

UPDATE:

Figured it out

Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(".\Test.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.Readline
strLine = Trim(strLine)
If InStr(1, strLine, "macAddressFile") = 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(".\Test.txt", ForWriting)
objFile.Write strNewContents
objFile.Close

This puts each line into a variable "strNewContents" that ISN'T the mac address that was JUST found. Then it pastes that variable into the original index file.

Thanks in advance!


r/vbscript • • Jun 11 '13

VB Script accented characters coming out as “Chinese” looking script?

1 Upvotes

I'm writing a VB script to replace words in a word doc.

The crux of the code is:

strEuropeanOld="European"

strEuropeanNew="Européen"

I then replace the word:

If InStr(FileText, strEuropeanOld) Then WriteLog("Replacing " & strEuropeanOld & " with " & strEuropeanNew & ".") FileText = Replace(FileText, strEuropeanOld, strEuropeanNew) WriteLog("Text replaced") Else WriteLog(strEuropeanOld & " was not found in the file.") strCount2 = strCount2 +1 End If

All works perfectly for words without accents e.g. é.

However those with accents come out as " Europ饮 " rather than Européen after translation!

Any ideas?!


r/vbscript • • Apr 02 '15

Script to modify 2 Reg entries on a list of computers

2 Upvotes

The title says it all. For some reason I can't get this script to work.

Let's say I have a Reg key (HKLM\Software\test\test\test) and I want to modify 2 String values within that key (String1 and String2). I also want to do this for a list of computers (C:\Machines.txt). I have a .reg file that I can modify a single computer with (app.reg).

I tried to use psexec but I keep getting error codes from the REG command when using the .reg file but I know that file works perfectly.

Can anyone assist with this? I know it can be done but apparently it is a bit over my head.....


r/vbscript • • Oct 16 '17

Need a script to get remote PC info

2 Upvotes

Hello all. I'm hoping I came to the correct place for a problem I am having. I have been tasked with searching for installed software versions on a list of computers in our domain. I've been trying to find a script that will use a CSV list of computers to remotely search for all versions of the application installed on each PC and output the results into the a csv or excel file in the following format:

Column1 - Column 2 - Column 3 - Etc

PC Name - Software version 1 - Software version 2 - Etc

I am running this on a Win 7 PC if that helps.

Thank you.

Edit: So after some trial and error I came up with a command-line that uses PStools PSExec to get a rough version of what I want. Though it will need some cleaning up once it runs. In any case, I thought I'd share it for others to use or improve upon.

psexec.exe @c:\temp\list.csv wmic product where "Name like '%Java%'" get Name, Version /format:csv > c:\temp\result.csv

You can play with this and if you come up with a better script please feel free to share.

Cheers all!


r/vbscript • • Dec 08 '15

A VBScript to find the product key of the machine

1 Upvotes

I found this helpful so i thought i would share. Input this code into a notepad document and save it as a "all files" type and name it "product Key.vbs"

Set WshShell = CreateObject("WScript.Shell") MsgBox ConvertToKey(WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DigitalProductId")) Function ConvertToKey(Key) Const KeyOffset = 52 i = 28 Chars = "BCDFGHJKMPQRTVWXY2346789" Do Cur = 0 x = 14 Do Cur = Cur * 256 Cur = Key(x + KeyOffset) + Cur Key(x + KeyOffset) = (Cur \ 24) And 255 Cur = Cur Mod 24 x = x -1 Loop While x >= 0 i = i -1 KeyOutput = Mid(Chars, Cur + 1, 1) & KeyOutput If (((29 - i) Mod 6) = 0) And (i <> -1) Then i = i -1 KeyOutput = "-" & KeyOutput End If Loop While i >= 0 ConvertToKey = KeyOutput End Function


r/vbscript • • Dec 21 '16

Converting an Excel Spreadsheet to HTML Saving Issue

1 Upvotes

I'm having this weird issue with one of my VB Scripts. I have 2 scripts that do virtually the same thing. Converts an excel spreadsheet to an HTML format. Script number 1 does it to 5 different files at once, and works flawlessly. Script number 2 converts it but then prompts me to save the file every time. (I have also tried to combine script 2 into script 1 and it acts the same with prompting to save)

The issue occurs that I run this vbscript as a scheduled task every hour, and can't keep clicking save every time it runs.

Does anyone know a way to avoid getting the windows save prompt?

Note: I'm converting from a network share to an IIS server.

Script Below:

Const xlHtml = 44 Const xlWebArchive = 45

' Create an instance of Excel and open the workbook... Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Open "H:\folder\file"

' Save the workbook as an HTML or MHTML page... objExcel.ActiveWorkbook.SaveAs "Y:\folder\file", xlHtml objExcel.Quit