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

Thursday, December 13, 2012

Excel 2003 Datasheet not getting imported in QTP 10 Datatable

Recently faced issue,
"Excel 2003 Datasheet not getting imported in QTP 10 Datatable"

Environment Conditions:
- QTP 10
- Excel 2003/2007/2010 with no Excel Addins installed(Addins like Data Classification tools)
- Win XP/7
- File Format of Data Sheet (.xls or 97-2003)


Drilling Down...
Tried many things...
checking compatibility mode of Excel workbook, column headers, etc. Nothing worked.

Finally I tried data row by data row.
Created a new excel with same headers, just went on adding set of rows and finally drilled down to row which had the problem.

Root Cause:

The data in the column contained n-Dash instead of Hyphen
n-Dash being UNICODE character occupies more space and then hyphen(an ASCII).

Now when the total character size of cells containing Unicode characters increases beyond a certain limit(not sure about the limit but this is what I got from the set of execution I performed), QTP is not able to import any sheet of that Excel Workbook.

The difference can be seen below. n-dash in 1st row and hyphen in 2nd.






Solution: Replace all n-Dash by Hyphen

Try this if you too are facing a similar problem. Hope it helps...

Cheers....

Tuesday, May 8, 2012

Manzil bhi uski thi...

Manzil bhi uski thi rasta bhi uska tha,
Musafir bhi unke the aur kafila bhi uska tha,

Saath saath chalne ki soch bhi uski thi,
Phir rasta badal ne ka faisla bhi uska tha,

Hathon me haath lekar hame hasane ki kasam bhi uski thi,
Phir hamari aankho me aansuo ka silsila bhi uska tha,

Mohabbat ki khwahish to hamari thi,
Par dil tod ne ka iraada uska tha,

Aaj tanha hai to dil ye sochta hai,
Duniya to uski thi par kya khuda bhi uska tha???

via SMS

Thursday, March 1, 2012

Right click on disabled (or any other object) in QTP

I recently faced a problem on one of the Java Tables.

The table as such was disabled(freezed!).
Which can be enabled by right clicking and selecting "unfreeze"

QTP internally doesn't perform operations on disabled objects so it gave me errors when I used

Browser("SwingSet demo").Page("SwingSet demo").JavaApplet("SwingSetApplet").JavaTable("Inter-cell spacing:").ClickCell 2, "Last Name", "RIGHT", "SHIFT"

QTP gives "Object Disabled" message box.

To get over this I used "Mercury.DeviceReplay" object.

Device level replay simulates mouse or key operations exactly as if they occur on the mouse or keyboard drivers. When a mouse action is simulated on device replay, the mouse pointer moves on the screen to the point where the action is to be performed during the test run.

Script Snippet Start

Set objRightClickMenu = CreateObject("Mercury.DeviceReplay")
objRightClickMenu.MouseClick intX, intY, 2
Set objRightClickMenu = nothing

Script Snippet End

Here intX and intY are absolute co ordinates where you want to perform the click.

Tuesday, February 28, 2012

Indians are Engineers at Heart!

The title comes from the commentary on ESPN Cricinfo during todays exciting match between India and Sri Lanka at Bellerive Oval, Australia.

The commentators were awesome throughout. Posting some comments i liked...

"Indians are Engineers..."
when Gambhir and Sachin were getting over Kulasekara and Mahroof


It looked like Gambhir and Kohli were slowing down a bit and the commentator said it...:D
take that Dhoni...



and when Gambhir was out he again said it...:D





Indian team is like rocket...
when boundaries flowed...



Tell the Americans...
we are world champions...





Brief summary of the match:

The Indian skipper had won the toss and decided to bowl first.
Sri Lanka dominated with the batting when the set a target of 321 for India.
India had to make this score in 40 overs to get a bonus point.
Considering the recent games and Sri Lanka's form, it looked like India would struggle to make it upto 321, but thanks to the awesome start given by The God! and Viru; the fluent batting by Gauti; and a match winning innings by Virat Kohli; the Indian team made it in just 36.4 overs.

It was a do or die for team India!
and we made it...we still have a hope to be in the finals. All depends on the match at Melbourne on 2nd March.

Screenshots taken from ESPN Cricifo

Monday, February 27, 2012

QTP Random Number Generation - RandomNumber.Value vs Rnd and Randomize

Recently I was facing a problem in generating Random numbers using QTP.

I started with QTP's inbuilt RandomNumber.Value(upperlimit,lowerlimit)

and the result was:

It would generate random numbers for that instance of QTP. But once QTP is restarted it will generate same numbers in same sequence. Example is shown in the images below.

The QTP always starts the Random Number Generation from the same number. To elaborate, QTP's Random Number function gets initialized with the same number(the seed) every time QTP's instance is created.

So for better performance we can use vb's Rnd function with call to Randomize. Call to Randomize initializes the Rnd function with a new seed value every time(this is based on the system time).
If Randomize is not used, Rnd uses the same number as a seed the first time it is called.
Hence it will generate the same value everytime the function is called.


Below are the results of all the cases. The execution 1 and execution 2 are of separate QTP instances.

Using QTP’s RandomNumber.Value(a,b) function.



Using vb’s Rnd function with Randomize.
This will generate random numbers every time!


Using vb’s Rnd function without Randomize.


Wondering what would happen on using Randomize with QTP's RandomNumber.Value(a,b) !!
Here are the results...

For more on Rnd Function follow check this link


For more on Randomize Function follow check this link

Tuesday, January 10, 2012

Can you define Love?

Before you can grow up, you must fall in love three times.



Once, you must fall in love with your best friend, ruining your friendship forever. This will teach you who your true friends are, and the fine line between friendship and more.

Once you must fall in love with someone you believe is perfect. You will learn that no one is perfect, and that you should never be treated as anything less than you deserve.

And once, you must fall in love with someone that is exactly like you. This will teach you about who you are, and who you want to be.

And when you’re through with all that, you learn that the people who care about you the most are the ones that you hurt, and the ones that hurt you are the ones that needed you the most.

But most of all, you learn that love is only a concept and is not something that can be defined, it is different to each and every person on this earth, knowing that everyone wants to be loved.....!!!!! :)

via @Nignesh Patel

Sunday, September 25, 2011

Thursday, September 22, 2011

Jaane kab hum itne bade ho gaye...

Kabhi pehli baar school jaane mai darr lagta tha,
Aaj milte hi dost ban jaate hai...

Kabhi maa-paapa ki baat sachi lagti thi,
Aaj unhi ko har pal jhuth bolte hai...

Pariyon ki kahaani ki jagah aaj kal raat ko phone pe "gf/bf"(replaced "dosto") ki baate sunna zyada acha lagta hai...

Pehle 1st aane ke liye pure saal padhte the,
Aaj paas hone ko taraste hai...

Cartoons ki jagah ab reality shows acche lagte hain...

Kabhi choti si chot lagne pe itna rote the,
Aaj Dil tut jaata hai fir bhi sambhal jaate hain...

Pehle dost bas saath khelne tak yaad rehte the,
Aaj wahi dost jaan se zyada pyaare lagte hain...

Ek din tha jab pal me ladna pal me manana to roz ka kaam tha,
Aaj jo ek baar juda hue to fir gehre rishte tak kho jaate hain...

Sach me zindagi ne bahut kuch sikha diya,
Jaane kab hume itna bada bana diya...

via Dips(SMS)

Thursday, August 11, 2011

Task Killer!!!

To kill processes in Windows


strComputer = "."

strProcessToKill = InputBox("Task Killer!!! ","Enter process name to kill!")

'strProcessToKill="wmplayer.exe"

'strProcessToKill="excel.exe"


Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'")



count = 0

For Each objProcess in colProcess
objProcess.Terminate()
count = count + 1
Next

wscript.echo "Killed " & count & " instances of " & strProcessToKill & "on " & strComputer

Override Windows AutoLock on Computers

Many of us face Autolock on computers. This wscript will keep on executing and will override the Windows Autolock.


'Purpose : Workaround for autolock policy.

'Memory Usage: 6700K(as per Windows Task Manager)

'Steps to Execute: Double click the vbs file everytime you don't want the autolock to rule over.


Option Explicit

Dim wshShell



'Open shell

Set wshShell= CreateObject("WScript.Shell")

Do While true

wshShell.SendKeys "{SCROLLLOCK}" 'SCROLL LOCK is the least used key...!!

wshShell.SendKeys "{SCROLLLOCK}"


WScript.sleep 30000

Loop

'Quit

msgbox "Done..."

WScript.Quit

Solution for ActiveX error in Automation Object Model code

Many of us experiences the AOM fails to create QTP object to launch and invoke tests and getting ActiveX object error popup.



Active X error will happen due to delay in License Checking. It will resolve, If you Follow below steps.


Navigate to Start>Control Panel>System>Advanced Tab>Environment Variables



1. “LSHOST” variable and click on Edit button.

2. Change variable name from “LSHOST” to “LSFORCEHOST”.

3. In variable value edit box instead of name enter IP address of License server.



Do this for both ‘User variables’ & ‘System variables’.

Wednesday, January 26, 2011

Artist's gift to Mr. JRD Tata

This was a gift given to Mr JRD Tata on his birthday by a street artist.


Nobody was able to understand the art.
Unfortunately, only the painting was given to Mr. JRD Tata and the artist had promised to reveal the secret shortly.
However, Mr JRD Tata was no more when the secret was actually revealed.




The secret is revealed below.


When you place a steel rod at the circle in the first pic you saw, you will see the image of Mr JRD Tata as a reflection on the steel rod as seen in the second pic below. Isn't it incredible!!


What was the artist doing on the streets of India????
Location: Tata Museum, Jamshedpur.

Source: Email

Thursday, October 7, 2010

A Tribute To The Hostel!

-Author: Hardik Rami
My first visit to the hostel was like an adventure in the new world.
I went to the E-block and I saw a completely novel environment…loud music was filling the air...people were chattering…TV room was thundering with voices (of course it was a cricket match).
But what I really liked is the liveliness…our hostel has a motto of “All for one…One for all!”
Now I love her...I feel myself at hostel…her rooms and all the residents say one thing that “let yourself live with reality and happiness” no one can feel alone & lonely at hostel…
Now some light on her beloved…
You may feel that hostelites are dull and dumb when you first see them…but appearance is a deception...hostelites are the real talented students of our college…not only academics but also they rock in every field…
As we know most of the toppers are from the hostel…we had GATE AIR 20 last year from hostel...and don’t forget a guy who went to IIM-C from LDCE, again the hostelite...! The SAE BAJA team is mostly comprised of the hostelites…
Our technical and cultural events find their life from the hostel…guys from C-block work for endless nights to make challenging robotics tracks for the Teqnix every year...And we see the most rocking robotic events better and better every time…even LEAF, JagteRaho and Vox Populi are the brain child of the hostel…
We have great sportspersons out there…I know a guy who has played county cricket at England…we have state champions in the table tennis, hand ball and football...not to forget many who had played state cricket…
Art and literature are getting respect & love…so many of the hostelites are awesome at painting, and sketch drawing…someone is writing a novel from his experiences!!! (If you are reading this, let me tell you, I consider you as a hostelite just like me…!) At least 10 languages are spoken in the hostel…
And ya music rocks in every block…music from every genre is popular…you can find Sufi and Rock playing at 3:00 am simultaneously with the cold breeze in the corridors…Nobody can beat them when it’s a matter of fashion…they are the coolest!
All the religions are worshipped…hostelites arranged Ganesha mahotsav and Saraswati puja every year…
To sum it up...we have great legacy and culture with the hostel...she is an integral part of the college…as the hostelites to our life…
These are the people living away from their families…but finding their new life and relatives at the hostel…pure by the hearts…sensitive and optimists…genius and artist…but mostly themselves…the real identity always…
So my all the friends at hostel…you are the guys who care for me selflessly…and same from myself…I will always remember the time I spend with you…I will never forget the sunset, I saw on the terrace, Night talking session at the cricket ground, on Nescafe and at the tank. And also the countless parties…!!!

let me remind u i m a localite...
this note is for them who doesnt know abt the hostel!!!

Sunday, August 29, 2010

M4 - The "Rakhadpati"

Can the Mumbai rain stop 5 LDites to do "Rakhadpati" ??
NO!!

29th Day of August 2010, Sunday
It rained the whole night and even in the morning and it continued the whole day.
But it was 3 in the afternoon and it was time to do some Rakhadpati in Mumbai.
I was a bit reluctant in going out in this rain, but then all my LD mates were ready so we all set out for "Rakhadpati"
Me Raunak and Amit.
Mansarovar - Kurala - Dadar(the meeting spot, Kinnar joins us) - Church Gate

and then to Marine Drive in Taxi. It was raining heavily here and the scenic view from Marine Drive was awesome. We could hardly see the buildings the other side. Best, romantic and awesome place with awesome atmosphere. Was not carrying the camera or else I would have put up the pics. It was real fun to shout in the rain on the edges of wall. The crazy frog tune also drove me crazy. Tea added to the fun. We walked along the Marine Drive Lane towards the Nariman Point and back. Also saw Trident. (missed Bi-dent, Uni-dent and Pepsodent) Now it was time to fill up the bellies. Taxi to Chowpaty and enjoyed almost all the type of chats here. Pavbhaji and Panipuri and we were done. Finished it with a paan. The food was really awesome. Forgot the Ganesh Pavbhaji for a while after having pavbhaji here.
What did you do if you did not have Bhutta(Corn) at Chowpaty!! So Bhutta at Chowpaty in rain and strong winds. Watching the "Queen's Necklace"
The Marine Drive when lit up with street lights in the eve, appears like a Queen's DIAMOND Necklace and hence the name.

Next on the list was a famous bar and restaurant, "LeoPold". Awesome place to hangout. But its too expensive. Now it was getting to late so did not visit Taj. May be next Sunday.
So back to Churchgate.
Churchgate - Dadar - Kurla - Mansarovar.
And ending it with other recognizable 'feature' of LDite. Why to wait in a long queue, if there are Fotcuts(Shortcuts)? The passengers on getting out of the train were rushing to form a queue for rickshaw. "Discipline" as I mentioned in the previous post. We also joined the queue. But then we thought, 'we are LDite!'. Immediately called up a rickshawala and waited for him separately besides the queue. Within 2 minutes he was there to pick us up and we were back to the room quickly. That was the one of the most funniest moment of the day.
So its time now and have a swelling in the knee so got to take some rest.
All for the day. Bye...