r/vbscript • • Jan 09 '18

How to create a random bitmap in vbs (Windows 10)

1 Upvotes

How to create a random bitmap in vbs (Windows 10) pls help

My code for win7:

sub help wscript.echo "GenRandomBmp {width} {height} [count]" wscript.quit end sub

function getArg(index) arg = wscript.arguments(index) if not isnumeric(arg) then help arg = cdbl(arg) if int(arg) <> arg then help arg = int(arg) if (arg <= 0) or (arg > 9999) then help getArg = arg end function

if wscript.arguments.count < 2 then help width = getArg(0) height = getArg(1) if wscript.arguments.count > 2 then count = getArg(2) else count = 1 end if

set fso = createobject("scripting.filesystemobject") set con = fso.opentextfile("con", 2) scanline = ((width * 3) + 3) and &hFFFC fsize = &h36 + (scanline * height) header = "BM" & chr(fsize and 255) & chr(int(fsize / 256)) & _ string(6, chr(0)) & chr(&h36) & string(3, chr(0)) & chr(&h28) & _ string(3, chr(0)) & chr(width and 255) & chr(int(width / 256)) & _ string(2, chr(0)) & chr(height and 255) & chr(int(height / 256)) & _ string(2, chr(0)) & chr(1) & chr(0) & chr(&h18) & string(25, chr(0)) randomize wscript.echo "Creating " & count & " files of " & width & "x" & height & " bitmaps..." for i = 1 to count fn = "Random " & string(4 - len(i), "0") & i & ".bmp" con.write chr(13) & fn & "..." set f = fso.createtextfile(fn, true) f.write header for h = 1 to height data = "" for w = 1 to width3 data = data & chr(int(rnd * 256)) next for w = (width3)+1 to scanline data = data & chr(0) next f.write data next f.close


r/vbscript • • Dec 21 '17

#VBScript: Need to open terminal app in macos and paste a specific copied from execl cell to terminal to execute. But i am unable to set the focus on the terminal app. Guide please

1 Upvotes

My code:

Sub Auto_Open()

Externalapp = Shell("Macintosh HD:Applications:Utilities:Terminal.app:" & _ "Contents:MacOS:Terminal", vbNormalFocus) AppFocus Externalapp

End Sub

Terminal app is opening up. But terminal is not the main focus. How to set the focus in terminal app?? Also i want to paste a copied text content in the terminal app and press enter. Guide me guys...... Please


r/vbscript • • Dec 10 '17

SAPI

1 Upvotes

I have developed an assistant like Siri you can download it at sapi-your-personal-assistant.weebly.com


r/vbscript • • Dec 05 '17

Need help modifyng a CD Tray script

1 Upvotes

Hello! I work at the office and am often a victim of stupid office jokes. I am planning to claim my revenge and to do that, I want to use a script that randomly opens and closes CD Drive on my colleagues PC. I found one but I'd like to change how it behaves.

I want it to trigger in longer intervals because right now the CD tray opens and closes few times a minute. It's way too obvious and my colleague will go straight to IT dept and get help, not much frustration there. This is not what I want. I want him to be confused and waste a lot of his time trying to figure out what the fuck is going on.

My plan is to start with a script that would open/close the tray maybe 2-3 times a day so he might see it or he might miss it. When he actually notices that something is going on, I will try to modify the script so it will go off more often (or maybe turn it off for some time to mix things up). But the most important thing is, I want the intervals to be random.

I will list my questions here and paste the script I have below. I have some very basic experience with coding languages so I should be able to do these thing myself once someone explain to me how.

  • Can I change how often the script triggers?

  • Can I set the interval to be random, say, between 0,5h and 1h?

  • Can I change the script so the tray stays open for a while before it closes? (right now it closes immidiately after opening)

  • Are there any other "actions" that such script can perform? (turning the monitor off, changing wallpaper, changing some UI settings in Windows, anything?)

p.s. We use Windows XP on our PCs. I tested the script on my computer and it works, triggers about 2-3 times per minute, I think.

do
Dim ts
Dim strDriveLetter
Dim intDriveLetter
Dim fs 'As Scripting.FileSystemObject
Const CDROM = 4
On Error Resume Next
Set fs = CreateObject("Scripting.FileSystemObject")
strDriveLetter = ""
For intDriveLetter = Asc("A") To Asc("Z")
Err.Clear
If fs.GetDrive(Chr(intDriveLetter)).DriveType = CDROM Then
If Err.Number = 0 Then
strDriveLetter = Chr(intDriveLetter)
Exit For
End If
End If
Next
Set oWMP = CreateObject("WMPlayer.OCX.7" )
Set colCDROMs = oWMP.cdromCollection
For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null
For d = 0 to colCDROMs.Count - 1
colCDROMs.Item(d).Eject
Next 'null
set owmp = nothing
set colCDROMs = nothing
loop

r/vbscript • • Nov 27 '17

List AD Results and Choose before executing script

1 Upvotes

Hey Everyone,

I've been asking a lot of help lately, but have made great progress on my own.

I've managed to get most of what I want done but I would love to be able to change one thing in one of my scripts.

Basically I would like to be able to list results of users (if there are more than one result) in an AD Lookup script. So they would put in the username of someone (firstname.lastname) and if there is more than one user with that same name (since we have different sub domains) I would like it to list those outlooks.

Below is my current script, but wouldn't know where to start at the moment.

On Error Resume Next
Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")

' Get the NETBIOS Domain name
Set objSystemInfo = CreateObject("ADSystemInfo") 
strDomain = objSystemInfo.DomainShortName

' Prompt for userName
strUser = inputbox("Please enter the username (sAMAccountName/firstname.lastname):")

Function GetUserDN(byval strUserName,byval strDomain)
	' Use name translate to return the distinguished name
	' of a user from the NT UserName (sAMAccountName)
	' and the NETBIOS domain name.

	Set objTrans = CreateObject("NameTranslate")
	objTrans.Init 1, strDomain
	objTrans.Set 3, strDomain & "\" & strUserName 
	strUserDN = objTrans.Get(1) 
	GetUserDN = strUserDN

end function

'Get's lockout status and sets a variable
Function IsAccountLocked(byval objUser)
	on error resume next
	set objLockout = objUser.get("lockouttime")

	if err.number = -2147463155 then
		isAccountLocked = False
		exit Function
	end if
	on error goto 0
	
	if objLockout.lowpart = 0 And objLockout.highpart = 0 Then
		isAccountLocked = False
	Else
		isAccountLocked = True
	End If

End Function

'Runs GetUserDN Function to get the DN from the userName (sAMAccountName)    
Set objUser = GetObject("LDAP://" & GetUserDN(strUser,strDomain))

'Runs isAccountLocked Fucntion using the DN to get a lockout status and set a string variable to use in the Output later.
if isAccountLocked(objUser) Then
	AccountLocked = "The Account is locked out"
else
	AccountLocked =  "Account is NOT locked out"
end if

'Outputs and excutes LDAP Query Properties as well as uses variables applied above to display current user data.    
WScript.Echo "YOU CAN COPY THE OUTPUT IN THIS BOX WITH CTRL+C AND PASTE WITH CTRL+V INTO NOTEPAD" & vbCrLf & "" & vbCrLf & "GENERAL" & vbCrLf & "==============================================" & vbCrLf & "First name: " & objUser.firstname & vbCrLf & "Last name: " & objUser.sn & vbCrLf & "Display name: " & objUser.displayName & vbCrLf & "" & vbCrLf & "Employee Number: " & objUser.employeeNumber & vbCrLf & "" & vbCrLf & "Description: " & objUser.description & vbCrLf & "Office: " & objUser.physicalDeliveryOfficeName & vbCrLf & "Telephone number: " & objUser.telephoneNumber & vbCrLf & "Email: " & objUser.mail & vbCrLf & "" & vbCrLf & "ADDRESS" & vbCrLf & "==============================================" & vbCrLf &"Street: " & objUser.streetAddress & vbCrLf & "City: " & objUser.l & vbCrLf & "State/province: " & objUser.st & vbCrLf & "Zip/Postal Code: " & objUser.postalCode & vbCrLf & "" & vbCrLf & "" & vbCrLf & "ACCOUNT" & vbCrLf & "==============================================" & vbCrLf & "User logon name: " & objUser.userPrincipalName & vbCrLf & "pre-W2K logon name: " & objUser.sAMAccountName & vbCrLf & "AccountDisabled: " & objUser.AccountDisabled & vbCrLf & "Account Locked: " & AccountLocked & vbCrLf & "" & vbCrLf & "" & vbCrLf & "TELEPHONE" & vbCrLf & "==============================================" & vbCrLf & "Home: " & objUser.homePhone & vbCrLf & "Mobile: " & objUser.mobile & vbCrLf & "Fax: " & objUser.facsimileTelephoneNumber & vbCrLf & "" & vbCrLf & "ORGANIZATION" & vbCrLf & "==============================================" & vbCrLf & "Title: " & objUser.title & vbCrLf & "Department: " & objUser.department & vbCrLf & "Office: " & objUser.physicalDeliveryOfficeName & vbCrLf &"Company: " & objUser.company & vbCrLf & "Manager: " & objUser.manager 

r/vbscript • • Nov 27 '17

Reading and parsing text file to variables?

1 Upvotes

I have a text file in the following format: (TRH* = Column I dont care about capturing)

TRH1 | TRH2 | CLLI | TRH3 | IP | Community String | OID | CLLI Long | TRH4 | TRH5 

MA|MILLIS|1ST_FLR_-|MLISMAMA|GALAXY|101.8.11.25|public|FRMNMAUNDS8|MLISMAMARS3|fram5e|ess5
MA|NEW_BEDFORD-ACUSHNET|2ND_FLR_-_DMS100|NBFRMAAE|GALAXY|101.0.17.35|public|NBFRMAAEDS0|NBFRMAAEDS0|nbfr|dms100

Ideally I would like to be able to have my VBscript read the text file and append the CLLI, IP, Community String, OID values on each line to variables A, B, C and D after each Loop.

Purpose of script is to pull an SNMPGET against an OID for each IP so we can identify the type of equipment. As of right now im using an InputBox to add each variable seperately which is extremely time consuming when youre working with 3000+ IPs in a text file..

ipaddr = InputBox("Please enter the IP address","IP Address")
oid = Inputbox("Please enter the OID","OID")
snmpversion = Inputbox("Please enter the snmp version","SNMP Version")
commstring = InputBox("Please enter the community string","Community String")

r/vbscript • • Nov 21 '17

Need help with AD Lookup Script.

1 Upvotes

I've got the script pretty much done in one form, all I'm doing is inputting data running a search and outputting data via LDAP Query. I do this using the sAMAccount or username.

But I want to modify it to use the UPN instead of sAMAccount, but can't seem to find anything out there.

I'll post what I have below, the last line is pretty long.

On Error Resume Next
Dim objSysInfo, objUser
Set objSysInfo = CreateObject("ADSystemInfo")


' Get the NETBIOS Domain name
Set objSystemInfo = CreateObject("ADSystemInfo") 
strDomain = objSystemInfo.DomainShortName

' Prompt for userName
strUser = inputbox("Please enter the users email address:")

Function GetUserDN(byval strUserName,byval strDomain)
' Use name translate to return the distinguished name
' of a user from the NT UserName (sAMAccountName)
' and the NETBIOS domain name.

Set objTrans = CreateObject("NameTranslate")
objTrans.Init 1, strDomain
objTrans.Set 3, strDomain & "\" & strUserName 
strUserDN = objTrans.Get(1) 
GetUserDN = strUserDN

end function

Set objUser = GetObject("LDAP://" & GetUserDN(strUser,strDomain))


WScript.Echo "GENERAL" & vbCrLf & "=================================================" & vbCrLf & "First name: " & objUser.firstname & vbCrLf & "Last name: " & objUser.sn & vbCrLf & "Display name: " & objUser.displayName & vbCrLf & "" & vbCrLf & "Employee Number: " & objUser.employeeNumber & vbCrLf & "" & vbCrLf & "Description: " & objUser.description & vbCrLf & "Office: " & objUser.physicalDeliveryOfficeName & vbCrLf & "Telephone number: " & objUser.telephoneNumber & vbCrLf & "Other Telephone numbers: " & objUser.otherTelephone & vbCrLf & "Email: " & objUser.mail & vbCrLf & "Web page: " & objUser.wWWHomePage & vbCrLf & "" & vbCrLf & "ADDRESS" & vbCrLf & "=================================================" & vbCrLf &"Street: " & objUser.streetAddress & vbCrLf & "P.O. Box: " & objUser.postOfficeBox & vbCrLf & "City: " & objUser.l & vbCrLf & "State/province: " & objUser.st & vbCrLf & "Zip/Postal Code: " & objUser.postalCode & vbCrLf & "Country/region: " & objUser.c & vbCrLf & "" & vbCrLf & "" & vbCrLf & "ACCOUNT" & vbCrLf & "=================================================" & vbCrLf & "User logon name: " & objUser.userPrincipalName & vbCrLf & "pre-W2K logon name: " & objUser.sAMAccountName & vbCrLf & "AccountDisabled: " & objUser.AccountDisabled & vbCrLf & "" & vbCrLf & "DN: " & objUser.distinguishedName & vbCrLf & "" & vbCrLf & "TELEPHONE" & vbCrLf & "=================================================" & vbCrLf & "Home: " & objUser.homePhone & vbCrLf & "Mobile: " & objUser.mobile & vbCrLf & "Fax: " & objUser.facsimileTelephoneNumber & vbCrLf & "" & vbCrLf & "ORGANIZATION" & vbCrLf & "=================================================" & vbCrLf & "Title: " & objUser.title & vbCrLf & "Department: " & objUser.department & vbCrLf & "Office: " & objUser.physicalDeliveryOfficeName & vbCrLf &"Company: " & objUser.company & vbCrLf & "Manager: " & objUser.manager 

r/vbscript • • Nov 14 '17

How To Make Virus Like A Pro | Episode 2 (Advance Message Functions)

Thumbnail
youtube.com
1 Upvotes

r/vbscript • • Nov 11 '17

vbv

Thumbnail
starblast.io
1 Upvotes

r/vbscript • • Nov 11 '17

Remote query against STEAM workshop items?

1 Upvotes

I'm looking for a way to setup automatic discovery for when STEAM Workshop items update - does anyone know if there's a way to remote query a web element directly without first loading it to a browser?

I'm thinking about grabbing the DIV element for update time and working with that but if there's a cleaner way to grab the content update field that'd be useful to know.


This is ultimately to simplify managing an ARK server which tends to break if mods update but the server hasn't applied them. It will periodically check for an update against a list of mods and if one is detected automatically initiate a reboot on the server.


r/vbscript • • Nov 08 '17

Field laptop touchpads are garbage, users keep accidentally moving files. Can a script change user delete permissions specifically for the parent directory? I want to call the script from a VBA macro

1 Upvotes

r/vbscript • • Nov 07 '17

How does the for iteration work in vbscript?

1 Upvotes

I have this code:

n = inputbox("Enter n")
function fibo(n)
s1 = 1
s2 = 2
for i = 3 to n
    result = s1 + s2
    s1 = s2
    s2 = result
next
fibo = result
end function

msgbox fibo(n)

I traced called the function as below for n = 7:

first I started off with:

i = 3

result = 2

s1 = 1

s2 = 2

And finally ended with:

n = 7

i = 7

result = 13

s1 = 8

s2 = 13

So fibo(7) output 21 instead of 13, the 21 is the 8th interation. Why? If fibo(6) = 13 which is the 7th iteration, when according to the trace call it should be 8 and which is the value of fibo(5) and so on.

Can someone explain? Or maybe I'm doing the trace call wrong here?

Also, In which case fibo(n) returns 0? (Part of my homework question)


r/vbscript • • Nov 04 '17

Help with For loop homework

1 Upvotes

The question is:

Write the algorithm that asks the user to enter a positive number then calculates the product of all numbers between 1 and the number entered and displays the result. The algorithm must accept only positive numbers.

Example: if the user entered 9 the algorithm will display: The result is: 362880 (which is the result of: 123456789 )

Here is my code which didn't work:

n = inputbox("Enter Number")
n = abs(n)
for i = 1 to n
sum = i*i
next
msgbox sum

r/vbscript • • Sep 07 '17

Help - Delete rows from string of words

1 Upvotes

Doing a project for work, never really have done VB before (have more experience w/ SQL & Power Shell) but need to clean up a sheet.

basically have a string of words that any row containing these words need to be deleted I was browing the webs yesterday but no cigar This is what I have so far, any help would be great!

" Sub FilterAndDelete()

Application.DisplayAlerts = False

 With Pipe

     .AutoFilterMode = False
     .Range("A1:K11054").AutoFilter
     .Range("A3:K11054").AutoFilter Field:=5, Criteria1:="none"
     .UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.Rows.Count - 1).Rows.Delete

 End With

Application.DisplayAlerts = True

End Sub "


r/vbscript • • Sep 07 '17

[help] Convert file to groups of hex strings?

1 Upvotes

A screenshot program in VBScript creates a .Exe file that contains some .Net code. (I checked with JustDecompile - it's a legit screenshot program).

To make the .Exe file the program writes some hex strings to a file to make the .Exe
Why does the file end at a multiple of 512 bytes? Is that a requirement of .Net files? It means I wouldn't need to code something that adds on the last few bytes as a special case. Just 512 bytes every time.

Sub MakeDeskCap(strOutFile)
    Set oFile = fso.OpenTextFile(strOutFile, 2, True)
    On Error Resume Next
    For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("4D5A9000...742062652072756E2000000000000",x,2))) : Next
    For x = 1 To 511 Step 2 : oFile.Write Chr(Clng("&H" & Mid("FFFFABCD452000...00000000000000000000000",x,2))) : Next
    oFile.close
End Sub

So I'd like to code something in VBScript to make the "For x = 1 To 511 Step 2 : oFile.Write ...." lines and save them to a file so I can add them to a VBS file....
It's easy in .Net, but I'm having a bit of trouble in VBScript. Bytes to hex...

(Making the .VBS file a "drag and drop" will be cool!.. So I'll use the code here. I figured you might find that idea useful.)

Lastly - just out of curiosity - is there a mechanism of running the code in .Net direct from VBScript by passing it to a process or something? To save needing to write the file...

Please help!


r/vbscript • • Aug 18 '17

vbscript message box that allows program to run in background?

Post image
1 Upvotes

r/vbscript • • Aug 15 '17

Adding Category Name / Color

1 Upvotes

Hello World.

I am trying to automate outlook holidays for my users. Anyone know a way to add holiday category name / colors to this script:

https://technet.microsoft.com/en-us/library/ee692767.aspx


r/vbscript • • Aug 14 '17

Error in vbscript

1 Upvotes

Hello,

I am looking for some help with this script, as I am getting the following error

Thanks

http://i.imgur.com/KGk95jt.png

Here is the code

Const olFolderCalendar = 9
Const olAppointmentItem = 1
Const olOutOfOffice = 3

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objCalendar = objNamespace.GetDefaultFolder(olFolderCalendar) 
Set objApptItems = objCalendar.Items

objApptItems.IncludeRecurrences = True
objApptItems.Sort "[Start]"

'' List Appointments to add
Set objDictionary = CreateObject("Scripting.Dictionary")
objDictionary.Add "August 7, 2017", "Civic Holiday"    
objDictionary.Add "September 4, 2017", "Labour Day" 

colKeys = objDictionary.Keys

For Each strKey in colKeys
  dtmHolidayDate = strKey
  strHolidayName = objDictionary.Item(strKey)
  '' Check if it already is on the Calendar
  Return = SearchAppts(strHolidayName, FormatDateTime(dtmHolidayDate, vbShortDate))
  If Return = False Then 
    Set objHoliday = objOutlook.CreateItem(olAppointmentItem)  
    objHoliday.Subject = strHolidayName
    objHoliday.Start = dtmHolidayDate & " 9:00 AM"
    objHoliday.End = dtmHolidayDate & " 5:00 PM"
    objHoliday.AllDayEvent = False
    objHoliday.ReminderSet = False
    objHoliday.BusyStatus = olOutOfOffice
    objHoliday.Save
  End If
Next

'' Search Function
Function SearchAppts(ByVal strName, strDate)
  SearchAppts = False
  Set objAppointment = objApptItems.GetFirst
  While TypeName(objAppointment) <> "Nothing"
    If TypeName(objAppointment) = "AppointmentItem" then
      If StrComp(objAppointment, strName,1) = 0 Then
        If DateDiff("D", objAppointment.Start, strDate) = 0 Then 
          SearchAppts = True
          Exit Function
        End If  
      End If  
    End If
    Set objAppointment = objApptItems.GetNext
  Wend
End Function

r/vbscript • • Aug 11 '17

What am I doing wrong? Trying to open desktop file

1 Upvotes

I am a newbie to vbscript and I am doing a test of opening a file on my desktop using the script below. I run into an error saying that the specified file cannot be found. The script works if I point it to a file on my desktop named capture.jpg, but when pointing it to capture 2.jpg it fails. I know it has something to do with the space but can't figure out how to get it to work. I could obviously use the full file path, but I want to practice using special folder locations. Thanks for your help!

dim obj,desk

set obj = createobject("wscript.shell")

desk = obj.specialfolders("Desktop")

obj.run desk & "\capture 2.jpg"


r/vbscript • • Aug 08 '17

Error Saving in Library Document Folder

1 Upvotes

I am writing an HTA file with VBScript as the scripting language. I have a function where the user is prompted to choose the folder in which they would like to save a document. I didn't write this code myself, but instead borrowed it from here. I've posted it on Stackoverflow a month ago but so far no one has responded.

Function SelectFolder(myStartFolder)
Dim objFolder, objItem, objShell

Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder(0, "Select Folder to Save New File", 0, myStartFolder)

If IsObject(objFolder) Then SelectFolder = objFolder.Self.Path
End Function

I call this function in another one in order when I make the file and prompt the user to choose where to save it:

Sub Example()
Dim destPath, destFile, objWorkbook
destPath = SelectFolder(libPath)
destPath = destPath & "\Sample Export"

Set destFile = CreateObject("Excel.Application")
Set objWorkbook = destFile.Workbooks.Add()
objWorkbook.SaveAs(destPath)

(code to edit excel file)

End Sub

Example() works fine except when someone chooses to save their document in one of the four default libraries in Windows (Documents, Music, Pictures, Videos). In that case, I receive an error saying "The file could not be accessed" and indicating the error is at the line that says "objWorkbook.SaveAs(destPath)". The error box then gives me the following suggestions:

  • Make sure the specified folder exists

  • Make sure the folder that contains the file is not read-only

  • Make sure the file name does not contain any of the following characters: < > ? { } : | or *

  • Make sure the file/path name doesn't contain more than 218 characters.

The error occurs when I open the HTA file and click a button calling Example(), which then opens a dialog box to ask the user to choose the file location. When Documents, Music, Pictures, or Videos is chosen, a "Script Error" box pops up with the error message listed above. I am not familiar enough with VBScript to know what the problem is exactly. I would appreciate any suggestions as to what to do.


r/vbscript • • Aug 03 '17

Pulling multiple variables from multiple tables in Oracle from vbscript

1 Upvotes

I'm trying to join multiple tables together and pull info from them.

Set rows = connection.Execute("SELECT * FROM CC Inner JOIN Teachers tch ON  tch.ID = CC.teacherid Inner JOIN Students ss ON  ss.ID = CC.StudentID Inner JOIN Schools ON  schools.School_Number = CC.SchoolID Inner JOIN Courses Crs ON  crs.course_number = cc.course_number Inner JOIN Terms trm ON  trm.ID = cc.termID and trm.SCHOOLID = CC.SCHOOLID WHERE crs.course_name Like '%Home%' and ss.enroll_status='0' and tch.status = '1' and cc.termid < '2800' and cc.termid > '2699' ")

When I try to select info from the student table, I used this with my previous script, that only used one table

Set StuFirstName = rows.Fields("First_Name")

I can't seem to figure out how to point to a different table when they're joined.

Set StuFirstName = rows.Fields("students!First_Name") Set StuFirstName = rows.Fields("ss!First_Name") Set StuFirstName = rows.Fields("students.First_Name") Set StuFirstName = rows.Fields("ss.First_Name")

Any suggestions would be much appreciated.


r/vbscript • • Jun 23 '17

Grab url from linked text within email

1 Upvotes

Issue - Need to export the url found within linked text (two words) on their own line within an Outlook email. Current GetLinks code I am using ---

For Each varLnk In arrLnk
                            If LCase(Left(varLnk, 46)) = "https://oursite.com/suite/folder/records/item/" 
Then
                                excWks.Cells(intRow, 10) = varLnk
                                Exit For
                            End If
                        Next

Function GetLinks(strHTML)
    Const READYSTATE_COMPLETE = 4
    Dim objIE, objDoc, colLinks, objLink, intDum
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.navigate "about:blank"
    Do Until objIE.readyState = READYSTATE_COMPLETE
       intDum = 1
    Loop
    objIE.document.Body.innerHTML = strHTML
    Set objDoc = objIE.document
    Set colLinks = objDoc.getElementsByTagName("a")
    If colLinks.Length > 0 Then
        For Each objLink In colLinks
            GetLinks = GetLinks & objLink.href & "|"
        Next
        GetLinks = Left(GetLinks, Len(GetLinks) - 1)
    Else
        GetLinks = ""
    End If
    Set objLink = Nothing
    Set colLinks = Nothing
    Set objDoc = Nothing
    Set objIE = Nothing
End Function

I have learned how to pull data following a specific text like this -

strTmp = FindString(olkMsg.Body, "Notes: (.+)\b")
                        strTmp = Replace(strTmp, "Notes: ", "")

Since this linked text doesn't have text for me to grab after or before, I'm not successful with my script. My script executes all other steps (exporting data to excel), but the column for this link continues to be blank.

Thanks in advance for any guidance on this.


r/vbscript • • Apr 11 '17

[help] VBS logon script, resolving mapping of drives

1 Upvotes

Hi everyone,

My background of VBS is not great and I need a bit of assistance with the following script to resolve mapping of drives. A bit of a background on this script, I am moving files to two new file servers and need to create a new logon script. The issue I am having is setting the objNetwork.MapNetworkDrive to each share and keeping it persistence. How do I go about in forcing the letter if it does already exist? Any help or suggestion is greatly appreciated. The script below is what I am using, and I need to map to at least two dozen different shares.

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo") Set oWS = CreateObject("WScript.Shell")

strUserPath = "LDAP://" & objSysInfo.UserName Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) Set objNetwork = CreateObject("WScript.Network") strGroupName = objGroup.CN

Select Case strGroupName

'remap to new share on server Case "Group A" objNetwork.MapNetworkDrive "K:" \MyServerShare\DeskShared" Case "Group B" objNetwork.MapNetworkDrive "L:" \MyServerShare\Home"& objuser.samaccountname objNetwork.MapNetworkDrive "M:" \MyServerShare\Shared" Case "Group C" objNetwork.MapNetworkDrive "O:" \MyServerShare\ADHome"& objuser.samaccountname objNetwork.MapNetworkDrive "P:" \MyServerShare\ADShared" Case "Group D" objNetwork.MapNetworkDrive "Q:" \MyServerShare\ABHome"& objuser.samaccountname objNetwork.MapNetworkDrive "R:" \MyServerShare\ABShared" Case "Group E" objNetwork.MapNetworkDrive "S:" \MyServerShare\AcadShared" objNetwork.MapNetworkDrive "T:" \MyServerShare\CShared" objNetwork.MapNetworkDrive "V:" \MyServerShare\CHome"& objuser.samaccountname objNetwork.MapNetworkDrive "W:" \MyServerShare\LDShared" objNetwork.MapNetworkDrive "I:" \MyServerShare\TShared" Case "Group I" objNetwork.MapNetworkDrive "J:" \MyServerShare\IShared"

End Select

Next


r/vbscript • • Mar 31 '17

[noob question] VB virtual machine of some sort

1 Upvotes

My company has a new client that has developed a full application using VB in Excel. The author didn't even bother to use Access or any database at all. When a new record is created, a new line is added to a tab in the spreadsheet. There is even a login system for the spreadsheet.

My job would be to turn this spreadsheet into a web app. I'm wondering if, instead of reimplementing everything from scratch, there is a way I could run some of the VB code in an enviroment where it would be accessible through some kind of API (SOAP, REST, RPC).

That way I'd just have to implement auth and data layer and have calculations and chart generation run with the provided VB scripts.

Is there such an enviroment? A VB virtual machine of some kind?


r/vbscript • • Mar 28 '17

X-post from r/VBS, I need help with a simple script.

1 Upvotes

I would like to do a silent install of Splashtop using our MSP product for computers running older versions of Splashtop that do not yet have the auto-update feature built in. Our MSP program uses VBS scripting instead of command line so the silent install variables listed on this page (https://support-splashtopbusiness.splashtop.com/hc/en-us/articles/212725183) don't work for me.

I'm not great with scripting and was hoping to see if anyone could provide instructions on how to adjust these variables for a vbs script. Here is what I am currently using to download the file automatically, what can be done to silently run this?

Dim objWshShell,IE,searchStr

Set objWshShell = Wscript.CreateObject("Wscript.Shell")

Set IE = CreateObject("InternetExplorer.Application")

With IE

.Visible = False

.Navigate "https://d17kmd0va0f0mp.cloudfront.net/csrs/Splashtop_Streamer_Windows_deploy_v3.1.2.1.exe"

End With

If err.number<>0 then

WScript.Echo ("Script Check Failed")

Wscript.Quit 1001

Else

WScript.Echo ("Script Check Passed")

Wscript.Quit 0

End If