0
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objTFile=objFSO.CreateTextFile("C:\test\Test.txt")          
SystemUtil.Run "C:\test\Test.txt"       
Window("Notepad").Activate
Window("Notepad").Type micCtrlDwn + "v" + micCtrlUp
wait 3
Window("Notepad").Type micCtrlDwn + "s" + micCtrlUp
systemUtil.CloseProcessByName "C:\test\Test.txt"
Set objfileToread=objFSO.OpenTextFile("C:\test\Test.txt",1)
fileText=objfileToread.ReadAll()

.................................................................................................
I am getting an error that:

This process is accessed by another service at "Window("Notepad").Type micCtrlDwn + "s" + micCtrlUp" step. But when I run the following code it gets executed successfully: ................................................................................................

Set objFSO=CreateObject("Scripting.FileSystemObject")
SystemUtil.Run "C:\test\Test.txt"       
Window("Notepad").Activate
Window("Notepad").Type micCtrlDwn + "v" + micCtrlUp
wait 3
Window("Notepad").Type micCtrlDwn + "s" + micCtrlUp
systemUtil.CloseProcessByName "C:\test\Test.txt"
Set objfileToread=objFSO.OpenTextFile("C:\test\Test.txt",1)
fileText=objfileToread.ReadAll()

...............................................................................................
All the scripting is in UFT.

Wasif
  • 14,755
  • 3
  • 14
  • 34
  • So what is your question? – Wasif Dec 24 '19 at 06:11
  • You are creating the text file and at the same time opening it. So it shows you the error. – Wasif Dec 24 '19 at 06:13
  • I'm going to make some assumptions here, since I don't have HP UTF. First, you are creating a text file and assigning it to variable objTFile that is never used, and whose file handle is never closed. I would suggest writing some content to the file, then closing the file handle before opening it with the SystemUtil.Run method. Second, it looks like you're completely relying on .txt file type handling, and assuming that Notepad will be opening it. I would suggest calling SystemUtil.Run "notepad C:\test\Test.xt" to ensure Notepad is the process opening the .txt file. Hope this info helps. – leeharvey1 Jan 12 '20 at 15:46

0 Answers0