Re: How to run a script based on condition
- From: Gladius <Gladius@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 22 Jan 2007 09:08:51 -0800
Thanks Richard for your immediate response. The command you mentioned works
for me.(Wscript.Quit). I am not using any error code, since i used On Error
resume Next at the top of the program.
I have another question, since i am new to regular expressions, i would like
to check if the phone number in AD are in companys standard format.
please help me with the coding.
I am retrieving the phone number from AD and store it in a file after
formating it.
Actually, the format of the phoe numbers in AD are,
(nnn) nnn-nnnn
1-nnn-nnn-nnnn
+1(nnn) nnn-nnnn
nnn-nnn-nnnnxnnnn
(nnn) nnn-nnnnxnnnn
format.
I would like to retrieve the phone number and change to companys format. like,
(nnn) nnn-nnnn
(nnn) nnn-nnnnxnnnn
Where n represents numbers .
The first 3 digits should be numbers within paranthesis and a space and then
three digits and then a hyphen followed by four digits.
If a user has extension, then it should be of (nnn) nnn-nnnnxnnnn.
I would like to check if it is in the companys format, else, change the
format and store it in a file. I tried with the coding,
If (phoneNumber <> "") Then
Dim re
Set re = New RegExp
re.Pattern = "(\d{3})(\d{3})(\d{4})"
If (phoneNumber = re.Pattern) Then
objfile.write "<B><FONT size=2 color=black>Tel:</B><FONT size=2
color=black> " & phoneNumber & " <BR> " & vbCrLf
Else
phoneNumber = re.Replace(offno, "($1) $2-$3")
objfile.write "<B><FONT size=2 color=black>Tel:</B><FONT size=2
color=black> " & phoneNumber & " <BR> " & vbCrLf
End If
Else
Dim offno, offnor
offno=InputBox("Please enter your office phone Number ")
If (offno = re.Pattern) Then
objfile.write "<B><FONT size=2 color=black>Tel:</B><FONT size=2 color=black>
" & offno & " <BR> " & vbCrLf
ELSE
offnor = re.Replace(offno, "($1) $2-$3")
objfile.write "<B><FONT size=2 color=black>Tel:</B><FONT size=2 color=black>
" & offnor & " <BR> " & vbCrLf
END If
END If
Please help me how i can check if it is in correct format or not.
Thanks.
"Richard Mueller [MVP]" wrote:
Gladius wrote:.
I would like to run a script based on condition.store
I have a program which retrieves information from Active Directory and
it in a file. I would like to check if the file exists or not, if existsthen
the rest of the program should not run. It should exit the program, else,it
should run the program. Actually i have to place the program as a Logonnot.
script. So, the program should run once by checking the file exists or
Dim objFS1file
Set objFS1 = CreateObject("Scripting.FileSystemObject")
If (objFS1.FolderExists(FolderLocation)) Then
'If (objFS1.FileExists(HTMFileString)) Then
'Exit
'End If
Else
Call objFS1.CreateFolder(FolderLocation)
End if
What is the command to exit from the program as soon as it detects the
exists.
The statement:
Wscript.Quit
will abort the program immediately. You can also pass an error code, but
that is seldom necessary. For example:
Wscript.Quit(3)
passes the error code 3 to the program that called the VBScript, if there is
one. If a batch file launched the VBScript, you could retrieve the error
code with the DOS "errorlevel" statement. Most likely, you should just use
Wscript.Quit.
--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--
- References:
- Re: How to run a script based on condition
- From: Richard Mueller [MVP]
- Re: How to run a script based on condition
- Prev by Date: Re: How to run a script based on condition
- Next by Date: Re: Encode the script
- Previous by thread: Re: How to run a script based on condition
- Next by thread: Re: Encode the script
- Index(es):
Relevant Pages
|
Loading