Page 1 of 1

start install process fails with Access denied

Posted: Thu Jun 07, 2018 9:33 am
by yam
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?

Re: start install process fails with Access denied

Posted: Thu Jun 07, 2018 9:48 am
by odklizec
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.

Re: start install process fails with Access denied

Posted: Thu Jun 07, 2018 12:20 pm
by yam
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)?

Re: start install process fails with Access denied

Posted: Thu Jun 07, 2018 12:51 pm
by odklizec
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?

Re: start install process fails with Access denied

Posted: Thu Jun 07, 2018 1:28 pm
by yam
I've changed the file copy to temp folder. Still getting Access Denied error.

Re: start install process fails with Access denied

Posted: Thu Jun 07, 2018 1:38 pm
by odklizec
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";;

Re: start install process fails with Access denied

Posted: Sun Jun 10, 2018 8:33 am
by yam
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.

Re: start install process fails with Access denied

Posted: Sun Jun 10, 2018 11:36 am
by odklizec
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 ;)