Sign in to follow this  
Followers 0
ClosetDweller

Search Network for ComputerName to map a share

7 posts in this topic

#1 ·  Posted (edited)

I am deploying about 250 workgroup workstations to POS locations and what I would like to achieve is to present an input box:

Local $value = InputBox("Store Number", "Enter the 4 digit store number", "", " M4")

to which they would enter their store number (ex. 0099) for the store number.

I would like to capture that information and add it to the known constant of the remainder of the nomenclature ex (Store_$value_A) that I can then use to map a share based on %computername%sharename

is this possible?

Edited by ClosetDweller

Share this post


Link to post
Share on other sites



Hi, ClosetDweller, welcome to the forum. With AutoIT, all things are possible :)

So, if I understand you correctly, you already have your input box to prompt the user to input a store number:

Local $value = InputBox("Store Number", "Enter the 4 digit store number", "", " M4")

Based on the 4 digit number returned, you would like to assign a variable:

$store = "Store_" & $value & "_A"

Then you want to map a network drive based on that new variable:

Run("net use z: " & $store & "MyShare", "", @SW_SHOW)

Is that about what you're looking to do?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Maybe you need to work with StringFormat('%4i', $variable) to format it. Should be a 4 digits.

Or use something like this

#Region    ;************ Includes ************
#Include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#EndRegion ;************ Includes ************
$GUI = GUICreate(" My GUI", 350, 180)
$hInput = GUICtrlCreateInput("0000", 10, 5, 100, 20, $ES_NUMBER)
$hstart_B = GUICtrlCreateButton('Start', 10, 30, 100, 20, $BS_DEFPUSHBUTTON)
GUICtrlSetLimit(-1, 5)
GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $hstart_B Then ConsoleWrite(GUICtrlRead($hInput) & @LF)
WEnd
Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
Local $controlID = _WinAPI_LoWord($wParam)
If $controlID = $hInput Then
  GUICtrlSetData($hInput, StringFormat('%05i', GUICtrlRead($hInput)))
  GUICtrlSetData($hInput, StringTrimLeft(GUICtrlRead($hInput), 1))
  ; your logic
EndIf
EndFunc   ;==>MY_WM_COMMAND

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I wrote this on my way to bed last night, and am unsure this morning why I suggested you use Net Use. The last example in my suggestion can be done easily enough with DriveMapAdd:

DriveMapAdd("Z:", "" & $store & "MyShare")

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Hi, ClosetDweller, welcome to the forum. With AutoIT, all things are possible :)

So, if I understand you correctly, you already have your input box to prompt the user to input a store number:

Local $value = InputBox("Store Number", "Enter the 4 digit store number", "", " M4")

Based on the 4 digit number returned, you would like to assign a variable:

$store = "Store_" & $value & "_A"

Then you want to map a network drive based on that new variable:

Run("net use z: " & $store & "MyShare", "", @SW_SHOW)

Is that about what you're looking to do?

Exactly... is there more to it than that? seems surprisingly simple.

Share this post


Link to post
Share on other sites

Hi, ClosetDweller. Do you WANT AutoIT to make things more difficult for you? :) I'm personally thrilled when I can do something quickly and easily.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can use regular expressions, to make sure the input is valid.

For the environment variables you will can use setx (google will invariably "correct" setx to sex, so be careful if you are at work. duckduckgo from now on) or the registry

User Variables: HKEY_CURRENT_USEREnvironment

System Variables: HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment

http://vlaurie.com/computers2/Articles/environment.htm

Edited by DicatoroftheUSA

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