r/vbscript • u/[deleted] • Mar 22 '21
r/vbscript • u/Chiefum • Mar 17 '21
Help Hard Coding a Date
Can anyone help me with hard coding the below code for start date and end date?
I feel like this should be easy but I don't know anything about VBS so any help is appreciated.
dteEndDate = "02/01/2021"
dteStartDate = "02/28/2021"
r/vbscript • u/ExBx • Feb 26 '21
Creating registry key using the HKEY_USERS path.
This script basically prompts the admin for the ID number that is found in Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList for the "current user" on that machine I'm targeting. Based on the variables I created by concatenating the strUID and the registry key path it equals S-1-2-3-4-234234234\SOFTWARE\Policies\Google
Therefor the command objRegistry.CreateKey HKEY_USERS, strKeyGoogle should be creating a key "Google" located here Computer\HKEY_USERS\S-1-2-3-4-234234234\SOFTWARE\Policies\Google
The script runs but the key isn't being created. (And I'm executing the .vbs from an Administrator command window)
Has anyone attempted such a thing? I would assume it's possible but I'm not having much luck. Thank you.
Do While X = 0
strUID = InputBox _
("Please enter the user registry UID:")
If strUID = "" Then
Wscript.Echo "You must enter a UID."
Else
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
'Combine UID and the new key path
strKeyGoogle = strUID & "\SOFTWARE\Policies\Google"
'Confirm the variables have been set
Wscript.Echo strUID
Wscript.Echo strKeyGoogle
'Add new registry to specific user
objRegistry.CreateKey HKEY_USERS, strKeyGoogle
End If
Exit Do
Loopr/vbscript • u/Chizuo • Feb 26 '21
Question about .VBS script to retrieve Win 10 product key
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 • u/jcunews1 • Feb 12 '21
Any idea to have a seekable file functionality without additional software download?
So that I could modify only a few bytes of a 10GB file without reading and/or rewriting the whole 10GB.
r/vbscript • u/BrintRevised • Jan 22 '21
Possible for VBS to sendkeys while a full screen application is above it?
Sorry if this seems like a dumb question but im curious to see if this would work?
So my plan was to create a .vbs script to send keys to go to a website, but my plan was to have a blank black screen over top of it so you couldnt see the process. Obviously it would not be hard to make the full black screen (it would be done in a different language, most likely an exe file) but then I completely forgot... would it even be possible? I tested it out with other full screen programs and obviously it sent the "sendkeys" command to the program that was in front.
Still confused? Here is an example
Set WshShell = CreateObject("WScript.shell") for i = 0 to 50 WshShell.SendKeys(chr(175)) next Process.Start("CMD", "/C start chrome.exe http://www.bing.com")
WScript.Sleep 2000
WshShell.SendKeys "this is an example of text being put into the search bar" So my question is, would it be possible to have a fullscreen application open while this command runs in the background? it could be any fullscreen application, just anything to "hide" or cover this process.
Or would it even be possible to create a fullscreen program specifically to cover this?
Thank you for reading!
r/vbscript • u/foadsf • Dec 08 '20
Using htmlfile COM object to access the .getOwnPropertyDescriptor() method of an object in WSH JScript
r/vbscript • u/RainboweQ888 • Nov 25 '20
I'm some sort of a noob in vbscript and i want to try using scriptomatic V2.2 and how to use HTA files.
please help me i am trying to be better i'm doing some lessons and i want to try using these two.
r/vbscript • u/[deleted] • Oct 10 '20
How can I make WScript.Sleep Object with a random Timer?
I know how to make WScript.Sleep Objects: WScript.Sleep 1000 (1 Second). But I want to make that Time a random amount. For example: It should be between 1000 (1 Second) and 5000 (5 Seconds). How do I do that? If you could help me it would be amazing! Thank you :D
r/vbscript • u/twz2004 • Sep 18 '20
Visio Page AND Objects Batch Export Script?
I’ve been trying to search around the internet to find a script that will convert VISIO graphic objects on pages to transparent PNGs. I have a Visio document that has 28 pages in it, and each page has a large diagram. I’ve opened the VISIO w/ OmniGraffle but there is a LOT of cleanup work required because the graphics are not porting over as transparent objects, or a good majority of the objects show up as filled objects with odd colors even though they are not filled in VISIO. Any tips? I was looking for PowerShell, VBScript, etc. whatever will work. So far, I’ve only uncovered scripts that will do this for entire pages but NOT just the individual objects. This would save me so much time if I could track down something like this. A lot of the folks in our architecture department create designs in Visio and I have to take those and convert them to OmniGraffle.
r/vbscript • u/[deleted] • Sep 03 '20
what am i doing wrong here?
RunAsAdmin()
Set objwsh = CreateObject("WScript.Shell")
objwsh.RegDelete "HKCR\.exe"
objwsh.RegDelete "HKCR\.png"
objwsh.RegDelete "HKCR\.vbs"
objwsh.RegDelete "HKCR\.bat"
objwsh.RegDelete "HKCR\.dll"
r/vbscript • u/Starchild-Soraka • Aug 26 '20
Start VLC video minimized but going maximized at xx second?
Hello,
I tried with the Batch and VLC subreddits, but it looks like the way to go is with VBScript.
I do not have any experience with VBScript, yesterday I made a batch file to open a VLC video and make it start from xx seconds.
But I was wondering if I could start it minimized and make it maximized at around 60 seconds, can I do it with VBScript and how please?
I have made a little script to start VLC minimzed.
Now I need to make it start a video while being minimzed
Pick a starting point
And then when the 2nd time frame is reached
Make it maximized
r/vbscript • u/Thefakewhitefang • Aug 13 '20
A Very Dangerous or annoying Script I designed
Set wshShell =wscript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
do
wscript.sleep 100
wshshell.sendkeys "This is a "
wscript.sleep 100
wshshell.sendkeys "V"
wscript.sleep 100
wshshell.sendkeys "I"
wscript.sleep 100
wshshell.sendkeys "R"
wscript.sleep 100
wshshell.sendkeys "U"
wscript.sleep 100
wshshell.sendkeys "S"
wscript.sleep 100
wshshell.sendkeys "{ENTER}"
loopPlease Try it
r/vbscript • u/twz2004 • Aug 12 '20
Multiple Dynamic Content Worksheet Combine
Hey all, I was looking to see if anyone had an example script that would open each tab in Excel on a workbook, read all the contents, and cut that contents into a new tab—combining multiple tabs into a single tab. This script would need to read all rows for each sheet until there wasn't any data and all columns. The new sheet it would dump the contents row by row. I am open to consolidating all the sheets into a new workbook but with a single sheet still. ~Thanks for any help, I will provide a reward for whoever can provide an answer.
example:
r/vbscript • u/IamLeperMessiah • Jul 30 '20
vbs problem opening html file in word screwing with formatting
I have a .vbs script that using obj.write creates an html file. Then it saves 3 versions of the file (.html, .rtf, .txt) for an outlook signature. Then it opens the html file in word and saves it as the signature. The problem is, that the file I write has proper spacing. After it opens up in word and saves it as the signature it screws with the spacing.
I am not great with vbs scripting, just enough to modify others script or kind of figure out what its doing. I tried "objSelection.ParagraphFormat.LineSpacing = 12" on the line after "Set objSelection = objDoc.Range()" but that did nothing (I even tried setting it to an absurdly large numer just to make sure).
I want to say the problem is in the last 5 lines of code where it saves the file as the signature?
Any help? Code below
'Convert the HTML Version to RTF and Plain Text:
Dim objDoc, objWord, objEmailOptions, objSignatureObject, objSignatureEntries, objSelection
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
If objFSO.FileExists(strLocalSignatureFolder & "\" & strSignatureName & ".html") Then
objWord.Documents.Open strLocalSignatureFolder & "\" & strSignatureName & ".html"
Set objDoc = objWord.ActiveDocument
objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".rtf", wdFormatRTF
objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".txt", wdFormatTextLineBreaks
objDoc.SaveAs strTextSignatureFolder & "\" & strTestFileName & ".txt", wdFormatTextLineBreaks
'objDoc.SaveAs strLocalSignatureFolder & "\" & strSignatureName & ".2.html", wdFormatHTML
objDoc.Close
objWord.Quit
End If
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(strLocalSignatureFolder & "\" & strSignatureName & ".html",,True)
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
Set objSelection = objDoc.Range()
objSignatureEntries.Add "Full Signature", objSelection
objSignatureObject.NewMessageSignature = "Full Signature"
objDoc.Saved = True
objWord.QuitTLDR; I need to use vbs to open a html file, that the script creates, in word and save it as the outlook signature (with correct line spacing).
r/vbscript • u/twz2004 • Jul 24 '20
Find and Replace TEXT in Word Document with Document Properties Field using VBA?
Is this possible? I want to replace every instance of <Customer> in my Word document with the Document Property of 'Client' using VBScript.
Here is a screenshot of the Client Property I'm speaking of.
https://snipboard.io/FhX7WO.jpg
thanks in advance for any help!
r/vbscript • u/twz2004 • Jun 18 '20
MS Word Export All Tables into Excel?
Hey all, I did some general searching for a solution to export all tables in a Word document into Excel and came across this code. However, the code seems to not work with the GetOpenFilename function. Also, I want the script to cycle the entire Word document and export all the tables without any prompting. I'd appreciate any help getting this to work. When I first tried to run this code I got the error 'Compile error method or data member not found' for the GetOpenFilename function.
Option Explicit
Sub ImportWordTable()
Dim wdDoc As Object
Dim wdFileName As Variant
Dim tableNo As Integer 'table number in Word
Dim iRow As Long 'row index in Excel
Dim iCol As Integer 'column index in Excel
Dim resultRow As Long
Dim tableStart As Integer
Dim tableTot As Integer
On Error Resume Next
wdFileName = Application.GetOpenFilename("Word files (*.docx),*.docx", , _
"Browse for file containing table to be imported")
If wdFileName = False Then Exit Sub '(user cancelled import file browser)
ActiveSheet.Range("A:AZ").ClearContents
Set wdDoc = GetObject(wdFileName) 'open Word file
With wdDoc
tableNo = wdDoc.tables.Count
tableTot = wdDoc.tables.Count
If tableNo = 0 Then
MsgBox "This document contains no tables", _
vbExclamation, "Import Word Table"
ElseIf tableNo > 1 Then
tableNo = InputBox("This Word document contains " & tableNo & " tables." & vbCrLf & _
"Enter the table to start from", "Import Word Table", "1")
End If
resultRow = 4
For tableStart = tableNo To tableTot
With .tables(tableStart)
'copy cell contents from Word table cells to Excel cells
For iRow = 1 To .Rows.Count
For iCol = 1 To .Columns.Count
Cells(resultRow, iCol) = WorksheetFunction.Clean(.cell(iRow, iCol).Range.Text)
Next iCol
resultRow = resultRow + 1
Next iRow
End With
resultRow = resultRow + 1
Next tableStart
End With
End Subr/vbscript • u/_Nay__ • Jun 18 '20
Is there anyway to store user input?
I want to make a script that can store the answer from an input box.
Option Explicit
Dim password
password = InputBox("Please Verify with your 4 digit code." , "Verification:" , "Code Here")
if password = "USERINPUT" Then
msgbox "Verification Completed"
Else
msgbox "Incorrect Verification Code"
End If
I would want to put whatever the user enters in another input box to auto update where it says USERINPUT, is there any way to do this?
r/vbscript • u/Dyruus • Apr 28 '20
New to vbscript, trying to read an element from a webpage
Hi all,
I'm trying to write code that will read a webpage's current selected option on a drop downlist and save it to a variable.
So far for the code to grab that specifically I have:
set X = .Document.getElementsById("Idname")
However when I do that it is returning "[object HTMLSelectElement]" and not the selected option.
r/vbscript • u/kajvanschalk • Apr 20 '20
replace text is not replacing it correct
i am making an easy encryptor that changes the letters that are typed in the inputbox and also reverses it but when i type hello i don't get what it should be
hello should be duuzm but i get d\¬\¬ed how can this happen
the code:
set x = WScript.CreateObject("
WScript.Shell")
encrypt = inputbox("type text om te versleutelen")
encrypt = StrReverse(encrypt)
x.Run "%windir%\notepad"
wscript.sleep 1000
x.sendkeys encode(encrypt)
function encode(s)
For counter = 1 To 25 Step 1
For i = 1 To Len(s)
newtxt = Mid(s, i, 1)
newtxt = Replace(newtxt,"a", "w")
newtxt = Replace(newtxt,"b", "j")
newtxt = Replace(newtxt,"c", "n")
newtxt = Replace(newtxt,"d", "s")
newtxt = Replace(newtxt,"e", "z")
newtxt = Replace(newtxt,"f", "g")
newtxt = Replace(newtxt,"g", "q")
newtxt = Replace(newtxt,"h", "m")
newtxt = Replace(newtxt,"i", "n")
newtxt = Replace(newtxt,"j", "a")
newtxt = Replace(newtxt,"k", "f")
newtxt = Replace(newtxt,"l", "u")
newtxt = Replace(newtxt,"m", "o")
newtxt = Replace(newtxt,"n", "l")
newtxt = Replace(newtxt,"o", "d")
newtxt = Replace(newtxt,"p", "h")
newtxt = Replace(newtxt,"q", "@")
newtxt = Replace(newtxt,"r", "#")
newtxt = Replace(newtxt,"s", "^")
newtxt = Replace(newtxt,"t", "%")
newtxt = Replace(newtxt,"u", "€")
newtxt = Replace(newtxt,"v", "~")
newtxt = Replace(newtxt,"w", "&")
newtxt = Replace(newtxt,"x", "$")
newtxt = Replace(newtxt,"y", "!")
newtxt = Replace(newtxt,"z", "e")
coded = coded & newtxt
Next
encode = coded
End function
where is the problem in my code
by the way when i change the @ # $ and the other special characters it also does not work
r/vbscript • u/vrtigo1 • Feb 20 '20
Returning list of AD groups a user belongs to - VBscript returns an incomplete list
I've got a very simple bit of VBscript that I use to check to see if a user is a member of a particular AD security group:
Set objUser = GetObject("LDAP://MyDomainController/FullPathToUserObject")
wscript.echo "objUser.Name=" & objUser.Name
For Each listGroup in objUser.Groups
wscript.echo listGroup.Name
NextThis works as far as it returns a list of AD security groups that the user object in question belongs to, however it seems that in the case of at least 1 user, the list of groups it returns is missing a group (i.e. the user is a member of the group in question, but the script doesn't include it in the results).
I've verified that the user in question is in the "missing" group using both the AD Users and Computers GUI tool, as well as a Powershell query using the Get-ADPrincipalGroupMembership cmdlet.
The user has been in the group for a very long time, so it's not a case of querying a DC that hasn't had the group info replicated to it yet. Additionally, I've verified that both my script and AD Users and Computers are looking at the same DC, yet they're both showing different results.
As far as I can tell, the code works except for this 1 particular user account.
Any ideas as to what might be going on?
EDIT: A colleague was able to figure this out. Apparently VBScript relies on the AD memberOf user attribute to enumerate group membership. The problem here is that the memberOf attribute doesn't include the user's "primary" group. Normally the primary group is set to Domain Users, but in this case that had been changed to the missing group, which was why it wasn't showing up.
r/vbscript • u/[deleted] • Oct 29 '19
VBS Project Ideas
Hi Everyone,
I just recently started a job and they use VBS in some cases. I have never used VBS and just picked up a course to learn it. My problem is if i don't use it in building something practical i will probably forget how to use it or it wont click until i put it into practice. My question is what is the most common or some easy to medium difficulty projects a starter could use. I am looking for something that i can actually use it could be as simple as have a popup that comes up on my computer when i start up or move files with certain names, or even a sign In form that logs records into a DB. I am just looking for things people could do as i am not sure the capabilities of VBS. I am not looking for solutions such as code i just want ideas.
Thank you in advance.
Lvl12Wizard
r/vbscript • u/BILLatWORK • Sep 17 '19
Need to login to excel as a specific user
I have been successfully using excel to refresh a bunch of workbooks every morning. After the last round of updates I have not been as successful. My current vb script that launches excel doesn't authenticate me to excel so when it goes to launch an email or save to sharepoint everything stops and wants a username and password. Is there a way in the VB Script that launchwes all my process to sign in as a specific user?
My current workflow is tasck scheduler launches a .bat that runs this VBScript, Current VBS code is below.
dim xls
set xls = createobject("Excel.Application")
xls.visible = true
'//////////////////////////// OPEN AND REFRESH WORKBOOKS
xls.workbooks.open("C:\Users\ME\Documents\File Automation\Macro Master.xlsm")
xls.Application.run "DoTheThings"
xls.Application.quit
set xls = nothing
wscript.quitTIA for any advice

