Sign in to follow this  
Followers 0
Zerby

RunAs problem

9 posts in this topic

#1 ·  Posted (edited)

Hello.

Okay, I'm really close in losing my cool over this issue, because I simply can't understand what's the problem. I think it might be something small, so after getting the answer I'll really look stupid, but at this point I'm ready to take that risk.

I work as in a school environment, and I need to install the newest Java update to all of the computers in the school. Doing this manually is a huge pain in the ass, because many of the computers are in use during the day etc. etc.

I've worked with AutoIt before, so I'm not a complite newbie at it, but not an expert either. I decided to make a script that when the user logs on, it messages the user with MsgBox, saying that Java will now be installed, then mounts a R:\ network drive (that has the java msi on it) and installs Java with admin rights.

So, here's my script:

#include<Misc.au3>
HotKeySet("{ESC}", "loppu")

$loytyy=0

DriveMapDel("r:")


$x = 0
While $x < 50
    if FileExists("r:") =0 then
        ExitLoop
    EndIf
    $x = $x + 1
    sleep(100)
WEnd


DriveMapAdd("r:", "\\servername\subfolder\java6", 0, "username", "password")
asenna()
$virhe=""
if @error>0 then
    Select
        Case @error = 1 and @extended = 1219
            $virhe= @crlf &  "Olet kytkeytyneenä samaan kohteeseen toisella tunnuksella"
    EndSelect
    msgbox(0,"",@error & " - " & @extended & $virhe)
endif

;===========================================================
Func loppu()
    exit
endfunc
;===========================================================




Func asenna()

RunAsWait("admin", @ComputerName, "password", 1, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

EndFunc

DriveMapDel("r:")

It mounts the drive just fine, but after that, it just closes. I've tried seperate script to run just the "RunAsWait" part, when the R:\ drive was mounted, but it still does nothing. Starts the script, few seconds pass and the script exits.

EDIT: driver --> drive

Edited by Zerby

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello.

Okay, I'm really close in losing my cool over this issue, because I simply can't understand what's the problem. I think it might be something small, so after getting the answer I'll really look stupid, but at this point I'm ready to take that risk.

I work as in a school environment, and I need to install the newest Java update to all of the computers in the school. Doing this manually is a huge pain in the ass, because many of the computers are in use during the day etc. etc.

I've worked with AutoIt before, so I'm not a complite newbie at it, but not an expert either. I decided to make a script that when the user logs on, it messages the user with MsgBox, saying that Java will now be installed, then mounts a R:\ network drive (that has the java msi on it) and installs Java with admin rights.

So, here's my script:

#include<Misc.au3>
HotKeySet("{ESC}", "loppu")

$loytyy=0

DriveMapDel("r:")


$x = 0
While $x < 50
    if FileExists("r:") =0 then
        ExitLoop
    EndIf
    $x = $x + 1
    sleep(100)
WEnd


DriveMapAdd("r:", "\\servername\subfolder\java6", 0, "username", "password")
asenna()
$virhe=""
if @error>0 then
    Select
        Case @error = 1 and @extended = 1219
            $virhe= @crlf &  "Olet kytkeytyneenä samaan kohteeseen toisella tunnuksella"
    EndSelect
    msgbox(0,"",@error & " - " & @extended & $virhe)
endif

;===========================================================
Func loppu()
    exit
endfunc
;===========================================================




Func asenna()

RunAsWait("admin", @ComputerName, "password", 1, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

EndFunc

DriveMapDel("r:")

It mounts the driver just fine, but after that, it just closes. I've tried seperate script to run just the "RunAsWait" part, when the R:\ driver was mounted, but it still does nothing. Starts the script, few seconds pass and the script exits.

Hi,

just a guess: Have you tried another logonflag? If not, I would try

RunAsWait("admin", @ComputerName, "password", 4, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

Hi,

just a guess: Have you tried another logonflag? If not, I would try

RunAsWait("admin", @ComputerName, "password", 4, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

;-))

Stefan

Didn't work, I also tried with 3, 2 and 0.

Just to note, it does run the java installer if I place it in C:\ driver (local), and change the script to run it from there. Just to test if my syntax was wrong or something.

I also tried:

Run("MSIEXEC.EXE /I R:\java16017c.msi")

And it works. So, what's wrong with my RunAsWait function :)

Share this post


Link to post
Share on other sites

Didn't work, I also tried with 3, 2 and 0.

Just to note, it does run the java installer if I place it in C:\ driver (local), and change the script to run it from there. Just to test if my syntax was wrong or something.

I also tried:

Run("MSIEXEC.EXE /I R:\java16017c.msi")

And it works. So, what's wrong with my RunAsWait function :)

Hi,

1) Which account you use, running the command (local administrator? or another)

I also tried:

Run("MSIEXEC.EXE /I R:\java16017c.msi")
2) You may proof the following minimum settings on share and directory:

Share settings. Default is reading for everyone

NTFS settings on directory java6 -> you need read and execute for everyone, you might need change for extracting files e.g

;-))

Stefan

Share this post


Link to post
Share on other sites

Hi,

1) Which account you use, running the command (local administrator? or another)

While testing, I've used local account (hence the @ComputerName as domain). I've also tried with network admin account, changing the @ComputerName to network domain name. Still didn't work.

2) You may proof the following minimum settings on share and directory:

Share settings. Default is reading for everyone

NTFS settings on directory java6 -> you need read and execute for everyone, you might need change for extracting files e.g

;-))

Stefan

Yea, I could try that, but I'd like that to be the last resort :) I could manually update all the student computers (The ones in computer classes), so few clever students wouldn't figure out the loophole and execute their own programs from there (highly unlikely, but you never know).

Share this post


Link to post
Share on other sites

While testing, I've used local account (hence the @ComputerName as domain). I've also tried with network admin account, changing the @ComputerName to network domain name. Still didn't work.

Yea, I could try that, but I'd like that to be the last resort :) I could manually update all the student computers (The ones in computer classes), so few clever students wouldn't figure out the loophole and execute their own programs from there (highly unlikely, but you never know).

Hi,

just for not misunderstanding you:

1) You logon locally as a local administrator

2) You run your script, with changed line to Run function:

Run("MSIEXEC.EXE /I R:\java16017c.msi")

And this is working.

3) You logon locally as a user

4) You run your script, with changed line to RunAsWait function:

RunAsWait("admin", @ComputerName, "password", 1, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

This is not working.

So 2 suggestions:

1) What happens if you change the Run command to RunWait

2) What happens if you change the RunAsWait command to RunAs

3) The service Secondary Logon is running?

3) Reproduce without AutoIT: Logon as user. Map networkdrive. Start -> Programs -> Acessoires -> Shift and right Click on Command Prompt -> RunAs <local administrator>. In command box goto drive R:. Run command MSIEXEC.EXE /I r:\java16017c.msi in DOS BOX

;-))

Stefan

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Hi,

just for not misunderstanding you:

1) You logon locally as a local administrator

2) You run your script, with changed line to Run function:

Run("MSIEXEC.EXE /I R:\java16017c.msi")

And this is working.

3) You logon locally as a user

4) You run your script, with changed line to RunAsWait function:

RunAsWait("admin", @ComputerName, "password", 1, "MSIEXEC.EXE /I r:\java16017c.msi", "r:\")

This is not working.

So 2 suggestions:

1) What happens if you change the Run command to RunWait

2) What happens if you change the RunAsWait command to RunAs

3) The service Secondary Logon is running?

3) Reproduce without AutoIT: Logon as user. Map networkdrive. Start -> Programs -> Acessoires -> Shift and right Click on Command Prompt -> RunAs <local administrator>. In command box goto drive R:. Run command MSIEXEC.EXE /I r:\java16017c.msi in DOS BOX

;-))

Stefan

Sorry for a late answer, my workday ended and I didn't have the script with me at home :)

So, answer for your first chapter: Yes, it works when I'm connected with admin rights locally (Well, I am logged in as network admin in this computer, but I guess that's not what matters here) and run it with Run function.

But, when I add the script as logon script to my test user (with normal privileges) and change the function to RunAsWait, it won't work. It will go to the correct asenna() function, but just won't start the install, and just exits the script.

To your suggestions:

1) With admin rights and running the script locally, with RunWait instead of Run, it works just the same as with Run.

2) Same, still just seems to complitely skip the RunAs part ;)

3) ?

4) I tried to run it as a normal user in cmd, it started it but immediatly said something about not being able to run the installer because it either doesn't exists or isn't Windows installer package or something that sort... It does open it if I just click it open though (saying you need admin rights to run if after a while though) so I don't know what's wrong..

Well anyway, I guess I'll just give this one up. It would've been really nice to get this working, not only to install this Java update but for future use too. I guess it's because of the settings in this environment that's causing the problem, sadly I've only been working here for couple months so I'm not that familiar with it all yet.

Well, guess I'll go and install them all manually B)

EDIT: Well okay I can't give up yet! I tried it once more with just "RunWait" as a normal user, and it started the install and ofcourse said that you need admin rights. So I'm missing SOMETHING with that RunAs command, anyone have ANY idea what's wrong?? It doesn't even try to run it with that command.

Edited by Zerby

Share this post


Link to post
Share on other sites

Can't edit my post so I'll have to post a new one:

It doesn't even seem to check if the user and password are correct, because if I put some random info there (as a username and password) it still functions exactly the same.

Share this post


Link to post
Share on other sites

Can't edit my post so I'll have to post a new one:

It doesn't even seem to check if the user and password are correct, because if I put some random info there (as a username and password) it still functions exactly the same.

Hi,

it seems you haven't try the part without Autoit. Start the cmd as local admin and then start the msi:

Reproduce without AutoIT: Logon as user. Map networkdrive. Start -> Programs -> Acessoires -> Shift and right Click on Command Prompt -> RunAs <local administrator>. In command box goto drive R:. Run command: MSIEXEC.EXE /I r:\java16017c.msi in DOS BOX

You find the Secondary logon ( it might be Run As Service ) under services of the computer (Start -> run -> services.msc). It must run, to allow starting processes with other credentials.

;-))

Stefan

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  
Followers 0