Sign in to follow this  
Followers 0
TexasJohn

Check and Map Drives

16 posts in this topic

I am Very new to AutoIT (two days) and I need to create a procedure that will check to see if a drive/folder (AD Home Directory) and the general share drive is mapped and If not, map the drives for the user.

Share this post


Link to post
Share on other sites



How do I pass the users AD user name to the script?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

The user and logon domain running the script is available as a macro; see help file:

MsgBox(64, "Domain\User", "Domain:  " & @LogonDomain & "\" & @UserName & @CRLF & _
"DNS Domain:  " & @LogonDnsDomain)

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What is the variable for HomeDirectory, DriveMapAdd("X:", @HomePath) is not working.

Share this post


Link to post
Share on other sites

Display the value you get with something like this:

MsgBox(64, "Home sweet home...", "@HomeDrive:  " & @HomeDrive & @CRLF & _
"@HomePath:  " & @HomePath & @CRLF & _
"@HomeShare:  " & @HomeShare)

Now compare those results with what you would use to manually map it on a command line with NET USE.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

OK, I's still not getting it. I need to pass the AD home directory, not the home directory on the local machine. I can't find anything in the help that talks to that.

Share this post


Link to post
Share on other sites

So that means you are running the script logged on as a local user? Is the computer a member of the domain? Are you going to input the domain via an input box, ini file entry, registry key? You are being very stingy with information on what you want to do.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

What we have is some Police Toughbooks that the offices log into and then VPN in to the network. At that point They have missed the login group police that maps their home directory.

Share this post


Link to post
Share on other sites

Yes: thee user logs in via cached credentials locally

Yes: the computers are members of the domain.

Everyone is part of the same domain, I don't want them to have to enter anything.

If I were out there with them, I would just open explorer - tools - map drive and browse to there home directory and map it. But these are cops and that seems to be too much trouble.

Share this post


Link to post
Share on other sites

Below is what I am trying to do

===============================================================

@echo off

IF EXIST X:\ GOTO DELETE_X

:DELETE_X

NET USE X: /DELETE

GOTO MAP_HOME

IF NOT EXIST X:\NUL GOTO MAP_HOME

:MAP_HOME

NET use x: \\srvvmfs1\userhome\%username%

ECHO DRIVE X: IS READY

GOTO END

:END

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Below is what I am trying to do

===============================================================

@echo off

IF EXIST X:\ GOTO DELETE_X

:DELETE_X

NET USE X: /DELETE

GOTO MAP_HOME

IF NOT EXIST X:\NUL GOTO MAP_HOME

:MAP_HOME

NET use x: \\srvvmfs1\userhome\%username%

ECHO DRIVE X: IS READY

GOTO END

:END

Run("cmd")
                    WinWaitActive("cmd")
                    Send("net use x: \\computer ip\folder")
                    Sleep(200)
                    Send("{ENTER}")
                    Sleep(1500)
                    Send("username")
                    Sleep(500)
                    Send("{ENTER}")
                    Sleep(1000)
                    Send("password")
                    Sleep(1500)
                    Send("{ENTER}")
                    Sleep(300)
                    Send("exit")
                    Sleep(500)
                    Send("{ENTER}")
                    WinWaitClose("cmd")
                    Sleep(300)
                    MsgBox(0, "connected", "Connected Succesfully")



                    Run("cmd")
                    Sleep(300)
                    Send("net use x: /delete")
                    Sleep(300)
                    Send("{ENTER}")
                    Sleep(300)
                    Send("exit")
                    Sleep(300)
                    Send("{ENTER}")
                    Sleep(200)
                    WinWaitClose("cmd")
                    Sleep(500)
                    MsgBox(0, "Disconnected", "Disconnected Succesfully")

here's something i used before. its basic as hell, but it worked fine.

Edited by royalmarine

Share this post


Link to post
Share on other sites

If I understand the snipet correctly, All I will really need is

Run("cmd")

WinWaitActive("cmd")

Send("net use x: \\srvvmfs1\userhome\%username%")

Sleep(200)

Send("{ENTER}")

Each user will have already entered his AD password and user name to get into his workstation using cashed AD credentials in has workstation.

Share this post


Link to post
Share on other sites

The below gets me the DOS window but nothing after that. What Im I missing here? If I take out the WinWaitActive("cmd"), it seems to work some of the time.

Run("cmd")

WinWaitActive("cmd")

Sleep(300)

Send("net use x: /delete")

Sleep(300)

Send("{ENTER}")

sleep(300)

Send("net use x: \\SRVVMFS1\userhome\%username%")

Sleep(200)

Send("{ENTER}")

MsgBox(0, "connected", "Done!")

Share this post


Link to post
Share on other sites

If the logged in user's credentials are sufficient to access the share, then all you should need is:

$sDrvType = DriveGetType("X:")
If Not @error Then
    $sDrvPath = DriveMapGet("X:")
    MsgBox(64, "X: Mapped", "X: is already mapped as type = " & $sDrvType & "; path = " & $sDrvPath)
Else
    If DriveMapAdd("X:", $sMapPath, 8) Then
        MsgBox(64, "X: Mapped", "Successfully mapped X: to " & $sMapPath)
    Else
        MsgBox(16, "Error", "Failed to map X: drive; @error = " & @error)
    EndIf
EndIf

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

We initially had a problem with a missing global veritable $sMapPath. I guessed at what is should be but I'm obviously wrong. I get the following error "Failed to map X drive: @error =1

$s

$sDrvType = DriveGetType("X:") $sMapPath = "\\srvvmfs1\userhome\username" If Not @error Then     $sDrvPath = DriveMapGet("X:")     MsgBox(64, "X: Mapped", "X: is already mapped as type = " & $sDrvType & "; path = " & $sDrvPath) Else     If DriveMapAdd("X:", $sMapPath, 8) Then         MsgBox(64, "X: Mapped", "Successfully mapped X: to " & $sMapPath)     Else         MsgBox(16, "Error", "Failed to map X: drive; @error = " & @error)     EndIf EndIf

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