VBScript that read from one file to write in another

Hello,

Here I leave you a VBScript I did to modify a TXT file with the information of other file.

We read the file “C:\myfolder\information.txt” and fil the variables.
We read and write the file “C:\myfolder\final.txt” with the values we did
read before in the case is needed.

‘***************************************************************************
***********
Const ForReading=1
Const ForWriting=2
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
folder = “C:\myfolder\”
filePath = folder & “final.txt”
filePathinf = folder & “information.txt”
Set myFile = objFSO.OpenTextFile(filePath, ForReading, True)
Set myFileinf = objFSO.OpenTextFile(filePathinf, ForReading, True)
Set myTemp= objFSO.OpenTextFile(filePath & “.tmp”, ForWriting, True)

mypo = “12345678”
mypocheck = false

commonname = “name”
sname = “sname”
myplu = “123”

dim mygs1_128(400)
dim mypeso(400)
index = 1

Do While Not myFileinf.AtEndofStream
myLineinf = myFileinf.ReadLine

if InStr(myLineinf, mypo) then

mygs1_128(index) = mid(myLineinf,2,40)
mypeso(index) = mid(myLineinf,87,5)

index = index + 1

myitemcode = mid(myLineinf,60,5)
mygtin12 = mid(myLineinf,45,12)
sellbydate = mid(myLineinf,107,10)
packingdate = mid(myLineinf,94,10)

end if

Loop

index1 = 1
index = 1

Do While Not myFile.AtEndofStream
myLine = myFile.ReadLine

if InStr(myLine, “transaction_id='” & mypo & “‘>”) then
mypocheck = true

end if

if InStr(myLine, “itemcode”) then
myLine = ” ” & myitemcode &
“”

end if

if InStr(myLine, “plu_number”) then
myLine = ” ” & myplu &
“”

end if

if InStr(myLine, “commonname”) then
myLine = ” ” & commonname &
“”

end if

if InStr(myLine, “gtin_12″) then
myLine = ” ” & mygtin12 &
“”

end if

if InStr(myLine, “scientificname”) then
myLine = ” ” & sname &
“”

end if

if InStr(myLine, “sellbydate”) then
myLine = ” ” & sellbydate &
“”

end if

if InStr(myLine, “packagingdate”) then
myLine = ” ” & packingdate &
“”

end if

if InStr(myLine, “netweight”) and Instr(myLine,”averagenetweight”) = false
then
myLine = ” ” & mypeso(index) &
“”
index = index + 1
end if

if InStr(myLine, “gs1_128barcode”) then

myLine = ” ” &
mygs1_128(index1) & “”
index1 = index1 + 1
end if

myTemp.WriteLine myLine
Loop

myFile.Close
myTemp.Close
objFSO.DeleteFile(filePath)
objFSO.MoveFile filePath&”.tmp”, filePath

Wscript.Echo “TXT Ready”
‘***************************************************************************
******************************

Enjoy.

System File Checker for Windows

Hello

Some time we have problems with a windows installation. In those moments it is important some tools for this matters, the scandisk utility, fragmentation, antivirus, etc…
But one option very important must be the System File Checker, a tool for check and recover the system’s files.

Run.. -> cmd (run as administrator)

sfc /scannow #Scan right now

sfc /scanboot #Scan at boot

sfc /revert #Return to default operations

sfc /? #More information

I hope this will be use-full for someone as for me.

Problems removing a printer from Windows 7

Hello every one.

Administrative Tools

Print Management

All Drivers -> deploy the option

Select the driver with right click and select: Remove Printer Package.

Make yourself sure the queue is empty, because that could give you problems for removing a printer or damage drivers. If you have problems cleaning the queue try this option in the command line:

net stop spooler

del %systemroot%\system32\spool\printers* /q

net start spooler


Performance Monitor: How to resolve the task is disabled error when starting a data collector

Very helpful for me.
Problem
You are attempting to configure Windows Server 2012 Performance Monitor to collect data in order to analyze CPU and memory load performance of a SharePoint 2013 web front end.  In Performance Monitor, you select the default Server Manager Performance data collector set, and then click the Start button.  You then experience the error message:
Solution
1.             Launch Task Scheduler using an account having local Administrator permissions.
2.             In the left task pane, expand the tree like so: Task Scheduler Library > Microsoft > Windows > PLA.
3.             Select the PLA group.  Note that the status of the Server Manager Performance Monitor is Disabled.
4.             In the right Results pane, right-click Server Manager Performance Monitor.  A menu appears
5.             Click Enable.  Note that now the status of the Server Manager Performance Monitor item is Ready:
References
·                     Error enabling Data Collector Set on Windows 2012
Notes
·                     Thanks to Happy SysAdmin for first helping me understanding this issue.

Functions to work on the web with vbscript

I will be sharing a research of functions you could use in vbscript for online web
access.

‘LIBRARIES OF FUNCTIONS

Function Searchweb(url,mystring)
gsearch = url & “#q=” & mystring
Set IE = CreateObject(“InternetExplorer.Application”)
set WshShell = WScript.CreateObject(“WScript.Shell”)
IE.Navigate gsearch
IE.Visible = True
Wscript.Sleep 6000
‘IE.Document.All.Item(“lst-ib”).Value = mystring
‘IE.Document.All.Item(pass).Value = valuep
WshShell.AppActivate “IE”
‘IE.Document.getElementById(submit).Click
‘IE.Document.getElementById(submit).Click
‘WshShell.SendKeys “{ENTER}”
‘return gsearch
End Function

Function Loginweb(url,user,valueu,pass,valuep,submit)
Set IE = CreateObject(“InternetExplorer.Application”)
set WshShell = WScript.CreateObject(“WScript.Shell”)
IE.Navigate url
IE.Visible = True
Wscript.Sleep 6000
IE.Document.All.Item(user).Value = valueu
IE.Document.All.Item(pass).Value = valuep
WshShell.AppActivate “IE”
IE.Document.getElementById(submit).Click
‘WshShell.SendKeys “{ENTER}”
End Function

Function Searchlink(url,linktext)
On error resume next
Dim WshShell, objIE, ElementCol
Dim LinkHref

LinkHref = url
‘This is the web site that will give the Certificate Security
Warning

Set WshShell = WScript.CreateObject(“WScript.Shell”)
Set objIE = CreateObject(“InternetExplorer.Application”)
objIE.Visible = False
‘No need to display IE before the “final” page has loaded (user never sees
the Certificate Warning page)
objIE.Navigate LinkHref ‘load web page
wshShell.AppActivate objIE

Do While objIE.Busy
wscript.sleep 100
Loop

Set ElementCol = objIE.Document.getElementsByTagName(“a”)
‘Get all links on web page
‘Grap/click the link we are looking for…
For Each Link In ElementCol
If Link.innerHTML = linktext Then
Link.Click
Exit For
End If
Next
objIE.Visible = True
end function

Function clickon(url,eleid)
‘Dim URL
Dim IE
Set IE = CreateObject(“internetexplorer.application”)
URL = url
IE.Visible = True
IE.Navigate URL

Do While IE.Busy
WScript.Sleep 100
Loop

IE.Document.getElementById(eleid).Click
end function

Function Find(StrString,URL)
Titre = “Find a String in a webpage”
‘URL = “https://www.facebook.com
Set ie = CreateObject(“InternetExplorer.Application”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
ie.Navigate(URL)
‘ie.Visible = 1
ie.Visible = 0
DO WHILE ie.busy
wscript.sleep 100
LOOP
Data = ie.document.documentElement.innertext
Set ie = Nothing
Set objRegex = new RegExp
objRegex.Pattern = StrString
objRegex.Global = False
objRegex.IgnoreCase = True
Set Matches = objRegex.Execute(Data)
For Each Match in Matches
MsgBox “We found this word : ” &vbCr& qq(Match.Value) & “in ” &
URL,64,Titre
Next
End Function

Function qq(strIn)
qq = Chr(34) & strIn & Chr(34)
End Function

Function Pause(NbMin)
wscript.sleep NbMin*1000*60
End Function

How to initialize a DELL Power Connect 3348 Switch

Hello;

This is an old post I want to re-post on this new blog!

Here I want to share some research I did about starting a DELL Power Connect
3348 Switch.
Connect the switch trough DB9 port to the computer; you can use
HyperTerminal or Putty application to connect by Serial, the default
configuration was fine for me, but in case of trouble you can check other
speed.

Once you are connected try:

Checking the network interface
>Show ip interface

Setting ip address for vlan or port
>enable
>configure
>interface vlan 1 “or” interface ethernet 1/e1
>ip address 192.168.1.2 /24
>exit
>exit

Setting gateway
>enable
>configure
>ip default-gateway 192.168.1.1
>exit

Setting a http user for the switch
>enable
>configure
>ip http authentication local
>username myuser mypassword admin level 15
>exit

Saving the new configuration
>enable
>copy running-config startup-config
YES

Restarting
>reload
YES

Resetting
>enable
>delete startup-config
>reload
YES

Enjoy.

The Technology Journey Begins

Thanks for joining me!

Good company in a journey makes the way seem shorter. — Izaak Walton

This Blog it is to share my passion for the Technology, if you are a technology person lets share some content and information for the mutual grow.

Ronald Blanco

 

Design a site like this with WordPress.com
Get started