Just nu i M3-nätverket
Gå till innehåll

Ta bort adminrättigheter för en .bat fil


Benny C

Rekommendera Poster

Jag skrev denna text på ett annat forum och känner att jag inte orkar skriva om den på svenska 00:15 på natten. Så här kommer den copy pastad på Engelska.

Programmerar .bat filer för ett verktyg till jobbet.

 

I'm having some problems with a script i'm making. Here is a short background. At my work (a computer store) we do alot of installations for the customers. Until now we have done most of the installations manually wich have been a pain in the ass. So I started to write a script. The script contains alot of tools for our daily work and it has a total of 20 something batch files for different purposes. So the main bat file is called start.bat and I run that with admin privileges (thru a shortcut). The admin rights is nessecery for the whole script to work properly. What I´ve noticed is that the admin rights seem to be inherited to other bat files that you use the call or start command on. Here comes the problem. One of the bat files downloads the spotify installer, starts the installer and should install the program. BUT... spotify installer does not allow you to run it with admin rights. It just pops up a messagebox that says something like "Run this program as a standard user, not as an administrator". 

I find this very strange. Is there a work around for this? I have not found anything when I googled if there is a command for temporarily removing the inherited admin rights for a bat file. 

If I run the spotify bat file directly without starting the elevated start.bat file first, it works perfectly. But f I run it thru the main file (start.bat) it won´t work.

Anyone who sits on a solution for this?

 

The, not so good, solution I´ve managed to create so far is this:
Starting start.bat
Automatically copying spotify.bat to autostart
Automatically restarting computer with shutdown.exe -r -t 0
spotify.bat runs thru autostart, downloads spotify and installs the program. It then deletes the downloaded installation file and the .bat in autostart and restarts the start.bat again so the user can continue the installation.

Is there another, more convinient way so you dont need to restart the computer?

Länk till kommentar
Dela på andra webbplatser

Hm.. kan man starta main som vanlig användare, anropa start1 som fixar spotify, sedan anropa start2 som administratör och där start2 då utför resten?

 

Funkar i Linuxmiljö där jag som vanlig användare startar ett skript som innehåller rader med admin-rättigheter + kommando att utföra.

Länk till kommentar
Dela på andra webbplatser

3 minuter sedan, skrev Cluster:

Antar att du bör starta den andra skriptfilen med runas, psexec (ej inbyggt) el. dyl.

 

Jag har kikat lite på runas, men tror inte det gör någon skillnad iom att rätt användare redan kör scriptet. Jag har aldrig använt runaskommandot, men kan prova experimentera lite med det.

 

tycker det är märkligt att Spotify valt att spärra admin, av alla rättigheter, från att installera deras program.

Länk till kommentar
Dela på andra webbplatser

1 timme sedan, skrev Mikael63:

Hm.. kan man starta main som vanlig användare, anropa start1 som fixar spotify, sedan anropa start2 som administratör och där start2 då utför resten?

 

Funkar i Linuxmiljö där jag som vanlig användare startar ett skript som innehåller rader med admin-rättigheter + kommando att utföra.

 

Tyvärr kommer inte det att fungera då start.bat är uppbyggd på ett interaktivt sätt där användaren själv får välja genom en meny vad som ska utföras. Därmed vet jag inte i förväg om användaren vill installera Spotify eller utföra något annat i start.bat filen. Tanken var dock god, men jag måste köra call eller start på spotify.bat filen efter användaren tryckt ett visst val i start.bat filen.

Länk till kommentar
Dela på andra webbplatser

Arkiverat

Det här ämnet är nu arkiverat och är stängt för ytterligare svar.

×
×
  • Skapa nytt...