Jump to content
Sign in to follow this  
TPlanet

RunAs admin but get User's access on network

Recommended Posts

TPlanet

Hi All,

As office 2007 needs to be installed with admin access, I scripted the this on that signs in as local admin account if user is not admin already. Then it connects to Source Server with an hard coded generic user and pswd and then does installation.

Is that possible to use the user Access instead?... I mean by (I don't know how) using user account and pswd to do net use whitout prompting the user or doing a link from the admin session to user one?

The user permissions on will network will define if Standard or Pro version will be installed.

If $CmdLine[0]=1 Then ;~ check if relaunched with server as parameter
    $ServerW=$CmdLine[1];~ and set it as variable $ServeurW
Else
    $ServerW=(EnvGet("SERVER"))  
EndIf

;~ if user not admin, copy this program to d: then relaunch with server as parameter
If Not IsAdmin() Then
    RunAsSet("Administrator",@ComputerName,"*******") 
        FileCopy(@AutoItExe, "d:\TempInst\",8)
        Runwait("d:\TempInst\" & @ScriptName & " " & $ServerW, "d:\TempInst\")
        DirRemove("d:\TempInst\",1)
    RunAsSet()
    Exit
EndIf

;~ Now we are admin let connect to the source
$CheminApp=("APP\Microsoft\MsOffice2007\")   
$Source=("\\" & $ServerW  & "\APP\" & $CheminApp)   

If Not FileExists($Source) Then  ;~     Administrator will not see source server, so we have to authentificate
    Runwait("net use " & $Source & " /USER:networkuser password")
EndIf

;~  **************  let's do install ********************
Runwait($Source & "setup.exe /adminfile " & $Source & "Profils\" & ".msp")
Exit

Thanks,

Share this post


Link to post
Share on other sites
Jos

I have always used the User credentials to copy the installer file(s) the to local harddisk and then running the installer with the Local Admin credentials.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TPlanet

I have always used the User credentials to copy the installer file(s) the to local harddisk and then running the installer with the Local Admin credentials.

Jos

I usually use to do so too. But this one will copy +-750Mb on temp folder. Then office setup will copy the files elsewhere on the c:\application data\... then do the install...

Installation procedure will be 35% slower... We can live with that, but if another solution exists, it would be great.

Edited by TPlanet

Share this post


Link to post
Share on other sites
Jos

I usually use to do so too. But this one will copy +-750Mb on temp folder then office install will copy it elsewhere on the c:\application data\... then do the install...

Install will be 30% slower... We can live with that, but if another solution exists it would be great.

Just wondering:Are you sure about that?

I would think starting the installer will still have to "download" it into Memory/Tempfiles which normally only slows things down doing it over a LAN.

So I am just curious now if you tried this and if it indeed was faster doing it that way.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TPlanet

Just wondering:Are you sure about that?

I would think starting the installer will still have to "download" it into Memory/Tempfiles which normally only slows things down doing it over a LAN.

So I am just curious now if you tried this and if it indeed was faster doing it that way.

Jos

Just compared... 11 minutes with net use and 14 minutes by copying on temp folder before.

Share this post


Link to post
Share on other sites
Jos

Just compared... 11 minutes with net use and 14 minutes by copying on temp folder before.

Ok.. well what you could try is to restart your script with the Administrator credentials and then do the Net Use, whch should make the mapped drive available under the elivated rights.

Something like this:

AutoItSetOption("RunErrorsFatal", 0) 
AutoItSetOption("TrayIconHide", 1) 
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "Secret"
$RUN = 0      ; run indicator 
; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"') 
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode")
   Exit
EndIf
; commands go here that require Administrator rights

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×