Jump to content
Sign in to follow this  
Akarillon

Automatic installation of network path software

Recommended Posts

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

Share this post


Link to post
Share on other sites

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 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Do you get the UAC prompt?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.
30ax5if.png

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.

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

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.

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  

×
×
  • Create New...