Sign in to follow this  
Followers 0
Akarillon

Automatic installation of network path software

13 posts in this topic

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!

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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!

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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!

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.


Challenge accepted!

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

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!

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

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!

Share this post


Link to post
Share on other sites

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!

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