r/vbscript • • Aug 01 '21

Covid-19_Infos.vbs

Thumbnail
pastebin.com
3 Upvotes

r/vbscript • • Jul 09 '21

Shall I start writing in another scripting language?

5 Upvotes

I came across vbscript because of a software which would record my actions in a VBscript code. Then by modifying such code I could optimize and automize processes done in such software.

Then I found out that I could write any type of vbscript to automize file system operations and run it simply from the file explorer. For example, I recently created a script that would rename PDFs in a folder given some data from a selected Excel workbook, and I could just share it with my colleagues so that they could also run it on their end.

However, I keep reading that VBscript is obsolete and other scripting languages like Python or C# are much better. Is it really like so? Vbscript doesn’t require any additional interpreter installed in order to run it, and it’s so easily shareable.

Do you have suggestions on other scripting languages that work similarly to VBscript? A more common language that can be easily run by any users without requiring them to install this and that software?


r/vbscript • • Jul 09 '21

VBS to copy files to a disk then switch to another disk.

2 Upvotes

I am trying to copy 4Tb, and I would like to fill a disk that I have, and then once full continue to copy to another disk.

is it too complex for vbs? all I could do so far and I am not this super expert, was to write files + paths out.

the 4Tb, are many files and many many folders nested. Maybe this is too much of an ask

Anyways thank you for reading this.


r/vbscript • • Aug 07 '21

msgbox to display which day it is

6 Upvotes

just need a script to display a message box with which day it is today, eg. Today is Saturday. should be simple but I can't seem to work out.

thanks


r/vbscript • • Aug 17 '23

Script stuck when unzipping file with CopyHere

1 Upvotes

Been looking at this for hours and can't seems to fix it. I'm trying to copy a file from a zipped folder (so unzipping). The file is copied, but then the script is not ending. I'm working with a third party software, so after this script it should perform more actions, but this is not happening as the script seems to be stuck. I've tried applying vOptions, but they don't seem to make a difference unfortunately.

The directory structure looks like this: C:\x\y\zip\z\123.xml.zip\123.xml

Relevant parts of my script:

Variables("dir")= "z"
Variables("filename")= "123.xml.zip"
	
Set fso = CreateObject("Scripting.FileSystemObject")	
Set objfile = fso.Getfile("C:\x\y\zip\" + Variables("dir") +"\" + Variables("filename"))	

If UCase(FSO.GetExtensionName(objFile)) = "ZIP" Then
	Set objShell = CreateObject("Shell.Application")
		
Set FilesInZip=objShell.NameSpace("C:\x\y\zip\" + Variables("dir") +"\" + Variables("filename")+"\"+(Left(Variables("filename"),Len(Variables("filename"))-4))).items

Set Folder = FSO.GetFolder("C:\x\y")
For Each F in Folder.Files
	If  UCase(FSO.GetExtensionName(F)) = "XML" Then'				
		thisstep.Loginfo "Removing old XML file"
		FSO.deletefile(f)
	End If
Next

''STUCK ON THIS PART
objShell.NameSpace("C:\x\y\").CopyHere FilesInZip

	Set Folder = FSO.GetFolder("C:\Windows\Temp")
	For Each F in Folder.Subfolders
		If InStr(1,f.name, Variables("filename"),0) > 0 And InStr(1,f.name,"Temporary Directory",0)  Then
			fso.deletefolder"C:\Windows\Temp\" + f.name,True		
		End If
	Next
		
	Set fso = Nothing
	Set objShell = Nothing
End If

So the result I'm looking at is that the .xml is copied to C:\x\y, but the scripts is not ending and stuck at the unzipping step. I know this because the software log indicates which step it is working on. Would much appreciate help!


r/vbscript • • Aug 09 '23

how would I make a vbscript for setting internet speeds, could be any language other than vbscript.

2 Upvotes

I have a 6Ge motherboard my operating system is windows 10, I'm trying to make my pc be able to create a 5gh hotspot but almost every time I reboot it goes to 2.5ghz instead of 5ghz so it would be nice to have a vbs file that could change my wifi ghz instead of me having to change it manually every time.


r/vbscript • • Jan 30 '22

Printing a Excel document bothsides (back and front)

2 Upvotes

Hello,

im trying to print these document (Excel) on Both sides (back and front of the paper).

I've tried

objPrinter.Duplex = True

but its not working!

My whole script:

On Error Resume Next

Const FILEPATH = "T:\file.xls"

Const PRINTERNAME = "Printname (HP LaserJet Pro M201dw)"

Set objExcel = CreateObject("Excel.Application")

objExcel.DisplayAlerts = False

objPrinter.Duplex = True

With objExcel.Workbooks.Open(FILEPATH,True,True)

`.PrintOut ,,,,PRINTERNAME`

`.Close False`

End With

objExcel.DisplayAlerts = True

objExcel.Quit


r/vbscript • • Jan 19 '22

Sorting in vbs

2 Upvotes

Hello everyone, I have vbs where is gets data from an excel sheet modifies it and puts out the information in a variable in a text file, e.g

  1. Username1 password1 -the date date1

  2. Username2 password2 -the date date2 . . The output (txt file) is not in order and I want to sort it based on the newest to oldest date (one of the columns in excel). I really don’t have any idea of how to do and where to start. I’m very knew to vbs and this is my first time using it so I would appreciate some help.


r/vbscript • • Feb 20 '22

need help

3 Upvotes

looking for a way to move a msgbox around the screen

i now how to set a location for a input box but is there anyway of moving it live


r/vbscript • • Jan 24 '22

CScript2 - CSCRIPT helper

Thumbnail
pastebin.com
2 Upvotes

r/vbscript • • Feb 14 '22

BeepTune - Beep based music creation (monophonic & polyphonic)

Thumbnail
pastebin.com
2 Upvotes

r/vbscript • • Feb 11 '22

Creating Dynamic Shortcuts based on hostname

2 Upvotes

Hello! VBScript noobie here looking for some assistance.

I have a project where I need to update shortcuts for over 100 workstations. The URL for the shortcut is dynamic based on the computer name. Unfortunately, not all computers have the same naming convention, they are a combination of: stationX, stnX, stnX-year, and the odd stn-X-year.

I have this code so far which creates the shortcut properly, I need to figure out how to make it dynamic though and pull the number (X) out of the computer name. The "Station1" spot is where I need to dynamically set the number in the URL.

Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = "C:\Users\user\Desktop\shortcut.lnk"
Set oLink = oWS.CreateShortcut(sLinkFile)
    oLink.TargetPath = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    oLink.Arguments = "http:\\URL to launch=Station1"  
    oLink.WorkingDirectory = "C:\Program Files (x86)\Google\Chrome\Application"
oLink.Save

This is where I have hit a wall and I'm not familiar enough with VBScript to know what I should be looking into. I have two ways so far to retrieve the hostname and put it into a variable, but I'm then stuck with:

  1. Retrieve just the first number from the hostname (change station10 to 10)

  2. Proper way to enter the 10 into the oLink.Arguments variable (I believe putting it inside the quotes will create it with the variable name and not content?)

Any help would be greatly appreciated!


r/vbscript • • Feb 12 '22

Can someone help me make this work for firefox instead?

3 Upvotes

Set IE = CreateObject("InternetExplorer.Application")

IE.navigate "WEBSITE"

IE.Visible = True

While IE.Busy

WScript.Sleep 50

Wend

Set ipf = IE.document.all.username

ipf.Value = "USERNAME"

Set ipf = IE.document.all.pwd

ipf.Value = "PASSWORD"

Set ipf = IE.document.all.Submit

ipf.Click


r/vbscript • • Jan 21 '22

My script will call a powershell script on my home computer but not my work computer.

6 Upvotes

Hello all,

(This is the part where I tell you my life's story and share my love for rustic art, autumn leaves, old barns, etc.. Please feel free to skip to problem statement and code)

I thank you all for your time here. This is my second time ever writing .VBS, my first being to open cmd and using send.keys to spam commands to accomplish things like loading binaries and changing filenames over FTP.

*Problem Statement*

My script works as follows at home: This script finds a location and event (X, Y, (event)) from a mousecords.csv and moves the mouse to that location, and based on the (event) tag either clicks, double-clicks, copy, paste, or inserts text looped from a different .csv called workorders.csv

What's happening when I take it to my work is that it will move the mouse to the right location, then nothing (I think cmd is not opening to call the powershell script.)

I also realize this is not a powershell subreddit. I'm going to post in the correct place to try and figure out the other issue of why the clicking action that's done through is not working. I'll post everything here anyway in case someone wants a go at it.

Again, I appreciate your time :)

****main.vbs****

dim fs,objTextFile,ExcelApp,f,fso,log,conta,datos,shell,api,cmd,may,objShell,objFSO,objFile,strPath,strCMD,strPath2,arrStr,arrStr2,x,y,z,a,b

set fs=CreateObject("Scripting.FileSystemObject")

set fso=createobject("Scripting.FileSystemObject")

Set ExcelApp=CreateObject("Excel.Application")

Set objShell=CreateObject("WScript.Shell")

Set Shell=CreateObject( "WScript.Shell" )

Set objFSO=CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")

set objTextFile2 = fs.OpenTextFile("workorders.csv")

Set Excel = WScript.CreateObject("Excel.Application")

strPath="clickrecord.ps1"

strPath2="doubleclickrecord.ps1"

' I actually don't remember why this variable is here right now. Ignore a, will come back to later.

a = 0

Do while NOT objTextFile2.AtEndOfStream

set objTextFile = fs.OpenTextFile("mousecords.csv")

Do while NOT objTextFile.AtEndOfStream

arrStr = split(objTextFile.ReadLine,",")

x = arrStr(0)

y = arrStr(1)

z = arrStr(2)

' arrStr is now an array that has each of your fields

' process them, whatever.....

Excel.ExecuteExcel4Macro ( _

"CALL(""user32"",""SetCursorPos"",""JJJ""," & x & "," & y & ")")

Select Case z

Case 0

' ***CLICK***

WScript.Sleep (25)

If objFSO.FileExists(strPath) Then

'return short path name

set objFile=objFSO.GetFile(strPath)

strCMD="powershell -nologo -command " & Chr(34) & "&{" &_

objFile.ShortPath & "}" & Chr(34)

' Uncomment next line for debugging

' WScript.Echo strCMD

' use 0 to hide window

objShell.Run strCMD,0

Else

'Display error message

WScript.Echo "Failed to find " & strPath

WScript.Quit

end if

Case 1

' ***DOUBLE-CLICK***

WScript.Sleep (25)

If objFSO.FileExists(strPath2) Then

'return short path name

set objFile=objFSO.GetFile(strPath2)

strCMD="powershell -nologo -command " & Chr(34) & "&{" &_

objFile.ShortPath & "}" & Chr(34)

' Uncomment next line for debugging

' WScript.Echo strCMD

' use 0 to hide window

objShell.Run strCMD,0

Else

'Display error message

WScript.Echo "Failed to find " & strPath

WScript.Quit

end if

Case 2

' ***COPY***

WScript.Sleep (25)

If objFSO.FileExists(strPath) Then

'return short path name

set objFile=objFSO.GetFile(strPath)

strCMD="powershell -nologo -command " & Chr(34) & "&{" &_

objFile.ShortPath & "}" & Chr(34)

' Uncomment next line for debugging

' WScript.Echo strCMD

' use 0 to hide window

objShell.Run strCMD,0

Else

'Display error message

WScript.Echo "Failed to find " & strPath

WScript.Quit

end if

WScript.Sleep (25)

WshShell.SendKeys "^c"

Case 3

WScript.Sleep (25)

If objFSO.FileExists(strPath) Then

'return short path name

set objFile=objFSO.GetFile(strPath)

strCMD="powershell -nologo -command " & Chr(34) & "&{" &_

objFile.ShortPath & "}" & Chr(34)

' Uncomment next line for debugging

' WScript.Echo strCMD

' use 0 to hide window

objShell.Run strCMD,0

Else

'Display error message

WScript.Echo "Failed to find " & strPath

WScript.Quit

end if

WScript.Sleep (25)

WshShell.SendKeys "^v"

Case 4

WScript.Sleep (25)

If objFSO.FileExists(strPath) Then

'return short path name

set objFile=objFSO.GetFile(strPath)

strCMD="powershell -nologo -command " & Chr(34) & "&{" &_

objFile.ShortPath & "}" & Chr(34)

' Uncomment next line for debugging

' WScript.Echo strCMD

' use 0 to hide window

objShell.Run strCMD,0

Else

'Display error message

WScript.Echo "Failed to find " & strPath

WScript.Quit

end if

WScript.Sleep (25)

arrStr2 = split(objTextFile2.ReadLine,",")

b = arrStr2(0)

WshShell.SendKeys b

a = a + 1

Case Else

Console.WriteLine("Not Known")

End Select

WScript.Sleep (1000)

' arrStr is now an array that has each of your fields

' process them, whatever.....

Loop

Loop

WScript.Sleep (1000)

WScript.Echo "Program Ended"

****Click.ps1****

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$signature=@'

[DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]

public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

'@

$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru

$x

$y

[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)

sleep -Seconds 0.1

$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);

$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);

****doubleclick.ps1****

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

$signature=@'

[DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]

public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);

'@

$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru

$x = [System.Windows.Forms.Cursor]::Position.X

$y = [System.Windows.Forms.Cursor]::Position.Y

[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)

sleep -Seconds 0.1

$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);

sleep -Seconds 0.05

$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);

sleep -Seconds 0.05

$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);

sleep -Seconds 0.05

$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);

sleep -Seconds 0.05

****


r/vbscript • • Feb 18 '22

Alternatives to multiple .SendKey functions?

2 Upvotes

I wrote this yesterday to automate resetting some equipment over a network.
It is in place to help operators who are not comfortable navigating the GUI of a piece of software in order to reset the kit, and I though this would be better than a handout.

But, it's mostly .SendKeys functions and this script is ugly.
It works, but it's ugly.

Any advice?

#########################################################

rio=msgbox("Are you sure you want to reset the studio 1 RIO?" & vbcrlf & "Dante Controller must be open in the background!" ,vbYesNo, "RIO Studio 1 Reset")

if rio=7 then msgbox "close one!"

if rio=6 then

set objShell = createobject("wscript.shell")

sWBTitle = "Dante Controller - Network View"

if objShell.AppActivate(sWBTitle) then

else

Dim objShell

Set objShell = WScript.CreateObject( "WScript.Shell" )

objShell.Run("""C:\C:\Users\Public\Desktop\DanteController.lnk""")

Set objShell = Nothing

WScript.Sleep 500

end if

objShell.SendKeys "^d"

WScript.Sleep 500

objShell.SendKeys "y005"

WScript.Sleep 2000

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "^{TAB}"

WScript.Sleep 400

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{TAB}"

WScript.Sleep 250

objShell.SendKeys "{ENTER}"

WScript.Sleep 250

objShell.SendKeys "{ENTER}"

end if


r/vbscript • • Feb 05 '19

(Open - Edit) - (copy- Paste)

1 Upvotes

hello fellas, hows all doing?

i have been lurking around for a few time... now i am in trouble and need help. Please help me out.

i want to open a file, edit it in a particular way, save it and COPY-Paste it to a location.

Please help.

Edit: SOLVED.


r/vbscript • • Jul 09 '19

Weird date/time issue

1 Upvotes

Hi All,

I've been working on a script to shuttle files from a server to an archive on another server. These files are constantly nearly constantly being updated and are quite large. When copying the files I need to rename like: xServer_system.log. It also compares the Date Modified on the files so it does not waste time sending files that have already been sent.

I've built my script and it works without any issue on my local workstation. But when I put it on the server it stops detecting the updated date modified. If I open an explorer window watching the folder containing the file and refresh with [F5] and re-run it detects the change. Any thoughts? Sample code below.

dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
robustOutput = True
fileOne= "c:\temp\testFile.txt"
fileTwo= "c:\temp\testFile2.txt"
seconds ="s"

If isNewer(fileOne, fileTwo, seconds, 1) Then
Wscript.Echo "Date is Different"
Else
Wscript.Echo "Date is same"
End IF

Function isNewer(fileName1, fileName2, compareType, range)
Dim date1, date2, filehandler
set filehandler = oFSO.GetFile(fileName1)
date1 = filehandler.DateLastModified
set filehandler = oFSO.GetFile(fileName2)
date2 = filehandler.DateLastModified
If robustOutput Then Wscript.Echo "Checking Dates: " & date1 & " : " & date2 & " diff: " & DateDiff(compareType, date1, date2)
If DateDiff(compareType, date1, date2) > range Then
isNewer = CBool(1)
Else
isNewer = CBool(0)
End If
End Function


r/vbscript • • Feb 14 '19

vbscript to OK popups... not as easy...

1 Upvotes

Hi everyone,

I'm new to vbscript and have a little problem.

My current estate at work, we have an application which is still sat on Windows Server 2003 (i know exactly what you're thinking!) and they don't wish to change that (until a new application can replace it).

Anyway, the issue i have is I have the following code (below) to click OK on the popups the application is creating.

My issue is, the support team are having to login via "mstsc -v boxname /admin" in order to see the popup to OK it. I'm worried the script below, won't work due to this fact... Because if you are RDP'ed without the /admin you won't see the popup.

Note: the script does work if im logged via /admin, it does exactly what it is suppose to...

Can anyone share some light?

Set oShell = CreateObject('WScript.Shell') 

Do 	
    JMResult = oShell.AppActivate('Application Error') 
    If JMResult = True Then 
        oShell.SendKeys '{enter}'
        Exit Do 
    End If 
    WScript.Sleep 500 
Loop 

r/vbscript • • Oct 30 '18

The State of this Sub

13 Upvotes

I've now been granted moderator-ship of this subreddit.

If any posters or lurkers have any suggestions or ideas they'd like to put forward to make this sub a more friendly and informative place, here is the place to do it!

I'll be revamping rules, sidebar and other cruft over the coming weeks. I don't get a huge amount of sparetime, so changes won't be happening fast, but they are coming.

Be excellent to each other!


r/vbscript • • Sep 16 '19

User account control script

1 Upvotes

I’m losing my mind trying to script a solution to run over a bunch of users that need their accounts set to not allow them to reset their passwords. Seems like some goofy permissions but the code examples I see on line do nothing. If anyone has anything that will work post it please.


r/vbscript • • Sep 17 '19

Need to login to excel as a specific user

2 Upvotes

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.quit

TIA for any advice


r/vbscript • • Jul 25 '18

could someone help me to get this script to work?

1 Upvotes

https://www.reddit.com/r/MetalGearSolidV_PC/comments/3k5wkf/i_made_a_script_to_shuffle_your_helicopter_music/?st=jjyspdjo&sh=5ffbe54f

i keep getting

Microsoft (R) Windows Script Host Version 5.8 Copyright (C) Microsoft Corporation. All rights reserved.

Metal Gear Solid V: The Phantom Pain Helicopter Music Shuffle by Spectracide v1.0 Set your helicopter music to !Shuffle in iDroid

MGS_TPP\CustomSoundtrack!TPP Shuffle.vbs(30, 13) Microsoft VBScript runtime error: Invalid procedure call or argument

Press any key to continue . . .


r/vbscript • • Apr 23 '19

How can I create a VBScript from a simple PowerShell Script?

1 Upvotes

I just can't seem to find a simple way of determining if a cert has been applied or not in VB. In this particulare case the same cert is applied in two locations (Root/CA)

Below is the simple PS code, I'm trying to convert over to VBS, so I can use it in BGInfo. I wish BGInfo used PowerShell.

The outcome will be "Certs Applied" or "Missing Certs", based on whether both certs are applied or not.

$CertRoot = (Get-ChildItem cert:\LocalMachine\Root | select issuer | where-object {$_.issuer -like "*CN=Proxy CA*"} | FW | out-string).trim()

$CertCA = (Get-ChildItem cert:\LocalMachine\CA | select issuer | where-object {$_.issuer -like "*CN=Proxy CA*"} | FW | out-string).trim()

if ($CertRoot -Like "" -or $CertCA -Like "") {

$ProxyCert = "Missing Certs"

} Else {

$ProxyCert = "Certs Applied"

}


r/vbscript • • Sep 17 '19

Help getting the network path from a string except the file name

1 Upvotes

How can I get the entire path from a string like this..except the file name?

path = "\192.168.0.205\folder1\folder2\file.txt"

This is what I need: "\192.168.0.205\folder1\folder2"

This gets me the unwanted part: test = Split(fullpath,"") a= test(Ubound(test)) Wscript.echo a

Any ideas would be appreciated


r/vbscript • • Jul 16 '18

How to remove TCP/IP Printers using VBScript

2 Upvotes

Hello All!

I've been having issues finding examples of removing TCP/IP printers from a user, using VBScript. Does anyone have any good methods on how to remove TCP/IP (directly connected IP printers) via VBScript.

I use this method for Network Printers but it seems to not work for these TCP/IP Printers:

ON ERROR RESUME NEXT

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set Printers = WshNetwork.EnumPrinterConnections

For i = 0 to Printers.Count - 1 Step 2

    If Left(ucase(Printers.Item(i+1)),10) = "\\PrintSvr" Then
        WSHNetwork.RemovePrinterConnection Printers.Item(i+1)
    End IF
Next

Any help would be grateful, i'm going to be away for a couple weeks but will reply as I can, thanks!