2

After installing QGIS (that from the 2.14 version has pip installed by default) I want to automatically install some pip packages within a bat file.

One method to do that is writing a file.txt with all the needed packages, open the OSGEO Shell as admin, cd in the directory of the file.txt and launch python -m pip -r file.txt

How do I make a bat file that automatically runs the Shell ad admin without asking for the password (that is the same behavior of right click and run as administrator)?

2
  • Is this OSGeo Shell specific? Otherwise I think stackoverflow might be more appropriate – underdark Sep 5 '16 at 16:12
  • actually I'd like to do it with the OSGeo Shell yes.. Should I move the question anyway? – matteo Sep 5 '16 at 16:31
1

If the only problem is running a program with administrator privileges, then yes you can do it. There are many guides on the web, on "how-to run shortcuts with admin rights", and each of those guides have 1 thing in common. You enter the password once, and when the shortcut is ran again, the password prompt shouldn't appear. I used the guide found here.

When you create a new shortcut, a new prompt should appear, which will ask for the user-info/application path:

runas /user:computer_name\Administrator /savecred “C:\your_script_path\script.bat”

Now the /savecred should save the password, making the next shortcut run password free while being ran with administrator privileges.

I assumed that you are using a windows OS. If you are on a Unix based OS, I will reform my answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.