Jump to content

RunAs Administrator/Mapping Drives


LanhamA
 Share

Recommended Posts

Good morning,

I'm a long time lurker here, and a first time poster. I have been using AutoIT in an educational environment with good success for the most part. As it stands, my school district limits rights that students have to workstations and we lock down machines pretty tight, for obvious reasons. We have a few applications that require elevated priveleges and that's where AutoIT comes in.

I was recently presented with a challenge that I'm hoping one of the more knowledgeable posters here can help me with. When a student logs in, we map his or her personalized user folder to a network drive through AD. Unfortunately, when AutoIT launches an executable as an admin those drives aren't pulling over. Do you have any suggestions as to what I could do to accomplish this? They are wanting to launch the executable with elevated priveleges and they are also wanting to be able to save files from that program to their network drive.

If this is not possible, I completely understand. Thanks for any assistance that you may be able to provide.

A. Lanham

Link to comment
Share on other sites

You'd need to remap the drives when you run the script, or access them directly using a UNC path. Get the current user's name to figure out which folder needs to be accessed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You'd need to remap the drives when you run the script, or access them directly using a UNC path. Get the current user's name to figure out which folder needs to be accessed.

 

Can a variable be used for the username, such as the user that is logged into the computer since this will be setup for multiple users? For example, our users map their drives to servernameapps%username%

Also, would you be able to provide an example?

Thanks,

A. Lanham

Link to comment
Share on other sites

@UserName will grab the current user's log in name. You can assign that to a variable if you need to. You might even be able to grab their shared drive using the environment variable HOMESHARE if it exists on your systems. (hint: (EnvGet("homeshare"))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@UserName will grab the current user's log in name. You can assign that to a variable if you need to. You might even be able to grab their shared drive using the environment variable HOMESHARE if it exists on your systems. (hint: (EnvGet("homeshare"))

I'll give that a shot and let you know how it works.

Link to comment
Share on other sites

Good morning,

I'm a long time lurker here, and a first time poster. I have been using AutoIT in an educational environment with good success for the most part. As it stands, my school district limits rights that students have to workstations and we lock down machines pretty tight, for obvious reasons. We have a few applications that require elevated priveleges and that's where AutoIT comes in.

I was recently presented with a challenge that I'm hoping one of the more knowledgeable posters here can help me with. When a student logs in, we map his or her personalized user folder to a network drive through AD. Unfortunately, when AutoIT launches an executable as an admin those drives aren't pulling over. Do you have any suggestions as to what I could do to accomplish this? They are wanting to launch the executable with elevated priveleges and they are also wanting to be able to save files from that program to their network drive.

If this is not possible, I completely understand. Thanks for any assistance that you may be able to provide.

A. Lanham

 

RunAs_Administrator.zip

Must compile the RAs_Adm.au3 With Options (AutoIt3Wrapper)

Marking Required Privileges Using an Application Manifest

http://msdn.microsoft.com/en-us/magazine/cc163486.aspx#S8

RunAs_Administrator

RAs_Adm.au3

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_File_Add=ManiFest.txt,24,1,0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
if Not (@Compiled) Then Exit(MsgBox(0,"Err","Must compile the RAs_Adm.au3 With Options (AutoIt3Wrapper)"))
MsgBox(0,"RunAs Administrator","Ok")

 

ManiFest.txt

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false">
        </requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="*" publicKeyToken="6595b64144ccf1df"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>

صرح السماء كان هنا

 

Link to comment
Share on other sites

What OS are you using?

"Programs may be unable to access some network locations after you turn on User Account Control in Windows Vista or newer operating systems"

http://support.microsoft.com/kb/937624/en-us

 

We're using Windows 7 with UAC turned off. I'm trying to get the drives mapped either as the user or as the domain admin account running the file, that way once the file is launched the student can save files to the mapped drive.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...