VirtMcPolygon Posted September 2, 2014 Posted September 2, 2014 Hi folks, I've only just become aware of AutoIT and the power of its scripting so please be gentle with me. I have a situation where some client machines which are connected to a different companies corporate domain than our own, need access to data on one of our file servers. Local usernames have been setup for security passthru and this all works as they currently use batch files with the net use commmands to map the drives. I would like to do something a little more eligant if possible and it seems AutoIT is the way forward for this and so much more. So far I am using the following script compiled as an .exe and when executed it prompts a windows dialogue box to Joe Bloggs for the his local account password that is setup on the "servername" and then maps the drives. DriveMapDel("H:") DriveMapDel("S:") DriveMapAdd("H:", "\\servername\Shared", 8, "servername\joe.bloggs") DriveMapAdd("S:", "\\servername\Home", 8, "servername\joe.bloggs") Seen as we have quite a few users accessing the data and a high staff turnover, I'd like to create an easier option to lighten the workload requests so essentially I would like the same windows prompt but this time for the username as well as the passwords to be entered and the "servername" to be predefined as the server validating the account information. I've tried this but without any luck. DriveMapDel("H:") DriveMapDel("S:") DriveMapAdd("H:", "\\servername\Shared", 8, "servername\", & $user, $passwd) DriveMapAdd("S:", "\\servername\Home", 8, "servername\", & $user, $passwd) Any help would be much appreciated. Thanks
computergroove Posted September 2, 2014 Posted September 2, 2014 #include <MagBoxConstants.au3> DriveMapDel("H:") DriveMapDel("S:") $temp1 = DriveMapAdd("H:", "\\servername\Shared", 8, "servername\", & $user, $passwd) MsgBox(0,"DriveMap H Syntax",$temp1) $temp2 = DriveMapAdd("S:", "\\servername\Home", 8, "servername\", & $user, $passwd) MsgBox(0,"DriveMap S Syntax",$temp2) My guess is that you need to add a space between $user and $passwd. Try the above and see if the spacing is correct. Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html
VirtMcPolygon Posted September 5, 2014 Author Posted September 5, 2014 #include <MagBoxConstants.au3> DriveMapDel("H:") DriveMapDel("S:") $temp1 = DriveMapAdd("H:", "\\servername\Shared", 8, "servername\", & $user, $passwd) MsgBox(0,"DriveMap H Syntax",$temp1) $temp2 = DriveMapAdd("S:", "\\servername\Home", 8, "servername\", & $user, $passwd) MsgBox(0,"DriveMap S Syntax",$temp2) My guess is that you need to add a space between $user and $passwd. Try the above and see if the spacing is correct. Hi there, Thanks for the response. I presume the #include <MagBoxConstants.au3> should be #include <MsgBoxConstants.au3>. When I run the script I get Error: Variable used without being declared in line 5.
spudw2k Posted September 5, 2014 Posted September 5, 2014 (edited) Hi there, Thanks for the response. I presume the #include <MagBoxConstants.au3> should be #include <MsgBoxConstants.au3>. When I run the script I get Error: Variable used without being declared in line 5. Correct, but I think it's eroneous in this example anyways as you aren't using any MsgBox constants. edit: On a side note...that comma ampersand sticks out to me. I'm not sure it should be like that. Correct as pointed out by misiooo below. The comma was/is erroneous. Edited September 5, 2014 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
misioooo Posted September 5, 2014 Posted September 5, 2014 Correct, but I think it's eroneous in this example anyways as you aren't using any MsgBox constants. On a side nite...that comma ampersand sticks out to me. I'm not sure it should be like that. ;& $user $temp1 = DriveMapAdd("H:", "servernameShared", 8, "servername", & $user, $passwd) ;just $user $temp1 = DriveMapAdd("H:", "servernameShared", 8, "servername", $user, $passwd) Looking at DriveMapAdd help file shouldnt it be like: $temp1 = DriveMapAdd("H:", "\\servername\Shared", 8, "servername\"&$user, $passwd) "domain"&$user = "domainusername" where username is a variable. Taken from example in help file: https://www.autoitscript.com/autoit3/docs/functions/DriveMapAdd.htm
spudw2k Posted September 5, 2014 Posted September 5, 2014 Um, yea...you're right. I should've looked at the Func instead of assuming the servername and username were separate parameters. Sorry for the confusion. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
VirtMcPolygon Posted September 16, 2014 Author Posted September 16, 2014 Guys, I appreciate the feedback. Evertime I try one of your examples though I getting an Error: Variable used without being declared message. Currently I have been using the following and converted to an .exe. DriveMapDel("X:") DriveMapDel("Y:") DriveMapAdd("X:", "\\servername\home\user.name", 8, "servername\user.name") DriveMapAdd("Y:", "\\servername\Shared", 8, "servername\user.name") When using this the user is prompted with a Windows login box before proceeding to map the drives. I am however having some issues where the program won't work for no apparent reason and I have to resort to the old net use batch file to complete the mapping so still on the hunt for a working reliable solution.
spudw2k Posted September 16, 2014 Posted September 16, 2014 (edited) Try inspecting @error after each DriveMapAdd to see if there is a reason why it isn't working. Return Value Success: 1. (See Remarks) Failure: 0 if a new mapping could not be created and sets the @error flag to non-zero. @error: 1 = Undefined / Other error. @extended set with Windows API return 2 = Access to the remote share was denied 3 = The device is already assigned 4 = Invalid device name 5 = Invalid remote share 6 = Invalid password DriveMapDel("X:") DriveMapDel("Y:") If Not DriveMapAdd("X:", "\\servername\home\user.name", 8, "servername\user.name") Then Msgbox(0,"DriveMapAdd(X:) failed", @error) If Not DriveMapAdd("Y:", "\\servername\Shared", 8, "servername\user.name") Then Msgbox(0,"DriveMapAdd(Y:) failed", @error) Edited September 16, 2014 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
VirtMcPolygon Posted September 16, 2014 Author Posted September 16, 2014 (edited) Try inspecting @error after each DriveMapAdd to see if there is a reason why it isn't working. Return Value Success: 1. (See Remarks) Failure: 0 if a new mapping could not be created and sets the @error flag to non-zero. @error: 1 = Undefined / Other error. @extended set with Windows API return 2 = Access to the remote share was denied 3 = The device is already assigned 4 = Invalid device name 5 = Invalid remote share 6 = Invalid password DriveMapDel("X:") DriveMapDel("Y:") If Not DriveMapAdd("X:", "\\servername\home\user.name", 8, "servername\user.name") Then Msgbox(0,"DriveMapAdd(X:) failed", @error) If Not DriveMapAdd("Y:", "\\servername\Shared", 8, "servername\user.name") Then Msgbox(0,"DriveMapAdd(Y:) failed", @error) Get error 1 mainly. It's weird, the permissions have been granted as going to the server via unc path works and the permissions work in granting share access. Just sometimes it fails to add the drive to Widows explorer. Edited September 16, 2014 by VirtMcPolygon
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