Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SelectFolder()
- Dim objFolder, objItem, objShell
- On Error Resume Next
- SelectFolder = vbNull
- Set objShell = CreateObject( "Shell.Application" )
- Set objFolder = objShell.BrowseForFolder(0, "Select Config Folder", 0, "")
- If IsObject( objfolder ) Then SelectFolder = objFolder.Self.Path
- Set objFolder = Nothing
- Set objshell = Nothing
- On Error Goto 0
- End Function
- Dim ConfigDir, Username, Password
- ConfigDir = SelectFolder
- If ConfigDir = vbNull Then
- MsgBox("You didn't selected folder!")
- WScript.Quit 0
- End If
- Username = InputBox("Enter your username:")
- Password = InputBox("Enter your password:")
- Dim file, lines, config, line, new_config, auth_file
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFolder = objFSO.GetFolder(ConfigDir)
- Set lines = CreateObject("System.Collections.ArrayList")
- For Each file in objFolder.Files
- If objFSO.GetExtensionName(file.Path) = "ovpn" Then
- lines.Clear()
- Set config = objFSO.OpenTextFile(file.Path)
- Do Until config.AtEndOfStream
- line = config.ReadLine
- If (Trim(line) = "auth-user-pass") Then
- lines.Add(Replace(line, "auth-user-pass", "auth-user-pass auth.txt"))
- Else
- lines.Add(line)
- End If
- Loop
- config.Close
- Set new_config = objFSO.CreateTextFile(file, True)
- For Each line in lines
- new_config.Write line & vbCrLf
- Next
- new_config.Close
- End If
- Next
- Set auth_file = objFSO.CreateTextFile(ConfigDir + "\auth.txt", True)
- auth_file.Write Username & vbCrLf
- auth_file.Write Password & vbCrLf
- auth_file.Close
- MsgBox("Done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement