renames file on a folder based on webpage - batch-file

I dont know whether this is proper question or not but I am learning. I have a webpage which has some buttons on it
like japan,tokyo,india,UK, USA
and a folder which has images on it
YK08HJX_SYPTE_20140403170541594.jpg
YK08HJX_SYPTE_20140403170542194.jpg
1YK0BHJX_SYPTE1-PC_20140403170000670.jpg
. when user click s on any button on webpage it should change the sypte1-PC or SYPTE to that button text.
YK08HJX_japan_20140403170541594.jpg
YK08HJX_INDIA_20140403170542194.jpg
1YK0BHJX_UK_20140403170000670.jpg.
any help would be appreciated.
this was my code: but dont how to interact directly with webpage on button click or href. text.
Listing A: RenameFiles.vbs
Dim WshShell, FileManagement, BrowseDialogBox, SelectedFolder, OldString, NewString, FullPath, TheFolder, FileList
Dim File, ThisFile, TheString, AlreadyRenamed, TempName, FlagName, Success, FindFlag, NewName, Dummy
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FileManagement = WScript.CreateObject ("Scripting.FileSystemObject")
Set BrowseDialogBox = WScript.CreateObject("Shell.Application")
Set SelectedFolder = BrowseDialogBox.BrowseForFolder(0, "Select the folder containing the files you want to rename.", &H0001)
If InStr(1, TypeName(SelectedFolder), "Folder") = 0 Then
WScript.Quit
Else
OldString = InputBox("Enter the characters in the filename that you want to replace","Rename Files")
If OldString = "" Then WScript.Quit
NewString = InputBox("Enter the characters that you want to replace them with","Rename Files")
‘If NewString = "" Then WScript.Quit
End If
FullPath = SelectedFolder.ParentFolder.ParseName(SelectedFolder.Title).Path
Set TheFolder = FileManagement.GetFolder(FullPath)
Set FileList = TheFolder.Files
Success = 0
For Each File In FileList
ThisFile = File.Name
TheString = InStr(ThisFile, OldString)
AlreadyRenamed = InStr(ThisFile, "%")
If (TheString <> 0) And (AlreadyRenamed = 0) Then
Success = 1
TempName = Replace(ThisFile, OldString, NewString)
FlagName = "%" + TempName
File.Name = FlagName
End If
Next
For Each File In FileList
ThisFile = File.Name
FindFlag = InStr(ThisFile, "%")
If FindFlag <> 0 Then
NewName = Replace(ThisFile, "%", "")
File.Name = NewName
End If
Next
If Success = 1 Then
Dummy = WshShell.Popup ("Rename Files operation complete!",5,"Rename Files",64)
Else
Dummy = WshShell.Popup ("Rename Files operation failed! Please repeat the operation.",0,"Rename Files",16)
End If
WScript.Quit

You mentioned you were having trouble interacting with the webpage or button click. So I'll help you with that portion. You can create a single button-click event that is fired whenever any of your buttons are clicked. That way you can keep your code in a single sub. Here's an example:
<html>
<body>
<script language="vbscript">
Sub DoClick(strText)
' strText will hold the name of the button that was clicked.
' Use it to rename your files.
End Sub
</script>
<input type="button" onclick="DoClick('Japan')" value="Japan" />
<input type="button" onclick="DoClick('USA')" value="USA" />
</body>
</html>

Related

Microsoft VBScript runtime error '800a01a8'

I have website which is working on my one server now I have migrated to another server changed the connection string. But one weird thing is some pages working fine but some page show me " page can not be displayed error message. I am new in VBscript Can anyone help me what am missing"
Below is the code of page which is not working on new server but working on old server
Microsoft VBScript runtime error '800a01a8' : object required
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% if session("MM_Username") = "" or isnull(session("MM_Username")) then
response.redirect("/login.asp")
end if
%>
<%
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then
MM_editConnection = MM_v3_STRING
MM_editTable = "dbo.custMessage"
MM_editColumn = "id"
MM_recordId = "" + Request.Form("MM_recordId") + ""
MM_editRedirectUrl = "Change.asp"
MM_fieldsStr = "textarea|value"
MM_columnsStr = "message|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<%
Dim change__MMColParam
change__MMColParam = "1"
If (Request("MM_EmptyValue") <> "") Then
change__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim change
Dim change_numRows
Set change = Server.CreateObject("ADODB.Recordset")
change.ActiveConnection = MM_v3_STRING
change.Source = "SELECT * FROM dbo.custMessage WHERE id = " + Replace(change__MMColParam, "'", "''") + ""
change.CursorType = 0
change.CursorLocation = 2
change.LockType = 1
change.Open()
change_numRows = 0
%>
<%
'setup database connection
dim conn
set conn = server.CreateObject ("ADODB.Connection")
conn.ConnectionString = "Provider=SQLOLEDB;User ID=***;Password=***;Initial Catalog=heart_Test;Data Source=****;"
conn.Open
%>
So here is the answer.
Start Internet Services Manager.
Click Default Web Site, and then click Properties.
Double-click ASP in the Features pane.
Expand Behavior.
Click Enable Parent Paths.
Click True for Enable Parent Paths.
Click Apply.

In Visual Studio 2013 I simply want to pass data to a sql table using VB?

I am designing an application which is my forte but now have to code the back end. I am using Visual Studio 2013 with DevExpress and SQL Server 2014. It may be a simple question but I have struggled to find a straight answer anywhere. I have an asp.net book but I still cant find an answer. I think I have connected my whole solution with a connection string in that I can populate the tables and stored procedures into my dataclass. I simply want to add any user input into a table on SQL Server using a button with an onclick event. Surely it cant be that difficult but remember I am a bit of newbie so any help would be greatly appreciated. If there is any questions you need answered to assist then let me know. I am writing in VB script but am struggling to get it to work. Any advice would be appreciated. Thanks in advance!
Protected Sub btnAddNewSource_Click(sender As System.Object, e As EventArgs) Handles btnAddNewSource.Click
'ErrDetails.Text = ""
'ErrDetails.Visible = False
'FocusSet = False
'errCount = 0
'ErrDetails.Text = ""
'If txtSourceFunding.Text = "" Then
' ErrDetails.Text = ErrDetails.Text + "Did you enter the funding source?" + vbNewLine
' ErrDetails.Visible = True
' txtSourceFunding.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If txtContributionFunding.Text = "" Then
' ErrDetails.Text = ErrDetails.Text + "Did you enter the contribution?" + vbNewLine
' ErrDetails.Visible = True
' txtContributionFunding.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If cmbStatus.Value = -1 Then
' ErrDetails.Text = ErrDetails.Text + "Did you inform us of the status?" + vbNewLine
' ErrDetails.Visible = True
' cmbStatus.Focus()
' FocusSet = True
' errCount = errCount + 1
'End If
'If FocusSet = True Then
' ErrDetails.ForeColor = Drawing.Color.Red
' ErrDetails.Height = 20 * errCount
' ErrDetails.Visible = True
' Return
'End If
'Dim btnSource = (From o In dc1.Update_GrantApplicationCycleFunding Where o.GrantApplicationID = Session("CurrentProjectID").ToString).FirstOrDefault
'If Not IsNothing(btnSource) Then
' btnSource.GrantApplicationID = Session("CurrentProjectID")
' btnSource.GrantApplicationCycleFundingSource = txtSourceFunding.ToString
' btnSource.GrantApplicationCycleFundingContribution = txtContributionFunding.ToString
' btnSource.GrantApplicationCycleFundingStatusID = cmbStatus.ToString
' btnSource.GrantApplicationCycleFundingNotes = memFundingNotes.ToString
'Else
' Dim NewGrantApplicationCycleFundings As New GrantApplicationCycleFunding
' With NewGrantApplicationCycleFundings
' .GrantApplicationID = Session("CurrentProjectID")
' .GrantApplicationCycleFundingSource = txtSourceFunding.ToString
' .GrantApplicationCycleFundingContribution = txtContributionFunding.ToString
' .GrantApplicationCycleFundingStatusID = cmbStatus.ToString
' .GrantApplicationCycleFundingNotes = memFundingNotes.Text
' End With
' dc1.GrantApplicationCycleFundings.InsertOnSubmit(NewGrantApplicationCycleFundings)
' dc1.SubmitChanges()
' End If
'dc1.SubmitChanges()
Hey I have now managed to make the button add data to the datagrid. The big thing I missed was the declarations of the fields values at the bottom of the code and of course the databind! Never forget the correct DATABIND. You can adapt and use this in your own code if you are having similar problems! If you need help or explanation and I can help you then I will. Just add comment. Thanks
** ErrDetails.Text = ""
ErrDetails.Visible = False
FocusSet = False
errCount = 0
ErrDetails.Text = ""
If spnTotalEstimatedCost.Value <= 0 Then
ErrDetails.Text = ErrDetails.Text + "Please enter the cost." + vbNewLine
ErrDetails.Visible = True
If FocusSet = False Then
spnTotalEstimatedCost.Focus()
FocusSet = True
End If
errCount = errCount + 1
End If
If txtSourceFunding.Text = "" Then
ErrDetails.Text = ErrDetails.Text + "Please........?" + vbNewLine
ErrDetails.Visible = True
txtSourceFunding.Focus()
FocusSet = True
errCount = errCount + 1
End If
If spnContributionFunding.Value = 0 Then
ErrDetails.Text = ErrDetails.Text + "Please......" + vbNewLine
ErrDetails.Visible = True
spnContributionFunding.Focus()
FocusSet = True
errCount = errCount + 1
End If
If FocusSet = True Then
ErrDetails.ForeColor = Drawing.Color.Red
ErrDetails.Height = 20 * errCount
ErrDetails.Visible = True
Return
End If
Dim NewGrantApplicationMatchFundings As New GrantApplicationMatchFunding
With NewGrantApplicationMatchFundings
.GrantApplicationID = Session("CurrentProjectID")
.GrantApplicationMatchFundingName = txtSourceFunding.Text
.GrantApplicationMatchFundingContribution = spnContributionFunding.Value
.GrantApplicationMatchFundingStatus = cmbStatus.SelectedItem.Value
.GrantApplicationMatchFundingNotes = memFundingNotes.Text
End With
dc1.GrantApplicationMatchFundings.InsertOnSubmit(NewGrantApplicationMatchFundings)
dc1.SubmitChanges()
'End If
'dc1.SubmitChanges()
txtSourceFunding.Text = ""
spnContributionFunding.Value = ""
cmbStatus.Value = ""
memFundingNotes.Text = ""
grdFunding.DataBind()
Dim btnTotal = (From o In dc1.Select_GrantApplicationMatchFundingTotal(Session("CurrentProjectID").ToString)).FirstOrDefault
If Not IsNothing(btnTotal) Then
spnTotalMatchFunding.Text = btnTotal.TotalFunding
txtGrantFunding.Text = (spnTotalMatchFunding.Value / spnTotalEstimatedCost.Value) * 100
Else
spnTotalMatchFunding.Text = 0
txtGrantFunding.Text = 0
End If
Dim cafChange = (From o In dc1.GrantApplicationCostsAndFundings Where o.GrantApplicationID.ToString = Session("CurrentProjectID").ToString).FirstOrDefault
If Not IsNothing(cafChange) Then
cafChange.GrantApplicationID = Session("CurrentProjectID")
cafChange.GrantApplicationProjectCostsYear1 = spnTotalEstimatedCost.Value
cafChange.GrantApplicationMatchedFundingNotesYear1 = memNotesMatchFunding.Text
cafChange.GrantApplicationProjectRequestedYear1 = txtGrantFunding.Value
dc1.SubmitChanges()
Else
Dim NewGrantApplicationCostsAndFundings As New GrantApplicationCostsAndFunding
With NewGrantApplicationCostsAndFundings
.GrantApplicationID = Session("CurrentProjectID")
.GrantApplicationProjectCostsYear1 = spnTotalEstimatedCost.Value
.GrantApplicationMatchedFundingNotesYear1 = memNotesMatchFunding.Text
.GrantApplicationProjectRequestedYear1 = txtGrantFunding.Value
End With
dc1.GrantApplicationCostsAndFundings.InsertOnSubmit(NewGrantApplicationCostsAndFundings)
dc1.SubmitChanges()
End If
End Sub

Replace the sequence of the same item

I'm making a script where the User makes a list and the same is sought in some text files and returns the results in a .txt only encounter the following problems:
The list is organized as follows on the interface:
Item1
item2
Item3
and is output as follows in the text file:
item1|item2|item3
First problem:
If the file from the beginning have a blank line:
item1
item2
item3
the output is with a "|" more and because the research problem:
item1||item2||item3
Second problem:
If the start/end have a blank line:
 
item1
item2
item3
 
the output is also in trouble at the time of search:
|item1|item2|item3|
Note: There may be several blank lines between the beginning, middle and end.
Note 2: The script goes inside a .hta, if necessary the code .hta will be at the end of post.
Note 3: The solution may be either batch, an external program or even vbs.
Option Explicit
Window.resizeTo 373,610
Const csFSpec = "List.ini"
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
Sub Window_OnLoad()
If goFS.FileExists(csFSpec) Then
document.all.DataArea.value = goFS.OpenTextFile(csFSpec).ReadAll()
document.all.DataArea.value = Replace(document.all.DataArea.value,"|", vbcrlf)
Else
self.close
End If
If document.all.DataArea.value =vbcrlf Then
document.all.DataArea.value =""
Else
End If
End Sub
Sub SaveFile()
If document.all.DataArea.value = "" Then
document.all.DataArea.value =vbcrlf
goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value
self.close
Else
document.all.DataArea.value = Replace(document.all.DataArea.value, "\", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "/", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ":", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "*", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "?", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, """", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "<", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ">", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "|", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "&", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "!", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value,vbcrlf,"|")
goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value
self.close
End if
End Sub
Sub QuitEdit()
self.close
End Sub
Sub Redefine()
document.all.DataArea.value ="Item1" & vbcrlf & "Item2" & vbcrlf & "Item3"
End Sub
Sub Clean()
document.all.DataArea.value = ""
End Sub
Full Code:
<html>
<head>
<title>List</title>
<HTA:Application
Border= "thin"
Application="/md/input"
Scoll="NO"
Singleinstance="Yes"
SysMenu=NO
Icon="%Windir%\System32\wscript.exe">
ShowInTaskbar="Yes"
Caption="Yes">
<script type="text/vbscript">
Option Explicit
Window.resizeTo 373,610
Const csFSpec = "List.ini"
Dim goFS : Set goFS = CreateObject("Scripting.FileSystemObject")
Sub Window_OnLoad()
If goFS.FileExists(csFSpec) Then
document.all.DataArea.value = goFS.OpenTextFile(csFSpec).ReadAll()
document.all.DataArea.value = Replace(document.all.DataArea.value,"|", vbcrlf)
Else
self.close
End If
If document.all.DataArea.value =vbcrlf Then
document.all.DataArea.value =""
Else
End If
End Sub
Sub SaveFile()
If document.all.DataArea.value = "" Then
document.all.DataArea.value =vbcrlf
goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value
self.close
Else
document.all.DataArea.value = Replace(document.all.DataArea.value, "\", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "/", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ":", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "*", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "?", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, """", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "<", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, ">", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "|", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "&", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value, "!", "_")
document.all.DataArea.value = Replace(document.all.DataArea.value,vbcrlf,"|")
goFS.CreateTextFile(csFSpec).Write document.all.DataArea.value
self.close
End if
End Sub
Sub QuitEdit()
self.close
End Sub
Sub Redefine()
document.all.DataArea.value ="Item1" & vbcrlf & "Item2" & vbcrlf & "Item3"
End Sub
Sub Clean()
document.all.DataArea.value = ""
End Sub
</script>
</head>
<body style="overflow:hidden" bgColor="#000080"></body>
<caption></caption><hr></hr>
<font color="#FFFFFF" Times New Roman" size="13"><center><B>List</b></center></font>
<caption></caption><hr></hr>
<TR><td>
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent; float: left;" type="BUTTON" value="Clean" class="btn" id="btna" onclick="Clean" onmouseover="btna.style.background = '#808080'" onmouseout="btna.style.background = '#F0F0F0'">
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent; float: right;" type="BUTTON" value="Redefine" class="btn" id="btnb" onclick="Redefine" onmouseover="btnb.style.background = '#808080'" onmouseout="btnb.style.background = '#F0F0F0'">
</TR></td>
<Table border="3" style="width:100%; text-align: center" BORDERCOLOR=#F0F0F0>
<TR><td>
<form>
<textarea name="DataArea" rows="23" cols=37></textarea> </Table>
<TR><td>
<p>
<div align="right"><input style="background-color:#F0F0F0; color: #000000; border: 2px transparent" type="BUTTON" value=" OK " class="btn" id="btnc" onclick="SaveFile" onmouseover="btnc.style.background = '#808080'" onmouseout="btnc.style.background = '#F0F0F0'">
<input style="background-color:#F0F0F0; color: #000000; border: 2px transparent" type="BUTTON" value="Cancel" class="btn" id="btnd" onclick="QuitEdit" onmouseover="btnd.style.background = '#808080'" onmouseout="btnd.style.background = '#F0F0F0'">
</div>
</td></TR>
</form>
</body>
</html>
From Filter at https://skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 a set of 19 sample programs in one file for working with files. It has two sample programs, 1 for lopping off blank lines top and bottom, and another one for all blank lines. Filter has a batch file that makes calling vbs scripts easy.
TrimLine
filter trimline {top|end|both}
filter tl {t|e|b}
Trims blank lines from top and bottom of files.
top - removes blank lines from top of file.
end - removes blank lines from end of file.
both - removes blank lines from top and end of file.
Example
Fixes win.ini, not that it needs fixing, and sends it to the screen
filter trimline both < "%systemroot%\win.ini"
Script
Sub TrimLines
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
If LCase(Arg(1)) = "top" or LCase(Arg(1)) = "t" then
Flags = 0
Do Until Inp.AtEndOfStream
Line=Inp.readline
If Line <> "" then Flags = 1
If Flags = 1 then outp.writeline Line
Loop
ElseIf LCase(Arg(1)) = "e" or LCase(Arg(1)) = "end" then
PendingLines = ""
Do Until Inp.AtEndOfStream
Line=Inp.readline
If Line <> "" then
outp.writeline PendingLines & Line
PendingLines = ""
Else
PendingLines=PendingLines & vbcrlf
End If
Loop
ElseIf LCase(Arg(1)) = "b" or LCase(Arg(1)) = "both" then
Flags = 0
Do Until Inp.AtEndOfStream
Line=Inp.readline
If Line <> "" then Flags = 1
If Flags = 1 then
If Line <> "" then
outp.writeline PendingLines & Line
PendingLines = ""
Else
PendingLines=PendingLines & vbcrlf
End If
End If
Loop
End If
End Sub
BlankLine
filter blankline {e|a}
Trims all empty and/or blank lines from a file.
e - removes blank lines from a file.
a - removes blank lines and lines only composed of space or tab from a file.
Example
Fixes win.ini, not that it needs fixing, and sends it to the screen
filter blankline a < "%systemroot%\win.ini"
Script
Sub BlankLine
Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Inp = WScript.Stdin
Set Outp = Wscript.Stdout
Set RegEx = New RegExp
RegEx.Pattern = "^\s+$"
If LCase(Arg(1)) = "e" then
Do Until Inp.AtEndOfStream
Line=Inp.ReadLine
If Len(Line) <> 0 Then
OutP.WriteLine Line
End If
Loop
ElseIf Lcase(Arg(1)) = "a" then
Do Until Inp.AtEndOfStream
Line=Inp.ReadLine
If Len(Line) <> 0 Then
If RegEx.Test(Line) = False then
OutP.WriteLine Line
End If
End If
Loop
End If
End Sub
Also you could use VBS replace command.
A = Replace("blah||blah", "||", "|")

Reading calendar folder in a date range using JACOB

hi guys is it possible on JACOB on reading only CALENDAR folder with a date range and let me get the subject. If yes please give a sample code for reference. Thanks a lot
This code has two filters
1) first only by date range - start and end date
2) filter by subject = "test"
If you need only date, you can omit second filter.
How to: Filter Recurring Appointments and Search for a String in the Subject
Dispatch namespace = outlokAx.getProperty("Session").toDispatch();
Dispatch calendarFolder = Dispatch.call(namespace, "GetDefaultFolder", new Integer(9)).toDispatch();
Dispatch calItems = Dispatch.get(calendarFolder, "items").toDispatch();
String customFilter = "#SQL=\"urn:schemas:calendar:dtstart\" > '" + DateUtility.dateToUtcString(startDate) + "' and \"urn:schemas:calendar:dtend\" = '" + DateUtility.dateToUtcString(endDate) + "'" ;
String customFindFilter = "#SQL=\"urn:schemas:httpmail:subject\" like '" + "test" + "'" ;
Dispatch restrictedItems = Dispatch.call(calItems, "Restrict", new Variant(customFilter)).toDispatch(); //Works only with dates
Dispatch.call(calItems, "Sort", "[Start]");
Dispatch.put(restrictedItems, "IncludeRecurrences", "False");
int numberOfMatchingItems = 0;
Dispatch lastitemFound = null;
if (restrictedItems != null && restrictedItems.m_pDispatch > 0) {
Dispatch findItem = Dispatch.call(restrictedItems, "Find", customFindFilter).toDispatch(); // Find Works with other attributes
while (findItem != null && findItem.m_pDispatch > 0) {
numberOfMatchingItems++;
lastitemFound = findItem;
findItem = Dispatch.call(restrictedItems, "FindNext").toDispatch();
Variant start = Dispatch.get(findItem, "Start");
Variant end = Dispatch.get(findItem, "End");
Variant subject = Dispatch.get(findItem, "Subject");
System.out.println("# Outlook event fetched: " + subject + " start: '" + start + "' end '" + end + "'");
}
}

ASP VBSCRIPT MS SQL SERVER connection

How to fix database connection? I'm moving website from one server to another.
This is what I've got in Connections file:
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="true"
' Catalog=""
' Schema=""
Dim MM_**_STRING
MM_**_STRING = "Driver={SQL Server};Server=localhost;Database=mssql0_***_1;Uid=mssql0_***_1;Pwd=********;"
%>
And this is asp file:
<%#LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/**.asp" -->
<%
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
MM_valUsername = CStr(Request.Form("userName"))
If MM_valUsername <> "" Then
Dim MM_fldUserAuthorization
Dim MM_redirectLoginSuccess
Dim MM_redirectLoginFailed
Dim MM_loginSQL
Dim MM_rsUser
Dim MM_rsUser_cmd
MM_fldUserAuthorization = "userAccess"
MM_redirectLoginSuccess = "/welcome.asp"
MM_redirectLoginFailed = "/index.asp?error=Incorrect+Login,+Please+try+again"
MM_loginSQL = "SELECT userName, userPassword, userFirstName"
If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
MM_loginSQL = MM_loginSQL & " FROM users WHERE userName = ? AND userPassword = ?"
Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
MM_rsUser_cmd.ActiveConnection = MM_**_STRING
MM_rsUser_cmd.CommandText = MM_loginSQL
I've got error '80004005' in line 24. What is wrong? Is it a problem with database connection?

Resources