nikink Posted March 1, 2007 Posted March 1, 2007 Ok, I'm autmating an install of Nvivo 7 which gets pushed out by our network's SMS software. Great idea in principle, but Nvivo 7 is a pain in the butt due to a certain part of it's msi being very poorly implemented. So, my specific problem is this. I have implement MHz's RunAsAdmin function within my script - which reruns the script itself with admin rights. When I log in as the standard User and manually browse to the windows sms cache folder and double click the script.exe everything works perfectly. When I use our network SMS software to run that same exe, it fails... tearing out hair here!!! Note, it is running off local HDD in both occasions, and our SMS software uses the same account to run the exe as the RunAsAdmin function uses to restart the script with admin rights... Any ideas? Pls?
MHz Posted March 1, 2007 Posted March 1, 2007 One issue could be that you are using Run() to restart the script and SMS may continue on to the next install which may foul the restart of your script running the MSI, so perhaps using RunWait() on the restart may help. Also as you mention that SMS is running already as admin so restart is not needed so you could add a check using "If IsAdmin() Then Return" at the start of the function before the restart code so you script continues with current admin permissions. I have a few variations of RunAsSet() restart code so I cannot know for sure of what you are executing. Hope the above helps to give you good direction to solve your issue.
nikink Posted March 1, 2007 Author Posted March 1, 2007 One issue could be that you are using Run() to restart the script and SMS may continue on to the next install which may foul the restart of your script running the MSI, so perhaps using RunWait() on the restart may help. Also as you mention that SMS is running already as admin so restart is not needed so you could add a check using "If IsAdmin() Then Return" at the start of the function before the restart code so you script continues with current admin permissions. I have a few variations of RunAsSet() restart code so I cannot know for sure of what you are executing. Hope the above helps to give you good direction to solve your issue. Nope. Unfortunately for that good idea of yours, SMS is only pushing this one package. It's so frustrating! ; AutoRun "Script.exe" as Admin ; By MHz on AutoIt Forums Func OnAutoItStart() ; Add User name Local $user = 'adminaccount' ; Add Domain name Local $domain = 'NetworkDomain' ; Add Password Local $password = 'AdminPassword' ; ; Check incoming parameters If Not $CMDLINE[0] Then ; No parameters then restart as admin RunAsSet($user, $domain, $password) ;MsgBox(0, "Try running this!", @ComSpec & ' /c "' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') Run('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') RunAsSet() Exit ElseIf $CMDLINE[1] <> '/admin' Then ; Exit script with exit code 1 Exit 1 EndIf EndFunc That's the version I'm using. It's worked well for me in other scripts. And yes, it's odd to the extreme that the SMS installer account isn't enough to install the program, but this Nvivo has a dodgy msi that uses the logged on user's account for a particular function. Note, that's the *logged on user's account*, not the account that's running the install (ie: the sms installer account). Which is why I added this runAsAdmin function to the script - and it works if I log on as the user account, browse to the folder it's hiding in and double click the exe, but does not work when sms tries to run the script. Bizarre. As you can see I tried to add @ComSpec at the beginning of the Run command, but that didn't help. One thing I have noticed though, is that the @AutoItExe path contains a '~' character in one of the folders, whereas the @ScriptFullPath is the exact same path but without that '~' (ie: it's the full path). I wouldn't expect that to make a difference... however a lot things about this install don't make sense (to me) so maybe that's it...?
MHz Posted March 1, 2007 Posted March 1, 2007 This is the changes as I previously advised. If the script inherits admin rights then it does not need RunAsSet() as for the IsAdmin() check. ; AutoRun "Script.exe" as Admin ; By MHz on AutoIt Forums Func OnAutoItStart() ; Add User name Local $user = 'adminaccount' ; Add Domain name Local $domain = 'NetworkDomain' ; Add Password Local $password = 'AdminPassword' ; ; Already an admin If IsAdmin() Then Return ; Check incoming parameters If Not $CMDLINE[0] Then ; No parameters then restart as admin RunAsSet($user, $domain, $password) ;MsgBox(0, "Try running this!", @ComSpec & ' /c "' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') RunAsSet() Exit ElseIf $CMDLINE[1] <> '/admin' Then ; Exit script with exit code 1 Exit 1 EndIf EndFunc You may need to use the logging switch and check the log of the install created with the MSI or use other methods to help identify the cause. If the SMS is using a system level account then perhaps using RunAsSet() may hinder the operation? I would try without RunAsSet() also to eliminate possibilities.
nikink Posted March 1, 2007 Author Posted March 1, 2007 This is the changes as I previously advised. If the script inherits admin rights then it does not need RunAsSet() as for the IsAdmin() check.You may need to use the logging switch and check the log of the install created with the MSI or use other methods to help identify the cause.If the SMS is using a system level account then perhaps using RunAsSet() may hinder the operation? I would try without RunAsSet() also to eliminate possibilities.k ta, I'll give it a try (but won't hold my breath! B-) ).
nikink Posted March 2, 2007 Author Posted March 2, 2007 Ok, when using the modified script above (with the IsAdmin()) the script is run by SMS but the nvivo msi fails with a psapi error. This is the consistant annoying troublesome pain in the ass error that seems to be caused by the msi using logged on user account to run that particular function. Nvivo's official forum response has been the ever so useful "make sure you are logged on as an admin when running the msi.". Sheesh!When running the script *without* the IsAdmin(), and pushed by SMS I get an AutoIt Error.Line 0 (File "C:\Folder\Path\Script.exe"):RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin')Error: Unable to execute the external program.Access is denied.If I just double click on the script.exe as the standard user, it runs and works.*tearing hair out in frustration*B-)Please, someone, gimme a clue!!! B-)
MHz Posted March 2, 2007 Posted March 2, 2007 Try setting a working directory as below. ; AutoRun "Script.exe" as Admin ; By MHz on AutoIt Forums Func OnAutoItStart() ; Add User name Local $user = 'adminaccount' ; Add Domain name Local $domain = 'NetworkDomain' ; Add Password Local $password = 'AdminPassword' ; ; Set a working directory for the script. FileChangeDir(@TempDir) ; Already an admin If IsAdmin() Then Return ; Check incoming parameters If Not $CMDLINE[0] Then ; No parameters then restart as admin RunAsSet($user, $domain, $password) ;MsgBox(0, "Try running this!", @ComSpec & ' /c "' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin') RunWait('"' & @AutoItExe & '" /AutoIt3ExecuteScript "' & @ScriptFullPath & '" /admin', @TempDir) RunAsSet() Exit ElseIf $CMDLINE[1] <> '/admin' Then ; Exit script with exit code 1 Exit 1 EndIf EndFunc The "If Admin() Then Return" line is perhaps an issue so consider testing with that line commented as well.
nikink Posted March 2, 2007 Author Posted March 2, 2007 Mmm. No darned difference... see what I mean about frustrating? I wonder if I had the script copy the entire installation folder to @TempDir, ran the install from there, and then deleted it all, if that would make a difference. In other words, maybe it's the folder path of @AutoItExe being concatenated with a ~ that's causing the problem... ? Downside to that is making sure there's space for the package available, but that would be preferable to not having the package work at all! B-) I appreciate the help you are giving me! Thankyou! B-)
noone Posted March 2, 2007 Posted March 2, 2007 I am having the same problem. I am also tearing what little hair I have left out over this. If anyone can help please let me know also. Thank you.
noone Posted March 2, 2007 Posted March 2, 2007 I have solved my problem. If you run as the system account then the script works. I was trying to install an MSI and that did not want to install under the admin account. But, when I let it install under the system account I had no problem. The only question I have now is WHY? Why will this not install an MSI under the admin account?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now