Deep Patel

Friday, November 6, 2020

 runas /u:MicrosoftAccount\users@xxx.xxx cmd.exe

Wednesday, June 5, 2013

Masking the characters in a cell with Asterisk/Password Characters for text in an excel Cell.

Sometimes we enter password in Excel Sheet(eg. Excel vba Utilities)
It is desired that the password be masked using Password Characters(like *)

This can be done by following steps.

1.    Select the step you want to mask with Password Characters




2.    Go to Format Cells>Number >Custom


3.    Enter the Type as mentioned in the below screenshot and press OK


4.    The data in the cell now appears masked as shown below




Tuesday, February 26, 2013

Generic vb Functions for any Webpage



Generic functions which can be used in vbscript or vba macro to open URL, enter values in text box, click a link and get all links on a webpage.
The below code shows a sample of the usage.
It asks for username and password, log into the web application and clicks on all links one by one.

You can use the generic functions/subs available at the lower part of the code

Dim IE
Dim IE2
uname=InputBox("Enter your uname")
passs=InputBox("Enter your password")
Set IE = WScript.CreateObject("InternetExplorer.Application")

'set the ie properties
IE.ToolBar = 0
IE.StatusBar = 1
IE.Width = 999
IE.Height = 999
IE.Left = 0
IE.Top = 0
IE.Visible = 1

'navigate to a web page
IE.Navigate("http://www.yourURL/")
WaitForLoad IE


WebFormFill "", , 0 
WebFormFill "",,1 
WaitForLoad IE

ClickLink ""
WaitForLoad IE


Set ElementCol = IE.Document.getElementsByTagName("a")
'Get all links on web page
'Grap/click the link we are looking for...
For Each Link In ElementCol
If instr(1,Link.innerHTML,". http://")>1 Then
mylink = Link.innerHTML

ClickLink mylink


End If
Next




Msgbox "Completed"


Sub GetOtherIE(URL)
  Dim objInstances, objIE
  Set objInstances = CreateObject("Shell.Application").windows
  If objInstances.Count > 0 Then '/// make sure we have instances open.
    For Each objIE In objInstances
 If InStr(objIE.LocationURL,URL) > 0 then
   Set IE2 = objIE
 End if
    Next
  End if
End Sub

'Attaches to an existing instance of IE with matching URL
Sub GetIE(URL)
  Dim objInstances, objIE
  Set objInstances = CreateObject("Shell.Application").windows
  If objInstances.Count > 0 Then '/// make sure we have instances open.
    For Each objIE In objInstances
 If InStr(objIE.LocationURL,URL) > 0 then
   Set IE = objIE
 End if
    Next
  End if
End Sub

'fills a form field and optionally submits form
Sub WebFormFill(fieldname,fieldvalue,submit)
  Dim FormNr
  Dim ItemNr
  Dim TheForm

  if IE.Document.All.Tags("FORM").Length = 0 then
    MsgBox("No form found in page")
  else
    for FormNr = 0 to IE.Document.Forms.Length - 1
      Set TheForm = IE.Document.Forms(FormNr)
      for ItemNr = 0 to TheForm.Elements.Length - 1
        if TheForm.Elements(ItemNr).Name = fieldname then
          TheForm.Elements(ItemNr).Value = fieldvalue
          If submit=1 then
            TheForm.submit
          end if
          exit for
        end if
      next
    next
  end if
End Sub

'Navigates IE to specified URL
Sub Navigate(URL)
  IE.Navigate URL
  do while IE.Busy
  loop
End Sub

'clicks specified link
Sub ClickLink(linktext)
  Dim anchors
  Dim ItemNr

  Set anchors = IE.document.getElementsbyTagname("a")
  For ItemNr = 0 to anchors.length - 1
    If anchors.Item(ItemNr).innertext = linktext Then
 anchors.Item(ItemNr).click
End If
  next

  'do while IE.Busy
  'loop
End Sub

'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
  dim t
  set t = IE.document.getElementsbyTagname(Tagname)
  if all=1 then
    ExtractTag = t.Item(Num).outerHTML
  else
    ExtractTag = t.Item(Num).innerText
  end if
End Function

Sub WaitForLoad(obj)
Do While obj.Busy
loop
wscript.sleep(100)
End Sub

Monday, January 21, 2013

QC OTA code for getting Bug/Defect History

Get all the required history details of a Defect/Bug in QC using the OTA apis.

Use the below code to access the history of a defect

Dim BugFactory, BugList
Set BugFactory = QCConnection.BugFactory  
Set bugFilter = BugFactory.FilterSet BugList = bugFilter.NewList
Set Bug = BugList(0) 'gives the first bug in bug list

Set hst = Bug.history
Set hstList = hst.NewList("")
For j = 1 To hstList.Count
                Set hstRec = hstList.Item(j)
                HTMLMSg_Content = HTMLMSg_Content & " " & hstRec.FieldName
                HTMLMSg_Content = HTMLMSg_Content & "
"
                HTMLMSg_Content = HTMLMSg_Content & hstRec.ChangeDate & "
"
                HTMLMSg_Content = HTMLMSg_Content & "" & hstRec.NewValue & "
" 'Target Test Date
Next j


To get specific items from the list use if conditions as below:

Set hst = Bug.history
Set hstList = hst.NewList("")
For j = 1 To hstList.Count
                Set hstRec = hstList.Item(j)
                If hstRec.FieldName = "BG_STATUS" And hstRec.NewValue = "Ready to Test" Then
                                'HTMLMSg_Content = HTMLMSg_Content & " " & hstRec.FieldName
                                'HTMLMSg_Content = HTMLMSg_Content & "
"
                                HTMLMSg_Table2 = HTMLMSg_Table2 & "" & hstRec.ChangeDate & ""
                                'HTMLMSg_Content = HTMLMSg_Content & hstRec.ChangeDate & "
"
                                'HTMLMSg_Content = HTMLMSg_Content & "" & hstRec.NewValue & "
" 'Target Test Date
                                Exit For
                 End If
Next j

Friday, January 18, 2013

Zindagi Na Milegi Dobara - Imraan's Poems

Poem 1 - after scuba diving.

Pighlay neelam sa behta hua yeh samaan
Neeli neeli si khamoshiyaan
Na kahin hai zameen
Na kahin aasmaan
Sarsaraati huyi tehniyaan, pattiyaan
Keh rahi hain ki bas ek tum ho yahaan
Sirf main hoon meri saansein hain aur meri dhadkanein
Aisi gehraiyaan
Aisi tanhaiyaan
Aur main sirf main
Apne honay pe mujhko yaqeen aa gaya


Poem 2 - after tamatina festival(leaving Laila).

Ik baat honton tak hai jo aayi nahin
Bas ankhon say hai jhaankti
Tumse kabhi, mujhse kabhi
Kuch lafz hain woh maangti
Jinko pehanke honton tak aa jaaye woh
…Aawaaz ki baahon mein baahein daalke ithlaye woh
Lekin jo yeh ik baat hai
Ahsas hi ahsas hai
Khushboo si hai jaise hawa mein tairti
Khushboo jo be-aawaaz hai
Jiska pata tumko bhi hai
Jiski khabar mujhko bhi hai
Duniya se bhi chupta nahin
Yeh jaane kaisa raaz hai

Poem 3- After Imran meets his father, Salman Habib

Jab jab dard ka baadal chaya
Jab ghum ka saya lehraya
Jab aansoo palkon tak aya
Jab yeh tanha dil ghabraya
Humne dil ko yeh samjhaya
…Dil aakhir tu kyun rota hai
Duniya mein yunhi hota hai
Yeh jo gehre sannate hain
Waqt ne sabko hi baante hain
Thoda ghum hai sabka qissa
Thodi dhoop hai sabka hissa
Aankh teri bekaar hi nam hai
Har pal ek naya mausam hai
Kyun tu aise pal khota hai
Dil aakhir tu kyun rota hai

Poem 4- Ending. 

Dilon mein tum apni
Betaabiyan leke chal rahe ho
Toh zinda ho tum
Nazar mein khwabon ki
Bijliyan leke chal rahe ho
Toh zinda ho tum
Hawa ke jhokon ke jaise
Aazad rehno sikho
Tum ek dariya ke jaise
Lehron mein behna sikho
Har ek lamhe se tum milo
Khole apni bhaayein
Har ek pal ek naya samha
Dekhen yeh nigahaein
Jo apni aankhon mein
Hairaniyan leke chal rahe ho
Toh zinda ho tum
Dilon mein tum apni
Betaabiyan leke chal rahe ho
Toh zinda ho tum





Wednesday, December 26, 2012

Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)


Title
Running a PASSPORT Emulator macro using a Visual Basic Application(Excel Macro)

Product
PASSPORT PC TO HOST

Emulation Types
SCO ANSI, Wyse 60, TN3270, TN5250, VT

Issue
Need to run a PASSPORT Macro from a Visual Basic Application.

Please see the following sample macro below:

Sub runmacro_zam()
    navigateto "C:\progra~1\passport\login.zam"
End Sub

Sub runmacro_zmc()
    navigateto "C:\progra~1\passport\login.zmc"
End Sub

Sub navigateto(macroname)
    Dim objSys
    Dim objSess
   
    Set objSys = CreateObject("PASSPORT.System")
    Set objSess = objSys.ActiveSession
   
    ' Assume you already have a PASSPORT session running
    objSess.navigateto macroname
End Sub

' You can use this too, but it will not work with a .zmc macro
Sub runmacro()
    Dim WshShell
   
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Exec ("C:\progra~1\passport\passatmr.exe /A 0 0 c:\progra~1\passport\login.zam")
End Sub