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

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!!!

Problems converting a constant

$
0
0
I have a vbs file which contains a huge list of constants e.g

Private Const Client = 3

The problem I am having is that I need to change one of these constants into a variable populated by a function call. e.g

Private Const Client = MyFunction()

Naturally this will not work as it is a constant but I cant declare it as :

Dim Client
Client = MyFunction()


because on a million pages which include this file and refer to this variable they will find that Client = nothing.

Why cant I do this :

Dim Client = MyFunction()

There is no option explicit on my page although maybe the many pages including this file may have it on which I cannot change.
Any ideas how I can get around this?

Access website and grab cookie

$
0
0
I've never really worked with VBscript, but I was asked to see if I could write a script that would run on a schedule on a PC to access a website and grab the cookie in order to send it to another server.

Does anyone know how to do this or a site that has instructions how to do this?

VBScript help on mouse action and screen resolutions

$
0
0
Hello all,

I have a problem that I am hoping can be resolved with a simple VBS text doc.

I have two computers on separate networks that share a mouse/keyboard with the use of a USB Switch board. The switchboard can be activated with either a button press or a keystroke-combo. These computers both have multiple monitors and I would like to have a VBS script running in the background of each computer so that when the mouse enters the very last pixel display on computer A the hotkey to switch the mouse/keyboard to computer B gets hit, and vice-versa for the other computer (the first pixel instead of last).

I have basic knowledge of VBS and have programmed a lot in VB.Net.

I already know how to set up a loop and send a keystroke. What I need to know is how to gather the total screen resolution from all monitors, get the last/first pixel distance in the X axis, and then determine when (inside the loop obviously) the mouse position is equal to the X value to send the hotkey. Could anyone possibly post some reference links for me on how to accomplish this in VBS?

Many thanks!
~Frab

Run-time error '2147217900 (80040e14)' when fetch data from excel to SQL server

$
0
0
Dear All,

I tried to fetch data from excel to SQL server. I have created Recordset, connection and command under ADODB. Everything were fine because I used this method many times already.
I have problem when I wanted to fetch one SQL command with variable (which I took from one of the excel field with name 'ProjectCode'). I got the value from that cell with command Range("ProjectCode").Value. My SQL query is running well when I run directly from Microsoft SQL Server Management Studio but I got error when I translate this to VbScript on my excel. Can please someone help me because I never use variable on my query using VbScript on my excel before? I throw the following command to my commandText on ADODB.Command. (Dim vlo_Command As New ADODB.Command. End then I put the following script to "vlo_Command.CommandText = 'my script below'"). I got runtime error '2147217900 (80040e14). Invalid column name 'P100' (assume value of ProjectCode field was P100) when I run my script. Can please someone help me?

SELECT Act.ActName, " & vbCrLf & _
"Users.FullName,TimeS.WeekEndingDate," & vbCrLf & _
"Times.HrsWrkMonday,TimeS.HrsWrkTuesday,TimeS.HrsWrkWednesday,TimeS.HrsWrkThursday,TimeS.HrsWrkFrida y,TimeS.HrsWrkSaturday,TimeS.HrsWrkSunday," & vbCrLf & _
"SUM(HrsWrkMonday+HrsWrkTuesday+HrsWrkWednesday+HrsWrkThursday+HrsWrkFriday+HrsWrkSaturday+HrsWrkSun day) as 'TimeSpent'," & vbCrLf & _
"Times.TeamID," & Range("ProjectCode").Value & vbCrLf & _
"FROM " & vbCrLf & _
"[IT_Timesheet].[dbo].[tblITTimeSheet] TimeS " & vbCrLf & _
"INNER JOIN " & vbCrLf & _
"[IT_Timesheet].[dbo].[tblITActivity] Act " & vbCrLf & _
"ON " & vbCrLf & _
"TimeS.ActID = Act.ActID " & vbCrLf & _
"INNER JOIN " & vbCrLf & _
"[IT_Timesheet].[dbo].[tblITUserAdministration] Users " & vbCrLf & _
"ON " & vbCrLf & _
"TimeS.UserId = Users.UserId WHERE Act.ActID = (SELECT ActID FROM [IT_Timesheet].[dbo].[tblITActivity] WHERE ActName LIKE '%' +" & Range("ProjectCode").Value & "+ '%') " & vbCrLf & _
"GROUP BY " & vbCrLf & _
"Act.ActName," & vbCrLf & _
"Users.FullName," & vbCrLf & _
"TimeS.WeekEndingDate," & vbCrLf & _
"Times.HrsWrkMonday,TimeS.HrsWrkTuesday,TimeS.HrsWrkWednesday,TimeS.HrsWrkThursday,TimeS.HrsWrkFrida y,TimeS.HrsWrkSaturday,TimeS.HrsWrkSunday," & vbCrLf & _
"Times.TeamID,TimeS.Reference " & vbCrLf & _
"HAVING " & vbCrLf & _
"Sum (HrsWrkMonday + HrsWrkTuesday + HrsWrkWednesday + HrsWrkThursday + HrsWrkFriday + HrsWrkSaturday + HrsWrkSunday) <> 0 " & vbCrLf & _
"Order BY WeekEndingDate Desc, FullName Desc"

Outlook VBA balloon notification

$
0
0
I am trying to show a specific balloon notification for when new mail comes in outlook. I have the following which will trigger on new mail but what can i add to just show a basic notification? Not really looking for a message box.
HTML Code:

http://www.howtogeek.com/wp-content/uploads/2015/08/648x298x00_lead_image_email_notification.png.pagespeed.gp+jp+jw+pj+js+rj+rp+rw+ri+cp+md.ic.qGvMu2Vv3i.png
Code:

Private Sub Application_NewMail()


End Sub


ADSI authentication by ASP

$
0
0
Hello,

I am using this function code in vbs file and works, but in asp page does not work.

####################################
Code:

function AuthenticateUser(strUser, strPW)

Const ADS_SECURE_AUTHENTICATION = &h0001
Const ADS_CHASE_REFERRALS_ALWAYS = &h60

strUser=split(strUser,"\")
i=0
for each x in struser

        if i=1 then

                    strUserName = x
        end if
i=i+1

next


Set objNetwork = CreateObject("WScript.Network")
strDomain = objNetwork.UserDomain

Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

Set objCommand.ActiveConnection = objConnection
strBase = "<LDAP://" & strDNSDomain & ">"

strFilter = "(&(objectclass=user)(objectcategory=person))"
strAttributes = "distinguishedName,sAMAccountName,displayName"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"

objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False

Set objRecordset = objCommand.Execute


strPath = "LDAP://" & strDomain & "/" & strDNSDomain
Set objDSO = GetObject("LDAP:")


Do Until objRecordSet.EOF
       
        if strusername = objRecordSet.Fields.item("sAMAccountName").Value then

                strUser = objRecordSet.Fields.item("sAMAccountName").Value
       
                set objUser = objDSO.OpenDSObject (strPath, strUser, strPW, ADS_SECURE_AUTHENTICATION OR ADS_CHASE_REFERRALS_ALWAYS)
       
       
                If Err.Number <> 0 Then

                        response.write "NO COINCIDEN"
                Else

                        response.write "COINCIDEN"
                End If
                Err.Clear
        END IF

        objRecordSet.MoveNext
Loop

End function

########################

In ASP page, the problem is here:

set objUser = objDSO.OpenDSObject (strPath, strUser, strPW, ADS_SECURE_AUTHENTICATION OR ADS_CHASE_REFERRALS_ALWAYS)

Could you help me please??
I checked strPath, strUser and, strPW and they have values.

Thanks

VBscript put path on "field" file

$
0
0
Hi, im try to upload my profile pictures in facebook by put the url on a "field file" without click "Choose" with this code, but, is not working:

Set IE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "https://m.facebook.com/photos/upload?profile_pic"
IE.Visible = True
Wscript.Sleep 2000
IE.Document.All.Item("file1").Value = "C:/10001.jpg"


The script can't populate that field. Why? any solution?

Usage of MSXML2.ServerXMLHTTP in vb script

$
0
0
Hi I am new to vb script and we are calling webservice function from vb script by using "MSSOAP.SoapClient30" as below and getting the response.
everything is working fine but now we are trying to use "MSXML2.ServerXMLHTTP.6.0" instead of "MSSOAP.SoapClient30" in vb script to call the webservice function as below and it is returning the response however the response we are getting is different then previous one
what changes should I do to get the response same as previous one

vb script code using "MSSOAP.SoapClient30"


sAdminSOAPUrl = "http://usalvwcrmssqa08.infor.com:80/ss1001wliis_qa08/ecs/webservices/AdminService?wsdl"
Dim vaData
Set soapClient3 = CreateObject("MSSOAP.SoapClient30")
Call soapClient3.MSSoapInit(sAdminSOAPUrl, "AdminService", "AdminService")
soapClient3.ConnectorProperty("EndPointURL") = sAdminSOAPUrl

vaData = soapClient3.exportDeployment("psoli","psoli","oob_data")
WScript.Echo vaData



vb script code using "MSXML2.ServerXMLHTTP.6.0"


' Namespaces.
Dim NS, NS_SOAP, NS_SOAPENC, NS_XSI, NS_XSD
NS = "http://www.w3schools.com/webservices/"
NS_SOAP = "http://schemas.xmlsoap.org/soap/envelope/"

' Creates an XML DOM object.
Set DOM = CreateObject("MSXML2.DOMDocument.6.0")

' XML DOM objects.
Dim Envelope, Body, Operation, Param
Const URL = "http://usalvwcrmssqa08.infor.com:80/ss1001wliis_qa08/ecs/webservices/AdminService?wsdl"

' Creates the main elements.
Set Envelope = DOM.createNode(1, "soap:Envelope", NS_SOAP)
DOM.appendChild Envelope
Set Body = DOM.createElement("soap:Body")
Envelope.appendChild Body

' Creates an element for the exportDeployment function.
Set Operation = DOM.createNode(1, "exportDeployment","")
Body.appendChild Operation

' Creates an element for the exportDeployment parameter
Set Param = DOM.createNode(1, "username","")
Param.Text = "psoli"
Operation.appendChild Param

Set Param1 = DOM.createNode(1, "password","")
Param1.Text = "psoli"
Operation.appendChild Param1

Set Param2 = DOM.createNode(1, "deploymentName","")
Param2.Text = "oob_data"
Operation.appendChild Param2

' Releases the objects.
Set Param = Nothing
Set Operation = Nothing
Set Body = Nothing
Set Envelope = Nothing
DIM test

Set XMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
XMLHTTP.Open "POST", URL, False
XMLHTTP.setRequestHeader "Content-Type", "multipart/form-data; User-Agent: SOAP Sdk"
XMLHTTP.setRequestHeader "SOAPAction", "AdminService"
XMLHTTP.send DOM.xml

' Loads the response to the DOM object.
DOM.LoadXML XMLHTTP.responseXML.xml
'WScript.Echo XMLHTTP.responseXML.xml

WScript.Echo XMLHTTP.responseXML.xml

' Releases the object.
Set XMLHTTP = Nothing

' XML DOM objects.
Dim NodeList, Element, vaData

' Searches for the exportDeploymentReturn object, which contains the value.
Set NodeList = DOM.getElementsByTagName("*")
For Each Element in NodeList
If Element.tagName = "exportDeploymentReturn" Then
vaData = Element.Text
Exit For
End If
Next

WScript.Echo vaData

Issue with webservice response while using MSXML2.ServerXMLHTTP.6.0 in vb script

$
0
0
Hi We are calling the webservice function from vb script by using "MSSOAP.SoapClient30", the function returns the byte array and we are saving that as *.jar file below is the sample code

============================================================
sAdminSOAPUrl = "http://testapp.com:80/test/ecs/webservices/AdminService?wsdl"
Dim vaData
Set soapClient3 = CreateObject("MSSOAP.SoapClient30")
Call soapClient3.MSSoapInit(sAdminSOAPUrl, "AdminService", "AdminService")
soapClient3.ConnectorProperty("EndPointURL") = sAdminSOAPUrl

vaData = soapClient3.exportDeployment("test","test","test_data")

If (IsArray(vaData)) Then
rgData = vaData
WScript.Echo rgData
sFilename = sPath & "xplbio.jar"
hFile = FreeFile()

Open sFilename For Binary As #hFile
Put #hFile, , rgData
Close #hFile

Dim fso As New FileSystemObject
fso.CopyFile sFilename, sPath & sExportName & ".jar"
fso.DeleteFile sFilename, True
End If
============================================================

now we are trying to use the "MSXML2.ServerXMLHTTP.6.0" instead of "MSSOAP.SoapClient30" but facing issues while writing the response into *.jar file and its being corrupt.
we have tried by channging the respose header as below but facing the same issue
"Content-Type", "text/xml; charset=utf-8",
"Content-Type" "multipart/form-data",
"Content-Type" "application/x-www-form-urlencoded",

is there any thing which I am missing please suggest, below is the sample updated code

==============================================================
' Namespaces.
Dim NS, NS_SOAP, NS_SOAPENC, NS_XSI, NS_XSD
NS_SOAP = "http://schemas.xmlsoap.org/soap/envelope/"

' Creates an XML DOM object.
Set DOM = CreateObject("MSXML2.DOMDocument.6.0")

' XML DOM objects.
Dim Envelope, Body, Operation, Param
Const URL = "http://testapp.com:80/test/ecs/webservices/AdminService?wsdl"

' Creates the main elements.
Set Envelope = DOM.createNode(1, "soap:Envelope", NS_SOAP)
DOM.appendChild Envelope
Set Body = DOM.createElement("soap:Body")
Envelope.appendChild Body

' Creates an element for the exportDeployment function.
Set Operation = DOM.createNode(1, "exportDeployment","")
Body.appendChild Operation

' Creates an element for the exportDeployment parameter
Set Param = DOM.createNode(1, "username","")
Param.Text = "test"
Operation.appendChild Param

Set Param1 = DOM.createNode(1, "password","")
Param1.Text = "test"
Operation.appendChild Param1

Set Param2 = DOM.createNode(1, "deploymentName","")
Param2.Text = "test_data"
Operation.appendChild Param2

DIM test

Set XMLHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
XMLHTTP.Open "POST", URL, False
XMLHTTP.setRequestHeader "Content-Type", "multipart/form-data; User-Agent: SOAP Sdk"
XMLHTTP.setRequestHeader "SOAPAction", URL
XMLHTTP.send DOM.xml

' Loads the response to the DOM object.
DOM.LoadXML XMLHTTP.responseXML.xml

' XML DOM objects.
Dim NodeList, Element, vaData

' Searches for the exportDeploymentReturn object, which contains the value.
Set NodeList = DOM.getElementsByTagName("*")
For Each Element in NodeList
If Element.tagName = "exportDeploymentReturn" Then
vaData = Element.Text
Exit For
End If
Next

If (IsArray(vaData)) Then
rgData = vaData
WScript.Echo rgData
sFilename = sPath & "xplbio.jar"
hFile = FreeFile()

Open sFilename For Binary As #hFile
Put #hFile, , rgData
Close #hFile

Dim fso As New FileSystemObject
fso.CopyFile sFilename, sPath & sExportName & ".jar"
fso.DeleteFile sFilename, True
End If
====================================================================

Combine 2 vbs Scripts

$
0
0
Hello to everyone
I'm trying to make a vbs script to to run a batch/cmd file elevated/with admin priviledges. Both files are in the same folder.
I also want to be able to run the script from no matter which drive or directery the folder is placed.
I mean using the equivalent of %~dp0 variable in the vbs script. Right now I have 2 vbs scripts.
One runs the cmd elevated, and the second one can run the cmd from inside the folder where they bothe are placed.
My problem: I'm unable to put the code of the 2 vbs scripts to one and a single vbs script file. As you will notice, I'm not so experienced in creating scripts. I need your help please.

First script to run cmd with admin priviledges:

Code:

et WshShell = WScript.CreateObject("WScript.Shell")
  If WScript.Arguments.length = 0 Then
  Set ObjShell = CreateObject("Shell.Application")
  ObjShell.ShellExecute "wscript.exe", """" & _
  WScript.ScriptFullName & """" &_
  " RunAsAdministrator", , "runas", 1
  Wscript.Quit
  End if

Set WinScriptHost = CreateObject("WScript.Shell")
CreateObject("Wscript.Shell").Run "cmd /k " & chr(34) & "C:\Users\xxxxx\Documents\file.cmd" & chr(34), 0, True
Set WinScriptHost = Nothing

Second script to run cmd from the same folder as the vbs script:

Code:

Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
sScriptDir = oFSO.GetParentFolderName(WScript.ScriptFullName)
CreateObject("Wscript.Shell").Run "file.cmd",0,True

Thank You
Viewing all 661 articles
Browse latest View live


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