Why I am not able to save notepad in UFT?

216 Views Asked by At
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.

0

There are 0 best solutions below