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.
Design a site like this with WordPress.com
Get started