Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 687

adding new paths

$
0
0
I have a VB script that goes to a folder on selection via filemaker 11.
I have been asked to add an extra path but keep getting an error.
The two scripts are below the one with 2 paths that works and the new one with 3 paths that doesn't (with the changes highlighted in red)!

This is the original script that works:

Option Explicit On

Dim jobnum
Dim pick(4)
Dim server(4)
Dim path, path2, finalpath
Dim flag
Dim configsource
Dim xdoc
Dim NL, TNL
Dim username, password, nServer, clientFolder
Dim update


configsource = "\\10.12.111.00\folder1\folder.xml"
xdoc = CreateObject("Microsoft.XMLDOM")

If Not xdoc.load(configsource) Then
MsgBox("Unable to read Configuration File")
WScript.Quit()
End If

NL = xdoc.getElementsByTagName("newfolder")

flag = 0
'Used for Folder Creation
pick(0) = "client1"
pick(1) = "client2"
pick(2) = "client3"
pick(3) = "client4"

'Server Array
server(0) = "\\10.32.12.10"
server(1) = "\\10.32.12.10"
server(2) = "\\10.32.12.10"
server(3) = "\\10.32.12.10"


jobnum = "<<IDNoJob>>"
'jobnum = "239735"

Dim fso
fso = CreateObject("scripting.filesystemobject")
Dim WsScript
WsScript = CreateObject("WScript.Shell")
Dim WshShell
WshShell = CreateObject("wscript.Shell")

Dim x
For x = 0 To NL.length - 1

username = NL.item(x).attributes.getNamedItem("username").nodeValue
password = NL.item(x).attributes.getNamedItem("password").nodeValue
nServer = NL.item(x).attributes.getNamedItem("server").nodeValue
clientFolder = NL.item(x).attributes.getNamedItem("folder").nodeValue

path = nServer + "\" + clientFolder + "\namedfolder1\" + jobnum + "\"
path2 = nServer + "\" + clientFolder + "\namedfolder2\" + jobnum + "\"

WsScript.Run("net use \\\\" + nServer + "\\ipC$/u:" + nServer + "\\" + username + " " + password, 0, True)
If fso.FolderExists(path) Then
flag = 1
finalpath = path
Exit For
Else
If fso.FolderExists(path2) Then
flag = 1
finalpath = path2
Exit For
End If
End If
Next


If flag Then
WshShell.Run("Explorer.exe " + finalpath)
End If

And this is the modified script (highlighted:
Option Explicit On

Dim jobnum
Dim pick(4)
Dim server(4)
Dim path, path2, path3, finalpath
Dim flag
Dim configsource
Dim xdoc
Dim NL, TNL
Dim username, password, nServer, clientFolder
Dim update


configsource = "\\10.12.111.00\folder1\folder.xml"
xdoc = CreateObject("Microsoft.XMLDOM")

If Not xdoc.load(configsource) Then
MsgBox("Unable to read Configuration File")
WScript.Quit()
End If

NL = xdoc.getElementsByTagName("newfolder")

flag = 0
'Used for Folder Creation
pick(0) = "client1"
pick(1) = "client2"
pick(2) = "client3"
pick(3) = "client4"

'Server Array
server(0) = "\\10.32.12.10"
server(1) = "\\10.32.12.10"
server(2) = "\\10.32.12.10"
server(3) = "\\10.32.12.10"


jobnum = "<<IDNoJob>>"
'jobnum = "239735"

Dim fso
fso = CreateObject("scripting.filesystemobject")
Dim WsScript
WsScript = CreateObject("WScript.Shell")
Dim WshShell
WshShell = CreateObject("wscript.Shell")

Dim x
For x = 0 To NL.length - 1

username = NL.item(x).attributes.getNamedItem("username").nodeValue
password = NL.item(x).attributes.getNamedItem("password").nodeValue
nServer = NL.item(x).attributes.getNamedItem("server").nodeValue
clientFolder = NL.item(x).attributes.getNamedItem("folder").nodeValue

path = nServer + "\" + clientFolder + "\namedfolder1\" + jobnum + "\"
path2 = nServer + "\" + clientFolder + "\namedfolder2\" + jobnum + "\"
path3 = nServer + "\" + clientFolder + "\namedfolder3\" + jobnum + "\"

WsScript.Run("net use \\\\" + nServer + "\\ipC$/u:" + nServer + "\\" + username + " " + password, 0, True)
If fso.FolderExists(path) Then
flag = 1
finalpath = path
Exit For
Else
If fso.FolderExists(path2) Then
flag = 1
finalpath = path2
Exit For
Else
If fso.FolderExists(path3) Then
flag = 1
finalpath = path3
Exit For
End If

End If
End If
Next


If flag Then
WshShell.Run("Explorer.exe " + finalpath)
End If


This is my first post and i would appreciate any help you can give me.
Cheers

Viewing all articles
Browse latest Browse all 687

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>