BIG problem with RegExp - HELPPPPP
Hi All,
I'm using the RegExp to parse some IMail Logs so that I can upload it to a
database and manage it to create special reports.
I did everything OK. The 20 logs worked fine, but in one o another, where
normally a process take just 2 minutos to do the Execute, do not stop...
took the regular CPU usage and do not stop for more than 16 hours, when I
stopped it at Task Manager.
The average of log files was about 8MB... but it worked fine with 20MB
too... took, about 0 minutos to execute.
Follow the sample code that I'm using.
Set regEx = New RegExp
REM
=======================================================================
REM Processa Leitura de Mensagens pelo IMAP4 e POP3
REM 07:21 00:02 IMAP4 (00000A34) logon success for zevallos
zevallos.com.br from 200.217.215.158
REM 07:21 00:03 IMAP4 (00000A34) logoff for zevallos R:100, D:100, P:0
REM
REM 07:21 00:03 POP3D (00000E48) logon success for autodestaque
diariodopara.com.br from 10.10.1.31
REM 07:21 00:03 POP3D (00000e48) logoff for autodestaque R:0, D:0, P:0
WScript.Echo "Processando Leitura de Mensagens pelo IMAP4 e POP3"
WScript.Echo
regEx.Pattern = "(.*:.*) (.*:.*) (POP3D|IMAP4) \((.*)\) logon success for
(.*) (.*) from (.*)\n"
regEx.IgnoreCase = True
regEx.Global = True
WScript.Echo "Search: " & Now()
Set Matches = regEx.Execute(strLogFile)
WScript.Echo " - " & Now() & " - Ítens encontrados: " & Matches.Count
Abraços,
Ruben Zevallos Jr. [ruben@zevallos.com]
+55 91 8116-7668
-------------------------------------------
Instant Messengers
Yahoo: Zevallos
AIM: RubenZevallosJr
ICQ: 2402977
MSN: RubenZevallos@hotmail.com
-------------------------------------------
HiperTools® 3.0 Developer > http://www.hipertools.com.br/
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/20/2003 Tag: Rename scheduled task name Tag: 141880
Checkbox
Hi All,
I want to display the value of my input of type check box.
How do I set the checked/ unchecked values inside the <input....>
Thanks in advance
Roberto Tag: Rename scheduled task name Tag: 141873
Variable length left border
How can I increase or decrease the height of the left border to match the
height of the body of a web page?
I'm using shared borders and want the left border to reach the bottom border
where left and bottom are block colours to avoid the nasty gap.
Brian Tag: Rename scheduled task name Tag: 141868
VBS Log Off Script
Hello,
I have already writen my login script in vbs to map network drives. In
windowsXP under an active directory with a group policy, what is the correct
syntax for a VBS file to UNmap network drives? Tag: Rename scheduled task name Tag: 141867
Newb Help: How do I find out what does in CreateObject()
Hi vbscript guru's.
I am a php mainly but php won't cut it in this situation so I think
I'm looking to vbs and/or javascript to hand off the variables to php.
I'm a vbs Noob so bear with me if my terminology is wrong.
Here is my situation.
I have a series of IE Plugins to check for (Flash, Real Audio, if the
user is using AoL, etc, etc,) I see through searching that the
CreateObject() is used with some error catching to see if the Object
is present. Error mean no plugin no error means its running
Now what I am wondering is how do I know what goes in the ()? Is
there a list that IE can spit out or something in my registry i can
lookup, or am I going to each of the major plug in makers and asking
them?
Perhaps there is an online resource for this...
Any help or direction would be appreciated.
Cheers and thanks to all in advance,
Gary Tag: Rename scheduled task name Tag: 141863
Select Case True and type mismatch
Hi,
I found this script out there on the net and it seems
perfect for what I want to do. That is Ping a series of IP
addresses and retern the info to an Excel Spreadsheet.
Unfortunatly, it uses the Select Case True method, which I
am not familliar with.
Here is the error I get when I try to run the script:
E:\Utilities\AdminTools\IP Ping.vbs(78, 2) Microsoft
VBScript runtime error: Type mismatch: '[string: "
Pinging ndcspi02."]'
And here is the code:
'IP Ping.vbs
'Ping multiple computers taken from a list in a text file
out put to an Excel Spreadsheet
' Requirments: List of IP Addresses in a file called (See
strFileName for the required text file)
' One IP Address per line
' Excel is needed
' Script was written in Windows XP using Wscript 5.6
' No blank line at the end of the script
'**********************************************************
********************************
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim strFileName : strFileName = "IPAddress.txt"
Dim Fso : Set Fso = CreateObject
("Scripting.FileSystemObject")
Dim oXLS : Set oXLS = WScript.CreateObject
("Excel.Application")
Dim WshShell : Set WshShell = createobject("wscript.shell")
Dim i
Dim intIndex
Dim oFile
Dim png
Dim strComputerIP()
Dim strIpAddress
Dim strPing
Dim strReply
Dim strRet
Dim strCname
If Not Fso.FileExists(strFileName) then
strRet = Msgbox("The file, " & strFileName & " is not
available" & vbCr _
& "The file must be located in the same folder as the
script." & vbCR _
& "Please check for the file <<" & strFileName
& ">in the folder" & vbCR _
& "<<" & Fso.GetParentFolderName
(Wscript.ScriptFullName) & ">>")
Wscript.Quit
End if
Set oFile = Fso.OpenTextFile(strFileName, 1)
'Configure Excel while leaving the spreadsheet hidden
oXLS.WorkBooks.Add
oXLS.Columns(1).ColumnWidth = 20
oXLS.Columns(2).ColumnWidth = 30
oXLS.Columns(3).ColumnWidth = 40
'Set column headers
oXLS.Cells(1, 1).Value = "IP Address"
oXLS.Cells(1, 2).Value = "Computer Name"
oXLS.Cells(1, 3).Value = "Return"
'Format text (bold)
oXLS.Range("A1:C1").Select
oXLS.Selection.Font.Bold = True
oXLS.Selection.Interior.ColorIndex = 1
oXLS.Selection.Interior.Pattern = 1 'xlSolid
oXLS.Selection.Font.ColorIndex = 2
'Left Align text
oXLS.Columns("B:B").Select
oXLS.Selection.HorizontalAlignment = &hFFFFEFDD ' xlLeft
intIndex = 2
i = 0
Do Until oFile.AtEndOfStream
Redim Preserve strComputerIP(i)
strComputerIP(i) = oFile.ReadLine
'Ping Ip Addresses
set png = WshShell.exec("ping -a -n 1 " & strComputerIP
(i))
do until png.status = 1 : wscript.sleep 10 : loop
strPing = png.stdout.readall
'NOTE: The string being looked for in the Instr is case
sensitive.
'Do not change the case of any character which appears on
the
'same line as a Case InStr. As this will result in a
failure.
Select Case True
Case InStr(strPing, "Request timed out", 1)
strReply = "Request timed out"
strCname = lcase(getcName(strPing))
Case InStr(strPing, "could not find host", 1)
strReply = "Host not reachable"
trCname = lcase(getcName(strPing))
Case InStr(strPing, "Reply from", 1)
strReply = "Ping Succesful"
strCname = lcase(getcName(strPing))
End Select
If strCName = "" then
strCname = "N/A"
End If
Call Show(strComputerIP(i), strCName, strReply)
i = i + 1
Loop
'Make the spreadsheet visable
oXLS.Visible = TRUE
Function GetcName(ByVal reply)
Dim C, tempcName
C = Instr(reply,"[")
If C = 0 Then Exit Function
TempcName = mid(reply,12,C-12)
'Used to remove the FQDN from the computer name.
GetcName = replace
(tempcName, ".ci.charlotte.nc.us", "",1)
End Function
Sub Show(strIP, strName, strValue)
oXLS.Cells(intIndex, 1).Value = strIP
oXLS.Cells(intIndex, 2).Value = strName
oXLS.Cells(intIndex, 3).Value = strValue
intIndex = intIndex + 1
oXLS.Cells(intIndex, 1).Select
End Sub Tag: Rename scheduled task name Tag: 141856
HTA (mshta.exe) won't terminate if java applet is running under XP
Hello everybody,
I searched the groups for days ...
Following Problem:
I have an HTA with a java applet in it. Works fine. And when I close
it, the window is away. But the mshta.exe process is still running and
won't terminate.
I think it's because mshta.exe is waiting for the applet to close. On
an HTML page ist works.
And the other thing: this problem occurs only under windows xp.
w2k,ME,98 will terminate mshta.exe without waiting for the applet.
The applet is running with the actual Sun VM Java 1.4.1_02 and NOT
with MS VM.
How can I unload or stop the applet, so mshta.exe will be terminated
on XP? Tag: Rename scheduled task name Tag: 141844
script to see if service is running
Does someone have a sample script I could use to run on my network to see if
a specific service is running? It is actually for remote computers so I
would need to be able to define an ip address range to scan the entire
range. I would like to be able to log it to a file. Tag: Rename scheduled task name Tag: 141841
methods, properties and events of an object
I would like to write a script (vbs) to enumerate methods, properties and
events of an object.
Any idea ?
Thanks.
Laurent. Tag: Rename scheduled task name Tag: 141836
Command Line Arguments
In a script (.vbs file), how do I capture command-line arguments? Say I have
a script named "Script.vbs" at C:\, which contains the following code:
MsgBox Command
then run it from a DOS window (at the C:\ prompt) by typing:
Script.vbs "Test"
I want a message-box to pop up with "Test" in it. However, all I get is a
blank message-box with an 'OK' button.
What do I need to put in the place of 'Command'??? Tag: Rename scheduled task name Tag: 141833
Displaying page,,,
Hi All,
I have a web page, this page has two display form methods. One is to display
a confirm delete and the
other to display a message when the record is deleted.
The problem is that when I choose Yes on the page to confirm delete only
part of the second page is display
and not all the page.
What could be the problem? Here is my code....
<%
'************************************************************
' Purpose: Organization Insert/Update page
'************************************************************
OPTION EXPLICIT
'********
'Includes
'********
%>
<!--- #include file="..\gen_functions.asp" --->
<%
'*********
'Constants
'*********
const adInteger = 3
const adCmdStoredProc = &H0004
'*****************
'Private Variables
'*****************
dim conn
dim command
dim rs
dim strFlow
'*****************************************
'Session Variables Referenced In This File
' session("OrganizationID")
'*****************************************
'***************
'Open connection
'***************
sub OpenDB
'Instantiate obj vars
set conn = Server.CreateObject("ADODB.Connection")
set command = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.RecordSet")
'Open DB
'conn.Open "advertisementDB"
conn.Open "Provider=SQLOLEDB;Data Source=ROBERTODELL;Initial
Catalog=Advertisement;User ID=sa"
end sub
'*******************************
'Setup Specific Stored Procedure
'*******************************
sub SetupProcedure(com, strProcName)
'Setup procedure
com.ActiveConnection = conn
com.CommandType = adCmdStoredProc
com.CommandText = strProcName
com.Parameters.Refresh
end sub
'********
'GetField
'********
function GetField( FieldName )
on error resume next
'Prevent exception 'Invalid Use of Null 'Marcio 08/07/2003 11:30 PM
if IsNull(rs(FieldName)) or IsEmpty(rs(FieldName)) then
GetField = CStr("")
else
GetField = rs( FieldName )
end if
'If error, return it
if err.number <> 0 then
strMessage = "* " & err.Description
strFlow = "Error"
GetField = ""
end if
end function
'******
'Delete
'******
sub Delete
on error resume next
'Optional parameters (do not fill out optional parameters, procedure will
make it NULL)
if request.form("hdnOrganizationID") <> "" then
command.Parameters("@OrganizationID") =
request.form("hdnOrganizationID")
end if
if session("OrganizationID") > 0 then
command.Parameters("@OrganizationID") = session("OrganizationID") 'Will
be null when inserting
end if
'Execute command... be ready to display exceptions generated by DB
command.Execute
'If an error happened in DB
if err.Number <> 0 then
strFlow = "Error" 'This will force form to load previous values
strMessage = "* " & err.Description
'No errors in DB
else
'If save and new, reset client id and reload form
if strFlow = "Delete" then
session("OrganizationID") = 0
end if
'Display form and message... successfully updated
strMessage = "Organization successfully deleted."
end if
'Always display the form. GetField() and GetLookup() will know from where
to populate
DisplayFormAfterDelete
end sub
'*****************
'PopulateForDelete
'*****************
sub PopulateForDelete
on error resume next
'Fill parameters and Execute command
command.Parameters("@OrganizationID") = session("OrganizationID")
'Execute command... be ready to display exceptions generated by DB
set rs = command.Execute
'If an error happened in DB
if err.number <> 0 then
strFlow = "Error" 'This will force form to load previous values
response.write "<center><br><font color='red'>" & err.Description &
"</font></center>"
end if
end sub
'****************
'Close Connectoin
'****************
sub CloseDB
'Close DB when state is not adStateClosed
if rs.State <> 0 then rs.Close
if command.State <> 0 then command.Close
if conn.State <> 0 then conn.Close
'Release mem
set rs = nothing
set command = nothing
set conn = nothing
end sub
'************
'Display Form
'************
sub DisplayForm
%>
<html>
<head>
<title>Advertisement System - Delete Organizations</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="javascript">
// T r i m ! ! !
function trim( inputString )
{
// Removes leading and trailing spaces from the passed string. Also
removes
// consecutive spaces and replaces it with one space. If something
besides
// a string is passed in (null, custom object, etc.) then return the
input.
if( typeof inputString != "string")
return inputString;
// Vars
var retValue = inputString;
var ch = retValue.substring(0, 1);
// Check for spaces at the beginning of the string
while( ch == " " )
{
retValue = retValue.substring( 1 , retValue.length );
ch = retValue.substring( 0 , 1 );
}
// Check for spaces at the end of the string
ch = retValue.substring( retValue.length - 1, retValue.length );
while( ch == " " )
{
retValue = retValue.substring(0, retValue.length-1);
ch = retValue.substring(retValue.length-1, retValue.length);
}
// Note that there are two spaces in the string - look for multiple
spaces within the string
while( retValue.indexOf(" ") != -1 )
// Again, there are two spaces in each of the strings
retValue = retValue.substring(0, retValue.indexOf(" ")) +
retValue.substring(retValue.indexOf(" ")+1, retValue.length);
// Return the trimmed string back to the user
return retValue;
}
// Performs validation and submits the form
function Validate( action )
{
if (action == 'No')
{
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
return;
}
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
}
</script>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<table width="800" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="800" height="23" valign="top"> <table width="100%"
border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana,
Geneva, Arial, Helvetica, sans-serif; font-size: x-small; color: Black;">
<tr>
<td width="21" height="23"></td>
<td style="font-weight: bolder; font-size: small; font-variant:
small-caps; ">
Welcome <%= session("AdminName") %>! </td>
<td width="461"></td>
<td width="93" valign="top"> <div align="right"><font
face="Arial, Helvetica, sans-serif"><b><font size="3"><a
href="..\login.asp"><font
size="2">LogOut</font></a></font></b></font></div></td>
<td width="22"></td>
</tr>
</table></td>
</tr>
</table>
<br>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
<form id="Organization" method="post" action="Organization_D.asp"
name="Organization">
<table align="rigth" width="100%" border="0" cellpadding="1"
cellspacing="1" halign="right" style="font-family: Verdana, Geneva, Arial,
Helvetica, sans-serif; font-size: xx-small;">
<!--DWLayoutTable-->
<tr>
<td width="89" height="15"></td>
<td width="204"></td>
<td width="369"></td>
<td width="83"></td>
</tr>
<tr>
<td height="25"></td>
<td align="right" valign="center"> <font face="Arial, Helvetica,
sans-serif" size="2" color="red">*</font>
Name</td>
<td valign="middle"><%= GetField("Name")%> </td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="center">Activity</td>
<td valign="middle"><%= GetField("Activity")%></td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact First Name</td>
<td valign="middle"><%= GetField("FirstName")%></td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact Last Name</td>
<td valign="middle"><%= GetField("LastName")%> </td>
<td></td>
</tr>
<tr>
<td height="23"></td>
<td align="right" valign="middle">Contact Email</td>
<td valign="middle"><%= GetField("Email")%></td>
<td></td>
</tr>
<tr>
<td height="34"></td>
<td> </td>
<td></td>
<td></td>
</tr>
<tr>
<td height="45"></td>
<td colspan="2" align="center" valign="middle" > <input
name="hdnFlow" type="hidden" id="hdnFlow2">
<input type="hidden" name="hdnOrganizationID" >
Are you sure you want to delete this record? <br>
<input name="btnYes" type="button" style="cursor:hand"
onClick="Validate('Yes')" value="Yes">
<input type="button" name="btnNo" onClick="Validate('No')"
value="No" style="cursor:hand" >
</td>
<td> </td>
</tr>
<tr>
<td height="24"></td>
<td> </td>
<td></td>
<td></td>
</tr>
</table>
</form>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
</center>
</body>
</html>
<%
end sub
sub DisplayFormAfterDelete
%>
<html>
<head>
<title>Advertisement System - Deleted</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<center>
<script language="JavaScript">
// Performs validation and submits the form
function validate( action )
{
if (action == 'No')
{
// Ready to submit
Organization.hdnFlow.value = action;
Organization.submit();
return;
}
}
</script>
<br>
<table width="778" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="778" height="40" valign="top"> <table width="100%"
border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana,
Geneva, Arial, Helvetica, sans-serif; font-size: x-small; color: Black;">
<!--DWLayoutTable-->
<tr>
<td width="21" height="36"></td>
<td width="236" valign="top" style="font-weight: bolder;
font-size: small; font-variant: small-caps; ">
Welcome <%= session("AdminName") %>! </td>
<td width="313" align="left" valign="middle" id="msgMessage"
style="font-weight: normal; font-size: xx-small;color: red; font-family:
verdana,tahoma,monospace; ">
<%= strMessage%> </td>
<td width="208" valign="top"> <div align="right"><font
face="Arial, Helvetica, sans-serif"><b><font size="3"><a
href="..\login.asp"><font size="2">
LogOut</font></a></font></b></font></div></td>
</tr>
<tr>
<td height="4"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table></td>
</tr>
</table>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
<form id="Organization" method="post" action="Organization_D.asp"
name="Organization">
<br>
<font style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: xx-small;">Go to Organization Browser </font>
<br>
<br>
<input name="btnGo" type="button" onclick="validate('No')"
style="border-bottom-style: groove; border-bottom-width: thin;
border-left-style: groove; border-left-width: thin; border-top-style:
groove; border-top-width: thin; border-right-style: groove;
border-right-width: thin; cursor:hand; background-color: #ADD8E6;"
value="Go">
<input type="hidden" name="hdnFlow" >
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</form>
<!--- #include virtual= "/advertisement/admin/menu.html" --->
</center>
</body>
</html>
<%
end sub
'*******
'M A I N
'*******
'Verify if login is not expired
CheckLoginSession
'Get the flow information from hidden field
if request.form( "hdnFlow" ) <> "" then
strFlow = request.form( "hdnFlow" )
else
strFlow = "Confirm"
end if
'Get the affiliateid from querystring
if request.querystring( "id" ) <> "" then
session( "OrganizationID" ) = CInt(request.querystring( "id" ))
'strFlow = "Confirm"
end if
'****************************************************
'Understand the navigation flow controlled by strFlow
'
' "Delete : Blank form - GetField returns blanks. Thus, load form with
blanks
' "Error" : Will populate form like in "Delete", based in response.form()
'
'****************************************************
select case strFlow
'Yes
case "Yes", "Delete"
OpenDB
SetupProcedure command, "dOrganization"
Delete
CloseDB
' Error or Update
case "Confirm", "Error"
OpenDB
'If delete, populate form to confirm
if strFlow = "Confirm" then
SetupProcedure command, "sOrganization"
PopulateForDelete
end if
DisplayForm
CloseDB
' When user choose No, it backs to the Affiliate browser
case "No"
response.redirect"brw.asp?sbj=Organization"
end select
%>
Thanks in advance
Roberto Tag: Rename scheduled task name Tag: 141827
VBScript Word Automation Table Error
Hi all, I'm using VBScript to create a Word doc from a web page. Everything
was going fine until I tried to add a table to the doc, then I get an error
which I can't account for. This is my code:
function test
dim oWord dim oDoc
set oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Add
set oDoc = oWord.ActiveDocument
oDoc.PageSetup.Orientation = 1
oDoc.Tables.Add Range:=oWord.Selection.Range, NumRows:=2,
NumColumns:=3
oWord.Selection.TypeText "Ben was here"
set oWord = nothing
end function
This runs fine if I comment out the oDoc.Tables.Add line. I have tried
approaching the tables call from all directions, eg.
oWord.ActiveDocument.Tables.Add, as well as the Range call, with no luck.
I'm running IE6 and Office XP.
Any help would be greatly appreciated :o)
Regards, Ben Empson
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ Tag: Rename scheduled task name Tag: 141815
Disabling CANCEL button during shell file copy
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I'm using the following script to copy files which provides a copy progress
dialog box. What I want to do is disable the CANCEL button during the copy.
Does anyone know of any way to do this?
Thanks,
Chris
SCRIPT:
'Respond with "Yes to All"(16) + Display dialog but no files(256) + Do not
confirm the creation of directory(512)
Const FOF_CREATEPROGRESSDLG = 784
ParentFolder = "D:\DATABACK"
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.NameSpace(ParentFolder)
objFolder.CopyHere "D:\TESTING", FOF_CREATEPROGRESSDLG
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0
Comment: Public PGP key for Chris Lynch
iQA/AwUBP0uLDG9fg+xq5T3MEQIBiACfbvKo6gvf6s4eLrlVbdxRuy6QUGUAnRJD
08BGtfO9xjqlWQqF1sTxHYfL
=7O0m
-----END PGP SIGNATURE----- Tag: Rename scheduled task name Tag: 141806
username and computer name in vbscript/asp/java/wsh?
Hi, I have seen this topic come up many times but have never really
seen a concise answer to the problem. Basically what I have is an asp
page that is using ado to do some database queries. I have an
activity log table in my database that I would also like to update
when certain events are triggered on the webpage. In this activity
log I wanted to have the network username and the computer name of the
person that was using the webpage. I thought VBScript would be best
for this because it runs client-side but I have not found a solution
yet. Though this webpage will be running on my company's intranet, we
are a company of 6000 and I have absolutely NO control over the server
it will be running on. Any help would be awesome. Thanks!
-Jeremy Tag: Rename scheduled task name Tag: 141805
transfering data from .csv to .xls
Hi,
I am using Activex scripts in SQL Server DTS Packages to
read from a .csv file and write it to a Excel file. The
actual problem is the leading zeroes are being truncated
in the XL file.
Hence, I use ActiveSheet.QueryTables.Add method to define
the formating properties that I require. It creates the
Excel file successfully but it neither transfers the data
nor does it format the cells. Below is my code. Pls.
let me know if I am going with the right approach. VERY
URGENT.
If any of you can suggest me an alternate way on how I
can transfer the data from .csv to .xls without loosing
the leading zeroes, I would be really grateful.
with regards,
Ram
Function Main()
Dim Xcl
Dim strDestinationFileName
Dim strSourceFileName
'strDestinationFileName
= "D:\_Clients_Data\Monument\Order\vipul2.xls"
strSourceFileName = DTSGlobalVariables
("Data_File_Path")&DTSGlobalVariables("Data_File_Name")
strDestinationFileName = DTSGlobalVariables
("Schema_File_Path")&DTSGlobalVariables
("Schema_File_Name")
Set Xcl = CreateObject("Excel.Application")
Xcl.Visible = true
Set newBook = Xcl.Workbooks.Add
newBook.Worksheets(1).Name="My First WorkSheet"
newBook.Worksheets(2).delete
newBook.Worksheets(2).delete
newbook.Worksheets(1).Activate
'importing the .csv file
With ActiveSheet.QueryTables.Add
(Connection:= "TEXT; D:\_Clients_Data\Monument\Order\09-
03_Order_Monument.csv", Destination:= Range ("A1") )
.Name = strDestinationFileName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier =
xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(2, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1)
.Refresh BackgroundQuery:= False
End With
newBook.SaveAs strDestinationFileName
Xcl.Visible = false
Set Xcl = nothing
Main = DTSTaskExecResult_Success
End Function Tag: Rename scheduled task name Tag: 141804
Highlight Text in Control
Greetings,
I am not sure if this is possible, but within ArcPad
Studio 6.0.1.2OU (ArcPAd is basically pared down desktop
GIS software for PDAs). I am doing my development on a
Windows 2000 machine, but the resultant code is placed on
an IPaq handheld.
I have an edit control in a form. The control is bound to
a DBF file and shows data if it is populated or "0"
(integer field in the DBF) if it is not.
I want to be able to highlight whatever text is in that
control (i.e. background of selected text is navy blue,
the text is white, and the caret/cursor is all the way to
the right of the selected string).
The tools that are being written are for handheld devices
that field workers will be utilizing with a stylus. The
fewer the clicks/taps they must make with the stylus, the
more efficient their use of our tool.
Any idea then, on how to highlight text in a VBScript edit
control ?
Best regards,
Jason Ramirez
...I know, I'm garrulous :) Tag: Rename scheduled task name Tag: 141791
Could not load type '****.Global'
I'm working my way through the .net Mappoint Web services sample code, but I
keep experiencing this error - "Could not load type '****.Global'" (where
**** is the application name). I've had a look through the news group for
similar problems but I've had no luck with of the suggested solutions. For
the record I've checked that the projects been built, the web service is
correctly named and the application is set up in IIS.
Any other suggestions? Tag: Rename scheduled task name Tag: 141786
Output PDF
I have the following code ...
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, f, ts
Set fso = CreateObject("Scripting.FileSystemObject")
strPhyPath = Server.MapPath("/paysonnelCE/Misc/Bernard")
Set f = fso.GetFile(strPhyPath & "\test.pdf")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.BinaryWrite ts.ReadAll
Response.Flush
the purpose is to stream a pdf to client... but all I get is the details,
ascii codes of the pdf ... anyway I can get a pdf instead of ascii text
display ? Tag: Rename scheduled task name Tag: 141782
Remote comuter access + FileSystemObject?
Hi! :-)
I'd like to know if it's possible to access the FileSystemObject on a remote
machine. In this case to check the remainging space on the HDs of my file
server.
Right now I can only access the local machine with:
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
For Each objDrive In objFileSystem.Drives
If objDrive.DriveType = 2 Then 'Local Disc
WScript.Echo objDrive.Path
WScript.Echo "Size: " & objDrive.TotalSize
WScript.Echo "Free: " & objDrive.FreeSpace
...
End If
Next
And check the directory sizes with:
Set objFolder = objFileSystem.GetFolder(strPath)
WScript.Echo strPath & " " & objFolder.Size
Is it at all possible to do this on a remote mashine and if so, how?
Thanks a million! :-)
/Sofia Engvall
AB Ångpanneföreningen Tag: Rename scheduled task name Tag: 141781
convert an html form post to a script
Hi
I have a form that posts to a CGI script. I would like to automatically send
multi posts to the CGI Script. Can anyone point me in the direction of how
to I can emulate the form post from inside a Script?
Regards and Thanks!!!
Meir Tag: Rename scheduled task name Tag: 141780
How to delete all jobs in a print queue by vbs?
Hi there,
Does anyone know how to delete all jobs in a print queue by vbs?
When I restart one of my Company's printer, all old print jobs will print
again,
so I want to write a script to fix it.
Thank you in advanced.
Regards,
Stanley Tag: Rename scheduled task name Tag: 141775
find a string in a file
Hello,
I am writing a VBString, what is the fastest way to open
a file and search a string and read a few characters
after that string?
Thanks,
Jim. Tag: Rename scheduled task name Tag: 141768
Displaying line number with custom error message?
Hello;
I'm trying to create a custom error capturing function that writes VBScript
errors to the computer's Event Log. I've been able to do most of what I
want so far, but I can't figure out how to write the line number of where
the error occurred... is that even possible?
Sincerely,
Todd M. Taylor Tag: Rename scheduled task name Tag: 141760
How to read a text file from web server
Hi guys,
Does anybody know how to read a text file from web server?
For example, read test.txt file from: http://abc/test.txt
Any comments will be highly appreciated.
Thanks Tag: Rename scheduled task name Tag: 141755
Computer name
Hello all,
I want to use a list of computers that I have serial numbers and
corresponding asset numbers for to rename the computers. I have the
compname.exe that works great but want to go a step further.
Is there a way to have vbscript detect the serial number of a computer
then use a list that associates a different name to the serial number
and have the script rename based on that?
Step 1:
Identify & Capture serial number
Step 2:
Compare serial number to list ie
serial number asset number
123456 abcdefg
Step 3:
Rename the computer so that if serial number = 123456 then
computername = abcdefg.
Thanks in advance for any help. Tag: Rename scheduled task name Tag: 141753
[newbie] Status of ActiveX-based web apps?
Hi,
We're currently checking out all our options to move from
VB-written dedicated apps to web applications, and that obviously
includes pages that include ActiveX and VBScript. I took a look on
Amazon, and noticed the dearth of books on the subject.
Hence my question : Apart from the fact that the ActiveX + VBScript is
an MS-only solution (which is not an issue with our customers)... why
so much exposure for Java or .Net, and so little for this alternative?
Are there technical issues that we'll see later as we investigate
further?
Thx for any feedback
JD. Tag: Rename scheduled task name Tag: 141751
Copy folder and progress bar.
Does anyone know of an efficient way of reporting the status (% complete) of
the folderobject.copy method?
I'm using the following to copy fair amounts of data (700 - 1000 Mb) in a
complexe directory structure.
*******************
Set fso = CreateObject("Scripting.FileSystemObject")
Set folderObject = fso.GetFolder("D:\somepath")
folderObject.Copy "e:\",TRUE
******************
I need to be able to show progress in either a progress bar or at the vey
least by feeding a percentage completed to a log windows.(wihich I already
have built using IE and an hta form.
Thanks
Pierre Tag: Rename scheduled task name Tag: 141749
WSH 5.6 debugging is available now!
Script Debugger IDE supports WSH debugging now!
New features you can see here:
http://www.script-debugger.com/products/scrdebugger/debugwsh.asp Tag: Rename scheduled task name Tag: 141743
Script problems (write routine)
Hello
I have a VBScript that sometimes works fine but often sucks - problem
in combination with WSH? 1st here is the part of the script making
trouble:
(note: following URL is an example)
private function writefile()
GetURL = www.someurl.com\index.php3?TYPE=Right
Dim Http
Set Http = CreateObject("Microsoft.XMLhttp")
Http.Open "GET",GetURL,False
Http.Send
HtmlResult = Http.ResponseText
HtmlResult = right(HtmlResult, len(HtmlResult) - instr(HtmlResult,
"<!-- Daten... -->"))
HtmlResult = left(HtmlResult, len(HtmlResult) - instr(HtmlResult,
"</body>"))
Set Http = Nothing
set fs=CreateObject("Scripting.FileSystemObject")
set f1=fs.CreateTextFile("test.tmp",true)
f1.write(HtmlResult)
f1.close
set f1=nothing
set fs=nothing
writefile = "Tempfile written."
end function
OK however the script only works when:
- I installed WSH 5.6 (is there a localized version oder only english?)
and reboot
- and run this script (in a Application supporting VBS-files) and it
works fine but
- after next reboot the Script terminates and also the application
script is running in terminates unexpected without promting or an
failure message.
Only when I re-install the WSH and after 1st reboot script also works.
So is this a WSH-Bug or where's the problem?
Note: I guess, the problem is the .write - routine because when the
script terminates, no such file has been written.
Kind regards, Torsten
--
"Outside is where the pizza comes from" Tag: Rename scheduled task name Tag: 141738
Generalized Time
How to read out the AD-property "createTimeStamp" (data type
GeneralizedTime) of an user object and convert to a readable string like
dd/mm/yyyy ?
Thanks for help Tag: Rename scheduled task name Tag: 141733
Server.MapPath
Hello,
I have an ActiveX-DLL (using VB-script) that creates some files.
When I use a direct path ("c:\wwwroot\...), the script works fine (see
below)
But if I use the Server.MapPath() there is an error: "Object required"
When I use the code in an ordinary .asp-file the Server.MapPath works fine.
' ----- Create the .fil-file
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.CreateTextFile("c:\inetpub\wwwroot\catalog\" & temp &
"\" & fname & ".fil", True)
' Set f = fs.CreateTextFile(Server.MapPath(temp & "\" & fname &
".fil", True))
Anyone know what I can do?
Regards,
/Mikael S Tag: Rename scheduled task name Tag: 141729
IP Address (Simplest script possible)
I want to put in my websote to grab the clients IP address and write it out.
Any help would ne great thanks! Tag: Rename scheduled task name Tag: 141720
how to debug .vbs script?
I'm running win2000 sp3 - and have VS.NET 2003 installed - as well as Visual
Studio - and the script debugger.
I'd like to be able to open a test.vbs script in a debugger (not run it in IE,
but as a stand alone ap) and set a breakpoint and run it - but how to accomplish
this simple task eludes me.
What is the best way to do this? I've got some .vbs scripts (that go with some
MS .NET sample code) that do not seem to work - and I'd like to fix them rather
than wait on MS.
--
Thanks in advance, Les Caudle Tag: Rename scheduled task name Tag: 141719
write to a file
Hello,
I do not know anything about VBScript yet. How can I
write a vbs file in windows 2000 that handles the
following?
1. Open a text file
2. jump a few lines
3. read the rest of lines and write to another file
4. exit
Any Help?
Thanks
Jim. Tag: Rename scheduled task name Tag: 141716
GetFile Method, ASP 3.0 & VBScript, Win NT 4.0 Server
This line of code is causing IIS 4.0 on Win NT 4.0 server
to hang infinately...
set objFile = objFSO.GetFile(strPhysicalPath)
The code works as expected on IIS 5.0/Win 2000 server.
When I comment out that line the page will display with no
problem. I have reinstalled the scripting runtime library
3 times (scr56en.exe).
Is there an issue with the GetFile method of the
FileSytemObject on Win NT 4.0 that I need to know about?
Please advise.
thanks,
Ron
p.s. the server has Service Pack 6a, and all security
patches as of today. Tag: Rename scheduled task name Tag: 141708
SQL VBscript Class help needed
Hi All.
Win 2kpro, sql server 2k, iis5 vbscript asp
Learning vbscript
I was wondering if anyone could help me with a VBscript CLASS I have
that I use for connecting to our database and execute stored procs.
I've included my CLASS to this message. Could someone please take a
look at it and possibly correct & alter it to make it better.
One bit I would like added is to beable to RETURN a value from a
Stored Procedure rather than a recordset using the class. I've tried
to comment it as much & clear as I can.
If anyone has any useful vbscript CLASS code that they wouldn't mind
sharing - I'd appreciate it.
Thanks for all the help & tips in advance.
Al
<%
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| Class : clsDBErrorChecker
|
'| Language : VBscript
|
'| Description : Used for checking DB for errors & Executing SQLs
|
'| Copyright : (c) 2003 Alan Spencer (Harag)
|
'|---------------------------------------------------------------------------------------------------------------------|
'| Properties : TotalErrors (read)
|
'| : AnyErrors (read)
|
'| : ExtraInfo (Write)
|
'| : InFunction (write)
|
'| : ConnectAs (write)
|
'|---------------------------------------------------------------------------------------------------------------------|
'| Methods : OpenDBConnection
|
'| : CloseDBConnection
|
'| : BeginTrans
|
'| : CommitTrans
|
'| : RollbackTrans
|
'| : Execute (sql, ReturnRS? T/F)
|
'| : OpenRS (sql, cursortype, locktype, options)
|
'| : OpenIntoArray (sql, Rows,Start,Array(fileds))
|
'| : ClearErrors
|
'| : GetFullError(x)
|
'| : GetAllFullErrors
|
'| : GetUserDefinedError
|
'| : SetInfo
|
'| : ResetInfo
|
'|---------------------------------------------------------------------------------------------------------------------|
'| Private : (S) ReportConnectionClosed
|
'| : (F) IsConnectionOpen
|
'| : (S) UpdateConnectionString
|
'|______________________________________________________________________________|
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| Options : adCmdText, adCmdStoredProc, adExecuteNoRecords
|
'|______________________________________________________________________________|
'| EXAMPLE OF USAGE (copy the text below and uncomment all the first
rem) |
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
' In Global.asa file:
' ***user*** & ***pass*** are altered via the DBclass
' Application("sDBConnection") = "Provider=SQLOLEDB; Data
Source=(local); Initial Catalog=dbnamehere; User ID=[***USER***];
Password=[***PASS***]; Persist Security Info=True"
'
---------------------------------------------------------------------------------------------------------------------
'
' 'Declare class
' DIM clsDBCheck, oRSfoobar
' set clsDBCheck = new clsDBErrorChecker
' ' Set the connection username
' clsDBCheck.ConnectAs = CONNECTAS_VSUser '
CONNECTAS_VSUser is the default
'
' ' Setup info code incase of error
' clsDBCheck.SetInfo "YourFunctionName", "Some info for finding
line in code easier. eg a linenumber or section header"
' ' create SQL string
' sSQL="usp_TEST_DisplaySecurityLevelUsers 16"
'
' ' run SQL string
' set oRSfoobar = clsDBCheck.OpenRS (sSQL, adOpenKeySet,
adLockPessimistic)
' ' ***OR ***
' set oRSfoobar = clsDBCheck.Execute (sSQL, true) '
return records
' ' ***OR ***
' clsDBCheck.Execute (sSQL, false) ' return no records
' ' ***OR ***
' MyArray = clsDBCheck.OpenIntoArray (sSQL, 0, 0, "")
'
' ' if any errors then report the errors else do stuff with
record set.
' if clsDBCheck.AnyErrors then
' Out clsDBCheck.GetAllFullErrors
' else
' ' SQL ran with no errors.
' if not oRSfoobar.BOF and not oRSfoobar.EOF then
' do
' ' Do some stuff here
' oRSfoobar.MoveNext
' loop until oRSfoobar.EOF
' end if
' oRSfoobar.Close
' end if
'
' ' Finally close & free memory
' clsDBCheck.CloseDBConnection
' set clsDBCheck = nothing
'_______________________________________________________________________________
'|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| S T A R T O F T H E C
L A S S
|
'|______________________________________________________________________________|
CONST NO_EXTRA_INFO = "<B><I>***None***</B></I>" ' default
extra info text (const)
CONST IN_FUNCTION = "<B><I>***Main***</B></I>" '
default function text (const)
' these are for DB security to connect using different login names
CONST CONNECTAS_User =1
CONST CONNECTAS_Admin =2
CONST CONNECTAS_Executive =3
CONST CONNECTAS_MAX=3
CLASS clsDBErrorChecker
'_____________________________________
'| Declare some PRIVATE variables for the class |
'¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
PRIVATE msConnString ' String
holding the actual Connection info
PRIVATE moConnection ' Connect
object to the DB - ADODB.Connection
PRIVATE mbIsConnectionOpen ' Boolean True if connetted to
DB
PRIVATE miConnectAs '
Username/password ID for connecting to DB
PRIVATE maConnectAsArray(3,1) ' Array of users &
Passwords
PRIVATE msExecutedSQL ' The executed SQL
PRIVATE msExtraInfo '
Extra info for the error results
PRIVATE msInFunction ' stores the
function name set for error results
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| I N I T I A L I Z E F U N C T I O N S
|
'|______________________________________________________________________________|
' Initialize the class, set up default variables erc.
PRIVATE SUB Class_Initialize
msExtraInfo = NO_EXTRA_INFO
msInFunction = IN_FUNCTION
mbIsConnectionOpen=false
' set the default user to connect as (public)
miConnectAs= CONNECTAS_User
' load all the username & passwords into an array
maConnectAsArray (CONNECTAS_User, 0) =
"publicusernamehere"
maConnectAsArray (CONNECTAS_User, 1) =
"userpasswordhere"
maConnectAsArray (CONNECTAS_Admin, 0) =
"siteadminusername"
maConnectAsArray (CONNECTAS_Admin, 1) =
"adminpassword"
maConnectAsArray (CONNECTAS_Executive, 0) =
"dbousernamehere"
maConnectAsArray (CONNECTAS_Executive, 1) =
"executivepasswordhere"
UpdateConnectionString
' Create The connection Object for the class
set moConnection = Server.CreateObject
("ADODB.Connection")
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' When class is terminated also terminate the connection to
the DB to free up resources
PRIVATE SUB Class_Terminate
' Close the connection Object and clear it
CloseDBConnection
set moConnection=nothing
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| P R O P E R T I E S
|
'|______________________________________________________________________________|
' will return 0 if none or >0 if there is any.
PUBLIC Property get AnyErrors
if TotalErrors >0 then
AnyErrors=true
else
AnyErrors=false
end if
End Property
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' returns the number of DB errors
' If warnings then reduces the number.
' eg "Cursor Type Changed"
PUBLIC Property get TotalErrors
DIM TotErr, NatErr, x, xx
TotErr = moConnection.Errors.Count
if TotErr > 0 then
xx = TotErr - 1
for x = 0 to xx
NatErr =
moConnection.Errors.Item(x).NativeError
if NatErr = 0 then
TotErr = TotErr - 1
end if
Next
end if
TotalErrors=TotErr
End Property
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' changes the connection string to a new username & password
as some Stored procs have
' different permissions from "public"
PUBLIC Property let ConnectAs (ByVal iNewConnect)
if iNewConnect <1 or iNewConnect > CONNECTAS_MAX then
iNewConnect = CONNECTAS_user
end if
' if changing to a new connect user then close DB and
reset ConnectionStr
if miConnectAs <> iNewConnect then
miConnectAs =iNewConnect
UpdateConnectionString
CloseDBConnection
end if
End Property
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' stores a string incase error is found and displayed, put
handy info to find line in code
PUBLIC Property let ExtraInfo (ByVal sInfo)
sInfo=trim(sInfo)
if sInfo="" then
msExtraInfo = NO_EXTRA_INFO
else
msExtraInfo = sInfo
end if
End Property
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' If Executing a SQL/stored proc in a FUNCTION then set this
to the FUNCTION name for ease of finding error
PUBLIC Property let InFunction (ByVal sInfo)
sInfo = trim(sInfo)
if sInfo = "" then
msInFunction = IN_FUNCTION
else
msInFunction = sInfo
end if
End Property
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| F U N C T I O N S / S U B S
|
'|______________________________________________________________________________|
' Opens up a connection to the DB - String must be valid
connection str.
'eg: "Provider=SQLOLEDB; Data Source=ServerName; Initial
Catalog=DBName; User ID=UserName; Password=UserPassowrd; Persist
Security Info=True"
' this string is altered using the "connectAs system"
PUBLIC SUB OpenDBConnection(ByVal sConnectionString)
moConnection.Open sConnectionString
mbIsConnectionOpen = true
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Closes a connection to the DB
PUBLIC SUB CloseDBConnection ()
if mbIsConnectionOpen then
moConnection.Close
mbIsConnectionOpen = false
end if
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Begin a DB transaction
PUBLIC SUB BeginTrans()
if IsConnectionOpen then
moConnection.BeginTrans
end if
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Commit the transaction
PUBLIC SUB CommitTrans()
if IsConnectionOpen then
moConnection.CommitTrans
End if
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Rollback the DB transaction
PUBLIC SUB RollbackTrans()
if IsConnectionOpen then
moConnection.RollbackTrans
End if
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Execute a SQL/storedproc on the DB
' NOTE: returns with a CursorType of FORWARD_ONLY - if you
want a different cursor type then
' use the "OpenRS" function
PUBLIC FUNCTION Execute (ByVal sSQL, ByVal bReturnRS)
DIM rs, lOptions
lOptions = adCmdUnknown
if IsConnectionOpen then
if not bReturnRS then
lOptions = lOptions+adExecuteNoRecords
end if
msExecutedSQL=sSQL
on error resume next
set rs = moConnection.execute
(msExecutedSQL, ,lOptions)
on error goto 0
if TotalErrors>0 then
if not lOptions AND adExecuteNoRecords
then
set Execute =
Server.CreateObject ("ADODB.Recordset")
end if
else
if not lOptions AND adExecuteNoRecords
then
set Execute=rs
end if
end if
end if
set rs=nothing
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' set oRSfoobar = clsDBCheck.OpenRS (sSQL, adOpenKeySet,
adLockPessimistic)
' CursorType, LockType, Options
' Allows you to set a cursor type to override executes default
PUBLIC FUNCTION OpenRS (ByVal sSQL, ByVal iCursorType, ByVal
iLockType)
' adOpenKeySet, adLockPessimistic
DIM rs
if IsConnectionOpen then
set rs=Server.CreateObject ("ADODB.Recordset")
rs.CursorLocation=adUseClient
msExecutedSQL=sSQL
on error resume next
rs.Open msExecutedSQL, moConnection,
iCursorType, iLockType
on error goto 0
if TotalErrors>0 then
set OpenRS = Server.CreateObject
("ADODB.Recordset")
else
set OpenRS=rs
end if
end if
set rs=nothing
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' Run an SQL/StoredProc and load the recordset into an array.
PUBLIC FUNCTION OpenIntoArray (ByVal sSQL, iRows, iStart,
aFieldsArray)
DIM rs
if IsConnectionOpen then
if iRows=0 then iRows=adGetRowsRest ' get
all rows
if iStart=0 then iStart=adBookmarkfirst '
start at the begining
msExecutedSQL=sSQL
set rs= OpenRS (msExecutedSQL, adOpenStatic,
adLockPessimistic)
if TotalErrors>0 then
OpenIntoArray = "" ' return a
string so user can check for (IsArray)
else
if not rs.BOF and not rs.EOF then
if IsArray(aFieldsArray) then
OpenIntoArray =
rs.getrows(iRows, iStart, aFieldsArray)
else
OpenIntoArray =
rs.getrows(iRows, iStart)
end if
else
OpenIntoArray=null
end if
end if
end if
set rs=nothing
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' clear the errors if your want... not really needed
PUBLIC SUB ClearErrors
moConnection.Errors.clear
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' returns a string of ONE error in an HTML format.
PUBLIC FUNCTION GetFullError(ByVal iErr)
DIM Tot, sTemp, En, errErrors
' 3621 = The statement has been terminated
Tot=TotalErrors
set errErrors = moConnection.Errors.Item(iErr)
if Tot>0 and iErr>=0 and iErr<=Tot-1 then
sTemp=""
En=errErrors.NativeError
if en <50000 then
if en <> 3621 then
sTemp=sTemp & "<P
STYLE=""text-align:left""><SPAN STYLE=""color:#990000""><B>DB
ERROR:</B></SPAN> <B>[File: </B>"&Request.ServerVariables
("SCRIPT_NAME")&"<B>]</B> "
sTemp=sTemp &
"<BR><B>[User:</B>"&maConnectAsArray (miConnectAs, 0)
&"<B>]</B><B>[Func: </B>"&msInFunction&"<B>]</B><B>[xInfo:
</B>"&msExtraInfo&"<B>]</B>"
sTemp=sTemp & "<BR><B>[ERR
SRC: </B>" & errErrors.source &"<B>]</B>"
sTemp=sTemp &
"<BR><B>[NativeError: </B>" & errErrors.NativeError &"<B>]</B> <B>[Err
Number: </B>"&errErrors.number & "<B>]</B> <B>[SQLstate:
</B>"&errErrors.SQLState & "<B>]</B>"
sTemp=sTemp & "<BR><B>[Desc:
</B>"& errErrors.Description&"<B>]</B>"
sTemp=sTemp & "<BR><B>[SQL:
</B>"&msExecutedSQL&"<B>]</B>"
end if
else
sTemp=GetUserDefinedError
end if
end if
set errErrors = nothing
GetFullError=sTemp
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' returns a string of all the errors found in HTML format.
PUBLIC FUNCTION GetAllFullErrors
DIM tot, x, sTemp
Tot=TotalErrors
sTemp=""
if tot>0 then
for x = 0 to Tot-1
sTemp=sTemp & GetFullError(x)
next
end if
GetAllFullErrors=sTemp
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' if use "RAISERROR ("some text",16,1) in an SQL Stored Proc
then this will return just the
' "Some Text" part of the error to a string.
PUBLIC FUNCTION GetUserDefinedError
DIM tot, x, sTemp
Tot=TotalErrors
sTemp=""
if Tot>0 then
for x = 0 to Tot-1
if
moConnection.Errors.Item(x).NativeError >=50000 then
sTemp=sTemp &
"<BR><B>[NativeError: </B>" & moConnection.Errors.Item(x).NativeError
&"<B>]</B>"
sTemp=sTemp &"<B>[ERROR:
</B>"& moConnection.Errors.Item(x).Description&"<B>] </B>"
'sTemp=sTemp &"<B>[ERROR:
</B>"& mid(moConnection.Errors.Item(x).Description,
InstrRev(moConnection.Errors.Item(x).Description,"[SQL
Server]")+12)&"<B>] </B>"
end if
next
end if
GetUserDefinedError=sTemp
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' A Quick way to set the ExtraInfo & InFunction parameters.
PUBLIC SUB SetInfo (ByVal sWhatFunction, ByVal sWhatInfo)
InFunction = sWhatFunction
ExtraInfo =sWhatInfo
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' This resets the ExtraInfo & InFunction strings to the
default values.
' Best place to run this is at the end of a function/sub
PUBLIC SUB ResetInfo
ExtraInfo =""
InFunction = ""
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| ***P R I V A T E*** F U N C T I O N S /
S U B S
|
'|______________________________________________________________________________|
' If connection is closed then see if there is an application
connection string
' if so open a connection automatically
PRIVATE FUNCTION IsConnectionOpen
if not mbIsConnectionOpen then
if not IsEmpty(msConnString) then
OpenDBConnection msConnString
else
ReportConnectionClosed
end if
end if
IsConnectionOpen = mbIsConnectionOpen
END FUNCTION
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
' If connection is closed then report error.
PRIVATE SUB ReportConnectionClosed()
DIM sTemp
sTemp= "<P STYLE=""text-align:left""><SPAN
STYLE=""color:#990000""><B>DB ERROR:</B></SPAN> <B>[File:
</B>"&Request.ServerVariables ("SCRIPT_NAME")&"<B>]</B> "
sTemp=sTemp & "<BR><B>[Func:
</B>"&msInFunction&"</B>]</> <B>[xInfo: </B>"&msExtraInfo&"<B>]</B>"
sTemp=sTemp & "<BR><B>[Desc: </B>THE DB CONNECTION HAS
NOT BEEN OPENED!!!!<B>]</B>"
sTemp=sTemp & "<P>You need the following 2 lines when
accessing the DB:"
sTemp=sTemp & "<BR>set g_clsDBCheck = new
clsDBErrorChecker"
sTemp=sTemp & "<BR>Application(""sDBConnection"")=
""Your Connection string here"" "
sTemp=sTemp & "<BR><BR>Eg ""Provider=SQLOLEDB; Data
Source=ServerIP; Initial Catalog=DBname; User ID=Username;
Password=password; Persist Security Info=True"""
Response.Write sTemp
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
PRIVATE SUB UpdateConnectionString()
msConnString=Application("sDBConnection")
msConnString = replace (msConnString, "[***USER***]",
maConnectAsArray(miConnectAs,0))
msConnString = replace (msConnString, "[***PASS***]",
maConnectAsArray(miConnectAs,1))
END SUB
'|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|
'| E N D O F T H E C L A
S S
|
'|______________________________________________________________________________|
END CLASS
%> Tag: Rename scheduled task name Tag: 141690
Changing components,,,
Hi All,
I am doing an asp page.
What I want is to use the same page I use to enter data to display data in
labels. This means that when the user wants to insert a record input boxes
must be displayed, but when the user wants to delete a record then only
labels must be displayed to confirm the deletion.
Thanks in advance
Roberto Tag: Rename scheduled task name Tag: 141684
snmp wmi scripting
Using VBScript, or natively, is it possible to utilise
WMI which includes an SNMP provider to manage a
datacomms device such as a network switch which has an
SNMP agent? Or, does the managed device need to have WMI
capability built in which of course datacomms devices do
not normally have? Tag: Rename scheduled task name Tag: 141674
when to write <%@ Language="VBScript" %>?
Since ASP server scripts use VBScript by default, does it mean it is
redundant to put the following in ASP page? Then when do we need to use
this? In client-side VBScript?
<%@ Language="VBScript" %>
Thanks!
John Tag: Rename scheduled task name Tag: 141662
Time
Hi all
<script language=vbscript>
document.write (Time()-1)
document.write ("<BR>")
document.write (Time())
document.write ("<BR>")
document.write DateDiff ("h",Date,23)
</script>
I want to display The Current time and also Current time -1 hr ( I mean
theTime should be Less then 1 hr from Current time.)
????????????????
Thanks
Naveen Tag: Rename scheduled task name Tag: 141654
Instr function
Based on the code below, why does the variable pos keep
coming up to 1 (indicating a match) when there is no
obvious match between the contents of variable 'transit'
and second element contained in myarray?
Function CompareOSDTransitsToOriginator()
dim myArray
OSDTransits = "44444,33333,55555,22222"
transit = "00968"
myArray = Split (OSDTransits,",")
msgbox myArray(1) ' which is "33333"
pos = instr(1, myArray(1), transit, 1)
if pos > "0" then
msgbox("Match found...")
else
msgbox("NO Match...")
end if
msgbox pos
End Function Tag: Rename scheduled task name Tag: 141651
Executing vbscript function from anchor tag
I am trying the execute a VBscript function from an anchor
tag, but seem to be unable to get the syntax correct.
Following is a simple web page that diplays a msgbox.
It works from the button, but not from the Anchor.
Can you you help me?
<HTML>
<INPUT id="cmdWrite" onclick="vbscript:WriteFile('Hello')"
type="button" value="Write File"><BR><BR>
<A HREF="vbscript:WriteFile('Hello')">Say Hello</A>
<SCRIPT LANGUAGE=VBSCRIPT>
Sub WriteFile(Value)
Msgbox "Value=" & Value
End Sub
</SCRIPT>
</HTML> Tag: Rename scheduled task name Tag: 141650
Share Permissions
Hi,
I am working on a script, which will list all shares on a
given computer and the permissions for each share. I
would then remove the Everyone permissions if there is
one and replace it with something else. My problem is I
cannot figure out how to list the permissions. I can
enumerate computers and list shares, but how to you list
the permissions for each share?
Thanks,
Scott Tag: Rename scheduled task name Tag: 141649
NTFS File Ownership lost, how to reset ?
I writed a vbscript to set ntfs permission recursively.
It use AdsSecurity.dll.
But when a file have lost owner information, script close with no error.
With WMI, I can detect the problem :
Function GetOwner(fileinput)
Set Obj = GetObject("Winmgmts://.")
On Error Resume Next
For each SID in Obj.ExecQuery("ASSOCIATORS OF
{Win32_LogicalFileSecuritySetting='" & fileinput & "'} WHERE
AssocClass=Win32_LogicalFileOwner ResultRole=Owner")
GetOwner = SID.AccountName
Next
If VarType(GetOwner)=0 Then
GetOwner = "error"
End If
End Function
Function return error and I can avoid to make a "GetSecurityDescriptor".
Then, how can I take ownership of the file (local or remote) without use
"GetSecurityDescriptor" using WMI or AdsSecurity ? Tag: Rename scheduled task name Tag: 141647
VBS modeless status/progress/log dialog
I had a little fun building a simple ActiveX EXE based dialog. Very
light weight and simple. Available here; with source and sample
test.vbs:
http://www.geocities.com/jaffadogmon/ Tag: Rename scheduled task name Tag: 141640
CDONTS.NewMail Object help
Hi All,
I'm new to this newsgroup, so please forgive my ignorance,
but I have an issue with the NewMail object that I can't
seem to resolve. The issue is this: I have the following
snippet of code to send out an HTML based e-mail:
Dim oEmail
Set oEmail = Server.CreateObject("CDONTS.NewMail")
oEmail.From = sFromemail
oEmail.To = sRecipemail
oEmail.Subject = sSubject
oEmail.Body = sBody
oEmail.BodyFormat = 0
oEmail.MailFormat = 0
oEmail.Send
Set oEmail = Nothing
However, it seems that by including the MailFormat = 0 bit
the sender is removing some of the periods out of my links
and image references, always at the very end
(www.blah.com/blah.htm becomes www.blah.com/blahhtm and
www.blah.com/blah.gif becomes www.blah.com/blahgif). It
also seems that even with both the BodyFormat and
MailFormat lines removed the object still removes periods
from some of my links. I've checked over my HTML several
times, but it's completely fine, and is shown properly on
a test page I've built.
I'm really having trouble figuring this out, so I would
really appreciate the help.
Thanks,
Jon Scolamiero. Tag: Rename scheduled task name Tag: 141639
Hi,
How can I rename the description and comments of a scheduled task in
Windows 2003 using VBscript?
Lars