Really Baffled any clues as to what is going on?
- From: Frederick <Frederick@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 12:55:07 -0700
I am working on a script, it has an input file of machine names. I am
prompting for the name of that file and doing some error handling if the file
does not exist or the iput is blank. When the logic is in the MAIN body of
the script everything works great! Here is the logic in as a part of MAIN.
__________________________________________________________________
On Error Resume Next
Set objFS = CreateObject("Scripting.FileSystemObject")
Dim fstrInputFile
Dim fstrLogFilePath
Dim fstrErrMsg
Dim fServerList
' Get Name of Input File and Check to see if its valid
fstrInputFile = InputBox("Enter name of file containing machines to modify
Including Full path)","Machines To
Modify","C:\MigrationTools\ListOfWorkstations.txt")
Set fServerList = objFS.OpenTextFile(fstrInputFile)
If fstrInputFile = "" Then
MsgBox ("Operation Cancelled, no input file supplied")
Wscript.Quit(1)
ElseIf Err Then
MsgBox ("Error: "& Err.Description)
Wscript.Quit(1)
End if
' Get Path to Store Log File and Check to see if its valid and Writable
fstrLogFilePath = InputBox("Enter the directory to store the Log File","Log
File Path","C:\MigrationTools\Logs")
If fstrLogFilePath = "" Then
MsgBox ("Operation Cancelled, no path for the log file supplied")
Wscript.Quit(1)
End if
____________________________________________________________________
Now if I move this logic down in to a function and put the results into and
array, everything works as long as there fstrInputFile acutally exisits,
otherwise at the Set fServerList = objFS.OpenTextFile(fstrInputFile) line the
script just dies. Help would be appericated.
Here is the logic in a sub..
____________________________________________________________________
On Error Resume Next
Set objFS = CreateObject("Scripting.FileSystemObject")
'Get the path to required Inputfile And the Logfile path
GetPathArray = Split(GetPath,",")
strInputFile = GetPathArray(0)
strLogFilePath = GetPathArray(1)
Function GetPath
Dim fstrInputFile
Dim fstrLogFilePath
Dim fstrErrMsg
Dim fServerList
' Get Name of Input File and Check to see if its valid
fstrInputFile = InputBox("Enter name of file containing machines to modify
(Including full path)","Machines To
Modify","C:\MigrationTools\ListOfWorkstations.txt")
Set fServerList = objFS.OpenTextFile(fstrInputFile)
If fstrInputFile = "" Then
MsgBox ("Operation Cancelled, no input file supplied")
Wscript.Quit(1)
ElseIf Err Then
MsgBox ("Error: "& Err.Description)
Wscript.Quit(1)
End if
' Get Path to Store Log File and Check to see if its valid and Writable
fstrLogFilePath = InputBox("Enter the directory to store the Log File","Log
File Path","C:\MigrationTools\Logs")
If fstrLogFilePath = "" Then
MsgBox ("Operation Cancelled, no path for the log file supplied")
Wscript.Quit(1)
End if
GetPath = fstrInputFile & "," & fstrLogFilePath
End Function
____________________________________________________________________
.
- Follow-Ups:
- Re: Really Baffled any clues as to what is going on?
- From: Michael Harris \(MVP\)
- RE: Really Baffled any clues as to what is going on?
- From: jwarnken
- Re: Really Baffled any clues as to what is going on?
- Prev by Date: AD/OU info
- Next by Date: Re: LDAP Query on expired Accounts
- Previous by thread: AD/OU info
- Next by thread: RE: Really Baffled any clues as to what is going on?
- Index(es):
Relevant Pages
|