command line action doesn't always work.

Ask general questions here.
dmconsulting1
Posts: 83
Joined: Fri Nov 08, 2019 3:23 pm

command line action doesn't always work.

Post by dmconsulting1 » Wed Dec 18, 2019 5:47 pm

I am trying to do a simple clean up step that removes the previous version before installing the new version. All I am doing is opening CMD, issuing the command: "rmdir /s /q .\install "

Sometimes it does, sometimes I get Access Denied on the EXE and 6 .dll files. I can run the command by hand and it works, I am running CMD as admin, I even moved this step to the start of the suite rather the end in case files were in use. All I am trying to do is delete the "install" directory and sub directories so the next run will install a new build in it's place as overwriting causes other issues.

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

Re: command line action doesn't always work.

Post by odklizec » Thu Dec 19, 2019 8:47 am

Hi,

I guess that if it "sometimes" works, you will get the same result also if the same CMD is called manually (just give it few tries)? Access Denied means that the app you trying to uninstall is most probably still in use? So, before issuing uninstall command, you should make sure the uninstalled app is really terminated. The best would be to search for the process name and eventually kill it before calling uninstall?
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

dmconsulting1
Posts: 83
Joined: Fri Nov 08, 2019 3:23 pm

Re: command line action doesn't always work.

Post by dmconsulting1 » Thu Dec 19, 2019 3:20 pm

This is why I moved it from the end of the script to the start.

Currently, the script uninstalls first, so the machine is not running the app and likely hasn't for some time. So it shouldn't be in use, or loaded into memory. I had a minute long post shut down wait, but it still happened. This is why I moved it to first step.

I thought the most reliable way to delete this directory would be from the command line, but this is proving me to be incorrect in that assumption.

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

Re: command line action doesn't always work.

Post by odklizec » Thu Dec 19, 2019 3:32 pm

Hi,

I must have been blind while reading your initial post :) I just noticed that you are trying to use simple rmdir command. What version of Windows do you use? The Access Denied error could be issued also in case the directory was created with different user account than you are using while deleting! What you can try is to run the test (whole Studio) as administrator. Another possibility could be killing explorer.exe process, but it's kind of dirty and risky hack ;)
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

dmconsulting1
Posts: 83
Joined: Fri Nov 08, 2019 3:23 pm

Re: command line action doesn't always work.

Post by dmconsulting1 » Thu Dec 19, 2019 4:10 pm

Maybe do a check for the process (AUT exe) and if running kill it?

dmconsulting1
Posts: 83
Joined: Fri Nov 08, 2019 3:23 pm

Re: command line action doesn't always work.

Post by dmconsulting1 » Thu Dec 19, 2019 4:17 pm

I am running both Ranorex and cmd as Administrator. I also try removing attributes in case that helps (it hasn't).

I added a second line, it worked last time. I am running a new build now. It's hokey, but if it works...
Attachments
uninstallCommand.png
uninstallCommand.png (40.63 KiB) Viewed 141 times

dmconsulting1
Posts: 83
Joined: Fri Nov 08, 2019 3:23 pm

Re: command line action doesn't always work.

Post by dmconsulting1 » Thu Dec 19, 2019 4:58 pm

And now for whatever reason, it works the first time. :lol:

I will keep looking into it, but as long as it does the thing, I am ok.