Akarillon Posted May 26, 2014 Posted May 26, 2014 Hello everyone. I have been a while away from AutoIt and have forgotten alot. I am trying to make a script that will install software from a network location. My problem starts when I am trying to make the script more smooth by passing the "You need administrative rights to run this program". I added the "RequireAdmin" at the start of the script so that it wouldn't pop up as the software launched, but now the script doesn't even find the software. What am I not seeing? #include <Process.au3> #RequireAdmin $short = FileGetShortName("\\domain\...$\...\.. .. ..\...\SetupClient.exe") $result = FileExists($short) If $result Then MsgBox(0, "", "File exists") _RunDos('"\\domain\...$\...\.. .. ..\...\SetupClient.exe"') WinWait("SetupClient") MsgBox(0, "", "test") Else MsgBox(0, "", "File doesn't exist") EndIf Challenge accepted!
water Posted May 26, 2014 Posted May 26, 2014 Here the network share is assigned by the logon script to the user. Admins most of the time do not get the same shares. So I think you need to access the network share in your script when running as admin. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 The network share should be the same for admins and users as I am using the direct path "servernamefolder$.....". Anyways it should work without these changes as I am running the script with my admin account and not a user. Challenge accepted!
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 I actually found that the script wont run at all when I add the #RequireAdmin. No matter where I put a MsgBox() it won't show anything before the script exits. Got any advice? Challenge accepted!
water Posted May 26, 2014 Posted May 26, 2014 Do you get the UAC prompt? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 Yes, the UAC asks for admin rights, but when I enter my credentials the script stops. It doesn't give any error messages, and tells me it ran smoothly. >Exit code: 0 Time: 6.823 Challenge accepted!
MHz Posted May 26, 2014 Posted May 26, 2014 I doubt FileGetShortName will work as expected over a network. With testing, I find that as soon as the filename is larger then a 8.3 filename, then an unusual filename is returned. Perhaps you can try this and see if the same happens to you $short = FileGetShortName("\\domain\...$\...\.. .. ..\...\SetupClient.exe") $result = FileExists($short) MsgBox(0, $result, $short) I tried 123456789.exe and get returned 11E83H~I.EXE. Yes, that is an I (eye) rather then a usual 1 (one) in the filename.
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 It does work if I remove the #RequireAdmin in the script. The FileGetShortName shouldn't be a problem but checked nontheless. I do get a shortened pathname which is that I want(because the path contains spaces). Heres a picture of the parts that gets shortened. I manage to run the software when I remove the #RequireAdmin from the script, but then the UAC prompts only when the script gets to the installation bit. This creates several problems as I want to install several pieces of software in one go. Challenge accepted!
MHz Posted May 26, 2014 Posted May 26, 2014 I had no problem with your code until the filename went above 8.3. The Network drive is not a Windows OS that I tested on which is probably why FileGetShortName failed. Does this work for you. #RequireAdmin Run('"\\domain\...$\...\.. .. ..\...\SetupClient.exe"') WinWait("SetupClient") MsgBox(0, "", "test")
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 I tried using the Run() command, but as it didn't work I ended up using _RunDOS() I tried again, and Run() simply wont run the software. The UAC prompts, but nothing happens. Could there be a problem with Run() and network paths? Challenge accepted!
MHz Posted May 26, 2014 Posted May 26, 2014 It could be a security setting blocking it. I am testing on Windows 7 Pro. Try ShellExecute as it might read the files manifest better. I used runas as a parameter with it else I would get a security prompt before execution. #RequireAdmin ShellExecute('"\\domain\...$\...\.. .. ..\...\SetupClient.exe"', '', @TempDir, 'runas') ; or If FileChangeDir('\\domain\...$\...\.. .. ..\...') Then Run('SetupClient.exe', @TempDir) Else MsgBox(0x40030, @ScriptName, 'Could not change working directory') EndIf FileChangeDir usually works over a network so you could try that to make the path a little simpler. Also test with a working dir such as @TempDir or @SystemDir.
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 ShellExecute has the same problems as _RunDos() and Run(). It won't run the script if I have the #RequireAdmin in my script. FileChangeDir didn't do anything(with or without #RequireAdmin). Challenge accepted!
Akarillon Posted May 26, 2014 Author Posted May 26, 2014 I think I found the solution. For some reason, my domain admin user couldn't run the script, but my personal user could run it smoothly. Sorry for not understanding Water. Challenge accepted!
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