r/visualbasic • • Apr 16 '21

VBScript Help with VB Script

2 Upvotes

I have one excel file (with 4 different tabs, if that matters). I use this ‘master file’ every month as a template and make over 300 copies, one for each of our clients each having their 3 digit suffix at the end of the file name so it would be ‘Master file ABC.xlsx’ or ‘Master file BCD.xlsx’ (and so on). I have an excel list of each of these suffixes and one excel ‘master file’. Now my question…how do I make a macro/magic button to make the 2 things automatically do what I do manually, create 300+ master files all titled ‘master file XXX’?

r/visualbasic • • Feb 18 '14

VBScript [VBScript] Downloading a text file

2 Upvotes

This one might get messy...and I thank you in advance for even looking at this post. I vow an hour of penance trying to help other programmers if this goes well.

I've got an HMI/SCADA made for a large manufacturing company. The HMI Supports VBScripts (but NOT VBA). They have asked for a tool that reports some data. my issue is not that. It calculates and pulls data fine, but they want a way to print it. My first instinct was to make a text file with a simple readout (5 lines, tops). I tested it locally and it generates a .txt file with the proper data. Below is a older version of the code, but it still did the trick:

Dim fso, tf

Set fso = CreateObject("Scripting.FileSystemObject")

Set tf = fso.CreateTextFile("c:\Reports" & StartDate & Enddate & "Pumplog.txt",True)

tf.WriteLine("Report for " & StartDate & " To " & EndDate)

tf.WriteBlankLines(3)

tf.Write("Gallons pumped: ")

tf.WriteLine(Cstr(SumGallons))

tf.Close

That generates a text file in C:\Reports. It works in demo mode, but this Screen is published to HTML on this server (the development server is also the host web server) to be viewed in internet explorer from anywhere on the network. When I run the script in HTML I get a N.70 Error saying permission denied. I fully understand why a webpage shouldn't just be able to place files on your computer, but I need a printer friendly page. So here are my ideas, and I have no idea how to do any of them:

  1. Get this script to open a text file with no name and allow the viewer to save it whereever they so choose, like a .pdf opened from an email.
  2. Publish a .txt file to the server and provide a link to view this file and DL as needed.
  3. Figure out a way to allow permissions so that the original script works.

There are probably more ideas but I can't think of them right now. If you know how to do any of the above or have another idea, I'd love to hear from you!

Thanks.

r/visualbasic • • Oct 08 '19

VBScript Help reading a potentially malicious vbs file

4 Upvotes

Hello, I just received a phishing email directed at my small business and the email contained an attachment. Now, I'm well aware that the email was a scam and the file is dangerous so I opened it in a linux vm and converted it to a .txt. However I am not familiar with vbs. I was hoping someone could give me a rough idea of what it is doing. It looks like there is also a MASSIVE array in the middle full of random characters. If this post breaks the subs rules just lmk and I will gladly take it down. Thanks and hopefully you can help. Btw the file is massive.

File: https://gist.github.com/user3423453456/8b074dc39333239015917993923c6cac

tl;dr Got send strange file. Need help understanding what it does

r/visualbasic • • Feb 20 '14

VBScript VBScript for hiding taskbar and desktop icons

1 Upvotes

i am trying to pull a prank on my sister, pause her in the middle of an episode of Shurlock on netflix, change her background to one of a weeping angle, hide her taskbar and desktop icons, show her desktop, and then play a really loud scarey noise. i have the scripts to switch the wallpaper and play the sound, i just need help with the other two

as the title states i am trying to create two different (or maybe one single) script(s) that will change the taskbar to hidden and the desktop icons also to hidden. i have been searching around online and the two scripts i found for taskbar hiding are:

Option Explicit
Const HKCU = &H80000001
 
Dim objReg
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}root\default:StdRegProv")
Dim objWMI
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}root\cimv2") 
 
' Adjust the first bit of the taskbar settings
Dim arrVal()
objReg.GetBinaryValue HKCU, "Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings", arrVal
arrVal(8) = (arrVal(8) AND &h07) OR &h01
objReg.SetBinaryValue HKCU, "Software\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2", "Settings", arrVal

' Restart Explorer for the settings to take effect.
Dim objProcess, colProcesses
Set colProcesses = objWMI.ExecQuery("Select * from Win32_Process Where Name='explorer.exe'")
For Each objProcess In colProcesses
	objProcess.Terminate()
Next 

and 2)

cSendKeyValue = "%u"		' Alt+u = Auto-hide the taskbar 
Set WshShell = Wscript.CreateObject("Wscript.shell") 
Set oShell = CreateObject("Shell.Application") 
oShell.TrayProperties 

Wscript.Sleep 100 
WshShell.SendKeys cSendKeyValue                        

Wscript.Sleep 100 
WshShell.SendKeys "{ENTER}"           ' Enter to Close Properties 

Set oShell = Nothing 
WScript.Quit

the problem with the first one is that its directly modifying the registry and requires explorer.exe to be restarted (not exactly discreet) and the second one requires mouse clicking (again, not discreet).

i have also tried one from ehow but it keeps getting errors


here is the only version of a script i can find for hidding desktop without modifying the registry has compiling errors and is listed below

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Function DesktopIconsShow()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 5
End Function

Function DesktopIconsHide()
    Dim hwnd As Long
    hwnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hwnd, 0
End Function

i would love some help as i am relatively new to visual basic. if someone could help make the two broken scripts into one working script, i would be very grateful

r/visualbasic • • Jul 04 '14

VBScript Usefull Visual Basic Script Programs

Thumbnail
26programmer.wordpress.com
0 Upvotes

r/visualbasic • • Oct 08 '25

VBScript IT2 Treasury Management Software - VBScript

6 Upvotes

Hi! Does anyone have any tips or advice for using scripts to create workbenches? I am trying to create a weighted average workbench and the preloaded functions are not really giving me what I need. Any help on how to format/create calculation scripts would be really appreciated!

Thank you:)

r/visualbasic • • Oct 11 '18

VBScript VBS script to connect to VPN Issues with parameter and using .dat file

3 Upvotes

Hello I am currently stuck on a script. I am trying to write a command to go to a VPN command line. We had a previous version of the command line for windows 7 and moved to windows 10.

Old command line was

objShell.Run("""" & strVPNClient & """" & " connect ""VPN EAST"" user " & strServiceUserName & " pwd " & strServicePassword),0,True

Now i need to run the command with a .dat file

strVPNClient is the VPN programs command line path

I tested it running it in command prompt as

C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe -s < loginuser.dat

It launched the VPN in command prompt and connected perfectly, but I dont know how to fix it in VBS

i have tried

objShell.Run "C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe -s < loginuser.dat"

and a few other ways.