Quantcast
Channel: VBForums - ASP, VB Script
Viewing all 663 articles
Browse latest View live

[RESOLVED] VBScript & Microsoft Forms 2.0 & Opus

$
0
0
Hi,

I'm currently working on a project to create a program that runs inside Opus (by Bruker).
Opus has a basic form designer (circa VB6 era by the look of it) with any code you write done in VB6:

Code:

dateExperimentStart = Now
 TimerRunScript.enabled = True
 Form.ShowControl("btnStopTempScript")
 Form.HideControl("listTemperatureScript")
 Form.HideControl("txtSelectedScan")
 Form.HideControl("txtSelectedTemperature")
 Form.HideControl("txtSelectedHoldTemperature")
 Form.HideControl("btnUpdateTemperatureScript")
 Form.ShowControl("listTemperatureScript")
 listTemperatureScript.Locked = True
 listTemperatureScript.MousePointer = 12

So you can use some properties that we all recognise like locked and mousepointer, but there are restrictions like not using the visible property and instead having to use HideControl and ShowControl.

There is some documentation, but I'm struggling what to Google for as I've never seen VBScript used with forms and there are rarely any posts relating to this. I try VB6 syntax and this sometimes works. The code editor is as functional as Notepad, so no Intellisense, debugger or anything really.

Has anyone come across another product that uses the combination of VBScript and MS Forms that has decent documentation?

Thanks

Kristian

VB File to change file files with extension .rmt and and donot strart with era*

$
0
0
Hello, I need help with writing a script to run in c:\Test folder to look for files with extension ".rmt". If the file name does not start with "era*" I want to rename the file so that it starts with "era" Plus original file name. If it is not possible to have the original file name then I want to have the name "era" followed by the sequential number 1, 2, 3 etc.
Can someone help me out?
Thanks in advance.

[RESOLVED] Permission Denied on new Object

$
0
0
Hello,

I have copied the sample of a Class from the VBScript language reference:

Code:

Class Customer
    Private m_CustomerName

    ' CustomerName property.
    Public Property Get CustomerName
        CustomerName = m_CustomerName
    End Property

    Public Property Let CustomerName(custname)
        m_CustomerName = custname
    End Property
End Class

and a function to create a new Instance of Customer:


Code:

        Public Function doit ()
                        On Error Resume Next
                        Dim a
                        Set a = New Customer
                        If err.number <> 0 Then
                                %>Err: <%= err.Description & " " & err.Number %><%
                        End If
                        Set doit = a
        End Function

When I call the function with

Code:

Dim x
Set x = doit()

I see an Error: 70, Permission Denied.

I do not have any clue, why I receive a filesystem error here on a simple New statement.
Do you have an idea?

Thank you
mmu1


The problem has been solved using Arrays instead of a List of Classes

Converting File

$
0
0
Hi Team,

Please anyone can help me with below issue ?

I was having .vb file script in the folder. I have copied .vb file on desktop and try to open . I had tried to open with Notepad so , all .vb file converted into Notepad file but extension remain the .vb file format.

Can anyone tell me how to change to original format :(

Passing an array from VBScript to COM enabled VB.NET Library...

$
0
0
Hi,

Getting this error below:

Error:0 'Invalid procedure call or argument: 'objFit.Simple''

VBScript Code:

Code:

dim objFit , alInputTemperatures
set objFit = CreateObject("VB_EPICS.CurveFunctions")
alInputTemperatures = Array(10,20,30,50)
msgbox(objFit.Simple(alInputTemperatures))


VB.NET Library Code:

Code:

Public Class CurveFunctions
    Public Function Simple(ByRef inp() As Single) As String
        Return "Hello There"
    End Function


I can call the function fine if I change its input parameter to say just a single and call it passing in just a single.

I've read that it could be that when VB Script is passing in the array, it is actually a variant and so doesn't match what the function is expecting, hence the error.

Here's a link to someone else who had the problem, but no solution:

http://www.visualbasicscript.com/m34060-print.aspx


All this is on Windows 7. VBScript is running via OPUS software made by Bruker. VB.NET library created in VS2010

Thanks

Resolving a argument when passing the string to another program?

$
0
0
Hi all,

I am executing a Python script via a VBscript and I wish to pass it the input & output file locations.

The script works when I have the input filename / path hardcoded, but the input file will be defined earlier on in the script.

Working code:

Code:

Set WSHShell = CreateObject("Wscript.Shell")
Return = WSHShell.Run("E:\Git\bin\bash.exe --login -i -c MORE /P "". F:/Users/py27/scripts/activate; tessewrapper -i F:/Input_File_Path/_File_Name.csv -o F:/Output_File_Path""" , 0, True)

I have: strPathAndFile = F:\Input_File_Path\_File_Name.csv (windows location)

So basically I need strPathAndFile in my code to replace the input file?

Can anyone help?

"checking a textbox is numerical before converting it" - How to do this succinctly?

$
0
0
Hi,

My Environment is Windows 7, 3rd party VBScript Engine and MS Forms.

I'm doing "isnumeric" checks on a load of values in textboxes and listviews before doing a "CInt" on each of them.

What's the most compact way of doing this.
I started off like this:

Code:

            if IsNumeric(txtPositionsTakenAtTemperature.Text) then
                singPositionsTakenAtTemperature = CSng(txtPositionsTakenAtTemperature.Text)
            else
                msgbox("'Sample Positions taken at' is blank or is not a number")
                exit sub
            end if


and moved onto this until I realised it would display an error, but then move on the next textbox:

Code:

subAddNumberToLV alCalibrationTemperatures, txtCalibrateTempStart
subAddNumberToLV alCalibrationX, txtCalibrateX
subAddNumberToLV alCalibrationY, txtCalibrateY

Code:

sub subAddNumberToLV( ByRef lvListView, ByRef strItem)

    if IsNumeric(strItem) then
        lvListView.Add(CSng(strItem))
    else
        msgbox(strItem & " is not a number")
        exit sub
    end if

End Sub

I could set an error flag in the sub and check it after every time I call subAddNumberToLV, but then it makes the code very bulky.
I don't have a controls container which I could loop through.
I did raise an error in the sub, but that stopped the code completely and closed the form which means the user would need to type everything in again.

Any thoughts?

Thanks

Kristian

VBS script to parse a directory of .csv files

$
0
0
I have many directories of weather data containing lots of .csv files (hundreds of thousands) I developed a script that went through and changed a character in each filename of a particular type so that I could isolate particular files easier. Now I need to look in those files and pull out ONE field of data, I am looking for either the highest or lowest temperature on a given date.
Typical data in the files looks like this

#2015-01-31 03:00:04#,19.49

I need to concentrate on the 19.49 field. Only 2 fields in these particular files.

Thanks to all

vb.net 2010 cant display asp page

$
0
0
I am a complete novice so please avoid jargon if you can. :) I want to understand how to create a aspx page called from a simple Html page

Using vb 2010 I created a web page with works locally and I can press buttons and up pops messages

Code:

Public Class Site
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MsgBox("Hi Kinga....this is Button1 one method (Routine)")
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MsgBox("Hi Kinga....this is Button2 one method (Routine)")
    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        MsgBox("Hi Kinga....this is Button3 one method (Routine)")
    End Sub
End Class

It works locally but when running in brower i get this


Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error:


An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.

Source File: \\web-123win\winpackage22\dokcon.com\www.dokcon.com\web\content\kingagirl\web.config Line: 18


Show Additional Configuration Errors:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280

Originally the error was something about custom error which I turned to OFF

web.config is as follows. The default of vb is to include a link to SQL which I do not want anyway


HTML Code:

<configuration>
  <connectionStrings>
    <add name="ApplicationServices"
        connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
        providerName="System.Data.SqlClient" />

  </connectionStrings>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>

   
        <customErrors mode="Off" defaultRedirect="kingaGirl.htm"/>
   
    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
            enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
            maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
            applicationName="/" />

      </providers>
    </membership>

    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
      </providers>
    </profile>

    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>

  </system.web>

I'd be very grateful if you can help

Richard

vbs - xls to csv

$
0
0
Hi, not sure if I'm in the right place here. I'm trying to take a directory of xls files and have them converted to csv into a different directory. I've got this, but I don't know how to change the saving directory.

WorkingDir = "C:\EXCEL\Test"
Extension = ".XLS"

Dim fso, myFolder, fileColl, aFile, FileName, SaveName
Dim objExcel,objWorkbook

Set fso = CreateObject("Scripting.FilesystemObject")
Set myFolder = fso.GetFolder(WorkingDir)
Set fileColl = myFolder.Files

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = False
objExcel.DisplayAlerts= False

For Each aFile In fileColl
ext = Right(aFile.Name,4)
If UCase(ext) = UCase(extension) Then
'open excel
FileName = Left(aFile,InStrRev(aFile,"."))
Set objWorkbook = objExcel.Workbooks.Open(aFile)
SaveName = FileName & "csv"
objWorkbook.SaveAs SaveName, 23
objWorkbook.Close
End If
Next

Set objWorkbook = Nothing
Set objExcel = Nothing
Set fso = Nothing
Set myFolder = Nothing
Set fileColl = Nothing

Thanks in advance.

Best Way to convert a column of strings into numbers

$
0
0
Hi!

I currently have a column with strings (names of animals) and I want to convert each animal name to a number (cow-> 1, zebra->3 etc.) with the numbers being based on an order that I set- meaning I need cow to be 1 and zebra to be 3, I can't just order them in an arbitrary way (sample file attached). What would be the best way to do that using VB?

Also, some of the names have hypens (-) in the string. Not sure if that affects anything, but just letting you know

Technically, I could do a Case Statement but in the complete file I have 32 names, so i didn't feel that writing 32 cases was so efficient...

Please let me know if you have any suggestions!

Thanks so much!
Attached Files

Parsing SOAP XML with Classic ASP

$
0
0
I'm typically a LAMP stack developer, so I'm a little out of my comfort zone on this one. I'm working on a classic ASP site that is doing a SOAP based XML API connection. It's worked in the past, but now we're updating the API to connect to a different application. I set up a SOAP client before writing this API, and it tested good. I've run several tests since to be sure that it is still working.

I set up a local ASP server to try to get the most detailed error possible. Here's what I get:
Code:

Microsoft VBScript runtime error '800a01a8'

Object required: '[object]'

/inc/verify.asp, line 66

Line 66 is as follows:
Code:

isSuccess = objDoc.getElementsByTagName("Status").item(0).text
If it is helpful, here is the full document.

Code:

<%@ language=vbscript %>
<% Option Explicit %>
<%
'============================================================'
'  Authenticate a representative using the representative's
'  user name (RepDID or EmailAddress) and password.
'============================================================'

'----------------------------------------------------------'
' Process User Submitted Data
'----------------------------------------------------------'
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then

        'Load form fields into variables
        Response.Write "<p>Loading form fields into variables</p>"
        Dim repUsername, repPassword
        repUsername = Trim(Request.Form("rep-username"))
        repPassword = Trim(Request.Form("rep-password"))

        'Set up basic Validation...
        Response.Write "<p>Validating form</p>"
        If repUsername = "" Or repPassword = "" Then
                Response.Redirect ("../index.asp?login=error#login")

        Else
                '----------------------------------------------------------'
                ' Compose SOAP Request
                '----------------------------------------------------------'
                Dim xobj, SOAPRequest
                Set xobj = Server.CreateObject("Msxml2.ServerXMLHTTP")
                xobj.Open "POST", "http://api.domain.com/3.0/Api.asmx", False
                xobj.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
                xobj.setRequestHeader "SOAPAction", "http://api.domain.com/AuthenticateCustomer"
                SOAPRequest = _
                "<?xml version=""1.0"" encoding=""utf-8""?>" &_
                        "<x:Envelope xmlns:x='http://schemas.xmlsoap.org/soap/envelope/' xmlns:api='http://api.domain.com/'>"&_
                                "<x:Header>" &_
                                        "<api:ApiAuthentication>" &_
                                                "<api:LoginName>string</api:LoginName>" &_
                                                "<api:Password>string</api:Password>" &_
                                                "<api:Company>string</api:Company>" &_
                                        "<api:ApiAuthentication>" &_
                                "</x:Header>" &_
                                "<x:Body>" &_
                                        "<api:AuthenticateCustomerRequest>" &_
                                                "<api:LoginName>"&repUsername&"</api:LoginName>" &_
                                                "<api:Password>"&repPassword&"</api:Password>" &_
                                        "</api:AuthenticateCustomerRequest>" &_
                                "</x:Body>" &_
                        "</x:Envelope>"

                Response.Write "<p>Sending SOAP envelope</p>"
                xobj.send SOAPRequest

        '----------------------------------------------------------'
        ' Retrieve SOAP Response
        '----------------------------------------------------------'
                Dim strReturn, objDoc, isSuccess
                Response.Write "<p>Receiving SOAP response</p>"
                strReturn = xobj.responseText 'Get the return envelope

        Set objDoc = CreateObject("Microsoft.XMLDOM")
                objDoc.async = False
                Response.Write "<p>Loading XML</p>"
                objDoc.LoadXml(strReturn)
                Response.Write "<p>Parsing XML</p>"
                isSuccess = objDoc.getElementsByTagName("Status").item(0).text

                '----------------------------------------------------------'
                ' If user is valid set Session Authenticated otherwise
                ' restrict user and redirect to the index page and show error
                '----------------------------------------------------------'
                Response.Write "<p>Authenticating...</p>"
                If isSuccess = "Success" Then
                        Session("Authenticated") = 1
                        'Session.Timeout = 1 '60 'Expire session 1 hours from current time
                        Response.Redirect ("../welcome.asp#AdvancedTrainingVideos")

                Else
                        Session("Authenticated") = 0
                        Response.Redirect ("../index.asp?login=error#login")

                End IF 'END - isSuccess

        End IF ' END - Basic Validation...
End IF 'END - REQUEST_METHOD POST

%>

Any insights are very welcome.

No JSON Arrays Left to Parse

$
0
0
I am working to get my code to loop through arrays of JSON strings (of same format) until it reaches the end of the arrays (i.e., no strings left). I need the code to recognize it has reached the end by identifying that a certain identifier (present in every set) does not have additional information in the next array. So I believe I am looking for "while" syntax that says "while this identifier has content" proceed parsing the JSON according to the below code. My existing code works for array of strings for which I know the length - unfortunately the lengths are variable therefore I need flexible syntax to adjust with the lengths (i.e., "For 0 to n" doesn't work every time).

The JSON code I am parsing is in this format:

Code:

{"id":1,"prices":[{"name":"expressTaxi","cost":{"base":"USD4.50"....}}
Here the identifier structure I'd like to augment with some type of while loop (the "i" is the index number depending on the # of loop in the yet to be implemented "while" loop).

Code:

Json("prices")(i)("name")
So ideally looking for something like:

Code:

"While Json("prices")(i)("name") has information" then proceed on....
Please note again, everything works when I know the length -- just looking for a small syntax update, thank you! Full code below:

Code:

Option Explicit

Sub getJSON()
sheetCount = 1
i = 1
urlArray = Array("URL1", “URL2”, “URL3”)

Dim MyRequest As Object: Set MyRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim MyUrls: MyUrls = urlArray
Dim k As Long
Dim Json As Object

For k = LBound(MyUrls) To UBound(MyUrls)
    With MyRequest
        .Open "GET", MyUrls(k)
        .Send
        Set Json = JsonConverter.ParseJson(.ResponseText)
      ''[where I’d like some type of While statement checking into the below line for content]
        Sheets("Sheet" & sheetCount).Cells(i, 1) = Json("prices")(i)("name")
        Sheets("Sheet" & sheetCount).Cells(i, 2) = Json("prices")(i)("cost")("base")
        i = i + 1
  End With
sheetCount = sheetCount + 1
Next
End Sub

How to search for more than 1 value using RegExp

$
0
0
I have a working VB scripts that currently search a single value under the session variable property_key and if match found it set to zero and exit. Now I am trying to modify the script so that it searches for three values in stead one.

Basically where I have the value = "Dept1", I need to replace it with something like value in "Dept1","Dept2","Dept3". If any of these three values match found set to 0 and exit.

Any assistant or direction greatly appreciated.


Code:

' define variables
'
dim Arguments, Property_Key, Value, returnData, result
dim instanceValue, instanceValues, instanceValueArray
Dim regEx, matchFound

' Session Property_Key information to test for
'
Property_Key = "SE_ssgnames"
Value = "Dept1"

' define Arguments object and return scripting dictionary of User Session returned data
'
set Arguments = Permission.Arguments
result = 1

' - retrieve return data for the dictionary item only for this Property_Key
'
returnData = Arguments(Property_Key)

' split the return data for processing
'
instanceValues = Split(returnData, ",")

' loop through and validate the Values for a match,
' when a match is found, set the result to 0 and exit the loop
'
Set regEx = New RegExp
regEx.Pattern = replace(Value, "\", "\\")
regEx.IgnoreCase = True

for each instanceValue in instanceValues
  '
  ' check for each value
  '
  matchFound = regEx.Test(instanceValue) ' Execute search.
  if matchFound then
    result = 0
    exit for
  end if
next

set Arguments = Nothing
set regEx = Nothing

' return the result
'
Permission.Exit(result)
'

vbscript to find a strings id and perform some operations and export data to an excel

$
0
0
Hi Team

I am newbie to VBscript and looking for an help. There are many log files in a folder. I want to search a string string1 and get its id loaded to a variable var1. Then search another string2 within the same id var1 if it is found some data in the log within the same var1 id need to be exported to an excel.

Please let me know whether i can achieve this in VBscript. Any helps and suggestions are welcome

the log file contains like below line multiple lines.

Line 8122: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | starts
Line 8123: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| DQLN=EQUAL_QUAL_QUEUE_GOHEAD_IT
Line 8124: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| INDX=1
Line 8125: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| DQLN=Another_id
Line 8126: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | EVNT=SWIdmst|DQLN=YN| Name=QID|Inputs=[accNumber=12457845,oon=6842703020]|Outputid=00a4028a87c4473f,amid=2353.6,TransactionTime=125ms
.........
Line 8160: Feb 01 19:44:40.961 | INFO | JEZHckpTehtA-ADSW4T14T5 | PROD | 10.86.99.108 | Feb 01 2016 19:44:29.595 | ends


String1 is: QUAL_QUEUE_GOHEAD_IT
Var1 is: JEZHckpTehtA-ADSW4T14T5
string2 is: Another_id
need to get details of accNumber=12457845,oon=6842703020,Outputid=00a4028a87c4473f,amid=2353.6 values to excel sheet.

I have the below code for it just started working on it,

Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Users\shambu\Desktop\otq"
Set objFolder = objFSO.GetFolder(objStartFolder)
Dim varid

For Each objFile in objFolder.Files
set oStream = objFile.OpenAsTextStream(1)
If not oStream.AtEndOfStream Then
contents = oStream.ReadAll
End If
oStream.Close

Set re = New RegExp
re.Pattern = "INFO \| ([^\|]*) \|.*QUAL_QUEUE_GOHEAD_IT"
re.Global = True
Set matches = re.Execute(contents)

For Each match In Matches
varid = match.SubMatches(0)
ProcessMatch objFile.Path, varid
Next

Next
sub ProcessMatch(path, id)
Msgbox "Match " & id & " found in " & path
end sub

Need to raise an image higher in html

$
0
0
Hi all, I'm REALLY new at this. I know almost nothing about html. So I need some help. I downloaded a free template that's perfect for my website, but I needed to change the logo. So I created one on the net. But the logo I created is positioned lower than the original and doesn't look as good that way.

I've been looking at the code and I don't see a way to change where the image starts. Here's the "head" code:
Code:

  <header>
    <div class="container_24">
            <!-- .logo -->
            <div class="logo">
              <a href="index.html"><img src="images/logo.png" alt="Shades"></a>
      </div>
            <!-- /.logo -->
      <!-- .extra-navigation -->
      <ul class="extra-navigation">
              <li><a href="index.html" class="home current">&nbsp;</a></li>
        <li><a href="#" class="map">&nbsp;</a></li>
        <li><a href="index-5.html" class="mail">&nbsp;</a></li>
      </ul>
      <!-- /.extra-navigation -->
      <nav>
        <ul>
                <li><a href="index.html" class="current">Home</a></li>
          <li><a href="index-1.html">Support</a></li>
          <li><a href="index-2.html">Services</a></li>
          <li><a href="index-3.html">Download</a></li>
          <li><a href="index-4.html">Clients</a></li>
          <li class="last"><a href="index-5.html">Contacts</a></li>
        </ul>
      </nav>
    </div>
  </header>

Would really appreciate any help. I'm a fish out of water here.

Dllcalls in a vbscript

$
0
0
I am not sure, this is probably not the right subforum... I would like to have a simple vbs script which runs on every Windows PC without additional apps and tools.

Below is a short script written in AHK: A text string is extracted from a file and added as resource in an exe file by dllcalls.

Can this be reproduced in a simple way in vbs?

Thank you very much in advance!

ExeFile = MyExe.exe
ScriptF = Script.txt
FileRead, Script, %ScriptF%

VarSetCapacity(Bin, BinScript_Len := StrPut(Script, "UTF-8") - 1)
StrPut(Script, &BinScript, "UTF-8")

Module := DllCall("BeginUpdateResource", "str", ExeFile, "uint", 0, "ptr")

DllCall("UpdateResource", "ptr", Module, "ptr", 10, "str", ">MY SCRIPT<"
, "ushort", 0x409, "ptr", &BinScript, "uint", BinScript_Len, "uint")
DllCall("EndUpdateResource", "ptr", Module, "uint", 0)

VB script for window services

$
0
0
Hi

We are using vbs script to monitor the services in SAP application.Below script was already implemented.It is listing only some services in SAP(stopped and running) .Please help me in the script to list all the services.

Const ForAppending = 8
DIM prefix, prelen
DIM pattern
pattern="%"

Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objLogFile = objFSO.OpenTextFile("services.csv", ForAppending, True)
Set objLogFile = Wscript.StdOut
'objLogFile.Write("Service Dependencies")
objLogFile.Writeline
strComputer = "."

DIM name

if WScript.Arguments.length = 1 then
pattern = WScript.Arguments(0)
end if

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
query = "Select * from Win32_Service where Name like '" & pattern & "' AND ServiceType = 'Own Process' OR ServiceType='Interactive Process'"
WScript.Echo query

Set colListOfServices = objWMIService.ExecQuery(query)

prefix = "C:\WINDOWS\"
prelen = len(prefix)
For Each objService in colListofServices
If not startsWith(objService.PathName,prefix,prelen) Then
objLogFile.Write " service_name=" & objService.Name & ";service_type=ntsrv;service_caption=" & objService.DisplayName& ";service_user=" & objService.StartName & ";service_Executable=" & objService.PathName & ";service_resources=serviceName_"&objService.Name
objLogFile.WriteLine
End If
Next
objLogFile.Close


Function startsWith(str1, prefix,prelen)
startsWith = Left(LCase(str1),prelen) = LCase(prefix)

End Function

Thanks,
karthik

Encryption (vbe files)

$
0
0
Hi

I have a file which is included in a number of pages

<!-- #include file="../_script/vb/blah.vbs" -->

The script includes some constants that I have been told to encrypt some how.
Using the windows encryption tool I encrypted this script creating a vbe copy of the file.
The problem I have is that other pages that include this file cant see it and when I change the references to

<!-- #include file="../_script/vb/blah.vbe" -->

the pages cant read the constants as they are encrypted.

What am I missing?
Do I neefd to encrypt everything that includes this script as well?

Reflection Loop Not Working

$
0
0
I tried to look all over the place for an answer, but I'm new to coding for my call center and really need some help. Here is what I'm trying to accomplish:

In Reflection, I am trying to search for a specific string within a set of rows. If the string is not on the first row, I want the cursor to move down to the next row and search for the string (repeating until the string is found on a row). Once the string is found, I want the cursor to select that row.

I have included my code which isn't working but hopefully will help:

-Sub gynbereferral()
-Const NEVER_TIME_OUT = 0

-Dim LF As String ' Chr(rcLF) = Chr(10) = Control-J
-Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
-Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[

-LF = Chr(Reflection2.ControlCodes.rcLF)
-CR = Chr(Reflection2.ControlCodes.rcCR)
-ESC = Chr(Reflection2.ControlCodes.rcESC)

-With Session
-Dim Reflection As Object
-Set Reflection = GetObject(, "Reflection2.Session")
-Dim LastColumn As Integer
-LastColumn = .DisplayColumns
-Dim cursorRow As Integer
-cursorRow = .cursorRow
-Dim screen_name As String
-screen_name = Reflection.GetText(0, 32, 0, 47)
-Dim ploc_name As String
-ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
-Dim Text As String
-Text = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)


-.Transmit "r" & CR
-.Transmit "m" & CR
-.Wait ("1")
-ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
-Do
-If ploc_name Like "*GYBEGP*" Then
-.TransmitTerminalKey rcVtSelectKey
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.TransmitTerminalKey rcVtRemoveKey
-.Transmit "99"
-.TransmitTerminalKey rcVtEnterKey
-.TransmitTerminalKey rcVtRemoveKey
-.Transmit "ftr" & CR
-.Transmit CR
-.Transmit CR
-.Transmit "+90" & CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.Transmit CR
-.StatusBar = "Waiting for Prompt: File changes and exit."
-.WaitForString ESC & "[KFile changes and exit.", NEVER_TIME_OUT, -rcAllowKeystrokes
-.StatusBar = ""
-.Transmit CR
-.StatusBar = "Waiting for Prompt: Print (L)ist, or (Q)uit:"
-.WaitForString LF & " Print (L)ist, or (Q)uit: ", NEVER_TIME_OUT, -rcAllowKeystrokes
-.StatusBar = ""
-.Transmit "b" & CR
-.TransmitTerminalKey rcVtSelectKey
-Else
-.TransmitTerminalKey rcVtDownKey
-ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
-Loop Until ploc_name Like "*GYBEGP*"
-Loop

-Do
-If ploc_name Like "*GYBEGP*" Then
-.TransmitTerminalKey rcVtSelectKey
-Else
-.Wait ("3")
-.TransmitTerminalKey rcVtDownKey
-.Wait ("3")
-ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
-Loop Until ploc_name Like "*GYBEGP*"
-Loop

Sometimes I can get my loop to work but it won't stop looping, like it it's looking for the GYBEGP string.

PLEASE HELP!!!
Viewing all 663 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>