start install process fails with Access denied

Class library usage, coding and language questions.
yam
Posts: 15
Joined: Thu May 04, 2017 6:37 am

start install process fails with Access denied

Post by yam » Thu Jun 07, 2018 9:33 am

I have a script that copies a setup file to the desktop and runs the install process. The script is truggered from Jenkins.
The problem is that, sometimes, the script fails with Access denied error:
[Error ][Module]: Access to the path 'C:\Users\builder\Desktop\setup.exe' is denied.

I have full administrator rights on the computer and as I mentioned, it does not happen all the times.

my code:
string fullCopyPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + +"\\setup.exe";;
System.IO.File.Copy(fullPath, fullCopyPath, true);

System.Diagnostics.Process installerProcess;
installerProcess = new System.Diagnostics.Process();
installerProcess.StartInfo.FileName = fullCopyPath;
installerProcess.StartInfo.Arguments = "/s /v/qn";
installerProcess.StartInfo.UseShellExecute = false;
installerProcess.Start();

Any idea how can I solve this issue?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: start install process fails with Access denied

Post by odklizec » Thu Jun 07, 2018 9:48 am

Hi,

Is there a reason why do you copy the setup.exe to desktop? Simply copy it to c:\temp or something similar and I guess the problem will go away? ;)

Anyway, are you sure the test is ALWAYS started as administrator? You see, having administrator rights to the computer may be not enough if you do not run the test as administrator. And it would explain random nature of the problem.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yam
Posts: 15
Joined: Thu May 04, 2017 6:37 am

Re: start install process fails with Access denied

Post by yam » Thu Jun 07, 2018 12:20 pm

Actually, there is no special reason for copying the setup file to the desktop. I can copy it to any folder.
Anyway, I'm running the test via Jenkins, to a computer with a administrator rights. Is there a way to run the script with administrator privileges (command line)?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: start install process fails with Access denied

Post by odklizec » Thu Jun 07, 2018 12:51 pm

Well, in this case, I would stick with standard user rights and a user/system-less folder. The thing is, that the app started as administrator, always shows the UAC prompt, which must be confirmed manually. I guess there is no easy/standard way to eliminate the UAC dialog? There may be a registry hack or 3rd party tool for this, but I'm not sure it's worth the problems?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yam
Posts: 15
Joined: Thu May 04, 2017 6:37 am

Re: start install process fails with Access denied

Post by yam » Thu Jun 07, 2018 1:28 pm

I've changed the file copy to temp folder. Still getting Access Denied error.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: start install process fails with Access denied

Post by odklizec » Thu Jun 07, 2018 1:38 pm

At which line exactly it fails?
BTW, I guess this line is just badly copied/pasted (notice the redundant + and ;)...
string fullCopyPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + +"\\setup.exe";;
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

yam
Posts: 15
Joined: Thu May 04, 2017 6:37 am

Re: start install process fails with Access denied

Post by yam » Sun Jun 10, 2018 8:33 am

Ignore the redundend +. In the script there is only one.
Anyway, it seems that the copy file succeeds. File exists. I get the error when using install process.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: start install process fails with Access denied

Post by odklizec » Sun Jun 10, 2018 11:36 am

I see. In this case, check these posts...
https://stackoverflow.com/questions/350 ... pen-folder

https://social.msdn.microsoft.com/Forum ... ess-denied

BTW, is there a reason why you start it via process? Just use Ranorex run app program instead ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration