Jump to content



Photo

mapping drives


  • Please log in to reply
8 replies to this topic

#1 ledigeine

ledigeine

    Wayfarer

  • Active Members
  • Pip
  • 87 posts

Posted 11 June 2012 - 06:47 PM

Ok so this project im working on is to make a UI that will let you pick a version of software then map to the drives needed based on an XML file.
I have many parts already setup but now im getting to the point where i might need to run commands to a cmd prompt or as i found out theres a DriveMap function.

The plans i had were to make the UI have 3 or 4 buttons:
Map = check if the drive letters we use are used already, if they are clear those. The user could have the drives Mapped or Subst'd so i will have to figure out how to check for either of those. Then clear them so my mapping will go through with out issue.

Clear = button will clear any thing mapped to the letters we use g/h, clearing mapped or subst'd drives.

Run = this will be a button that will run an EXE from the drives that the user has hopefully mapped with out error.

Exit = exits the ui

Now before starting any of these i was wondering if you guys have found easy or quick ways to help me out. Luckily i found the DriveMap fuctions or id have been looking for cmdprompt stuff this whole time.
Any tips on any button would be great... cept the exit.. i already got that done ;)







#2 Kidney

Kidney

    Adventurer

  • Active Members
  • PipPip
  • 134 posts

Posted 11 June 2012 - 07:18 PM

in SciTE, there is an add-on included in autoIT called Koda(FormDesigner). its located under Tools.

that will get you started on the GUI. once you have the GUI setup like you want it, click the button on the top left corner of Koda that is called "Generate Code" the hot key is F9.
copy all the code that was generated to your autoIT script and when you run it, the GUI should show.
in the While loop, i would change the Switch case to a Select case so that way the form doesnt close after 1 button click. here is what yours might look like:

While 1     $nMsg = GUIGetMsg()     Select $nMsg         Case $GUI_EVENT_CLOSE Or $nMsg = $btnExit             Exit         Case $nMsg = $btnMap             _Func_Map()         Case $nMsg = $btnRun             _Func_Run()         Case $nMsg = $btnClear             _Func_Clear()     EndSelect WEnd


#3 ledigeine

ledigeine

    Wayfarer

  • Active Members
  • Pip
  • 87 posts

Posted 11 June 2012 - 07:26 PM

Ahh yes thnx i never noticed that area before.
I already kinda got the UI and stuff going.
ui.jpg

I will be having the map button run a new function so that will be fine. I think my issue right now is coding the checking for mapped drives then mapping and all that. I feel like its hard to believe that DriveMapGet/DriveMapAdd/DriveMapDelete will do all i need. Usually when something is too easy I end up having to go back to fix it like 9 times.

Also i will need to figure out how to check for subst'd drives so i can clear them. But i havent even started researching that yet.

#4 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,868 posts

Posted 11 June 2012 - 07:27 PM

While 1     $nMsg = GUIGetMsg()     Select $nMsg         Case $GUI_EVENT_CLOSE Or $nMsg = $btnExit  

Your code for the Select statement is wrong, that is the format for a Switch statement. Select is different, see below.
While 1     $nMsg = GUIGetMsg()     Select         Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $btnExit

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#5 EndFunc

EndFunc

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 426 posts

Posted 11 June 2012 - 07:34 PM

Ok so this project im working on is to make a UI that will let you pick a version of software then map to the drives needed based on an XML file.
I have many parts already setup but now im getting to the point where i might need to run commands to a cmd prompt or as i found out theres a DriveMap function.

The plans i had were to make the UI have 3 or 4 buttons:
Map = check if the drive letters we use are used already, if they are clear those. The user could have the drives Mapped or Subst'd so i will have to figure out how to check for either of those. Then clear them so my mapping will go through with out issue.

Clear = button will clear any thing mapped to the letters we use g/h, clearing mapped or subst'd drives.

Run = this will be a button that will run an EXE from the drives that the user has hopefully mapped with out error.

Exit = exits the ui

Now before starting any of these i was wondering if you guys have found easy or quick ways to help me out. Luckily i found the DriveMap fuctions or id have been looking for cmdprompt stuff this whole time.
Any tips on any button would be great... cept the exit.. i already got that done ;)

Question.. Do you have to use G or H drive. Because like you said if the user already has it mapped you'd have to disconnect it and remap, Why not just use any available drive for your script so that way its more dynamic and it doesn't matter if they have those drives mapped already.

i do this all the time with autoit. Use DriveMapAdd to map any drive, run your script then disconnect it. Example

$Drive = DriveMapAdd("*", "server1c$") ;Do something with $Drive which will contain the $Drive autoit mapped. ;Example Run($Drive & "script.exe") ;Then to remove the drive use DriveMapDel DriveMapDel($Drive) ;This way you never need to know or hardcode a Drive letter. It will pick any unused drive letter.

Edited by EndFunc, 11 June 2012 - 07:35 PM.

EndFuncAutoIt is the shiznit. I love it.

#6 Kidney

Kidney

    Adventurer

  • Active Members
  • PipPip
  • 134 posts

Posted 11 June 2012 - 07:36 PM

Your code for the Select statement is wrong, that is the format for a Switch statement. Select is different, see below.

While 1     $nMsg = GUIGetMsg()     Select         Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $btnExit

thanks for catching my error ;)

#7 ledigeine

ledigeine

    Wayfarer

  • Active Members
  • Pip
  • 87 posts

Posted 11 June 2012 - 07:59 PM

Question.. Do you have to use G or H drive. Because like you said if the user already has it mapped you'd have to disconnect it and remap, Why not just use any available drive for your script so that way its more dynamic and it doesn't matter if they have those drives mapped already.

i do this all the time with autoit. Use DriveMapAdd to map any drive, run your script then disconnect it. Example

$Drive = DriveMapAdd("*", "server1c$") ;Do something with $Drive which will contain the $Drive autoit mapped. ;Example Run($Drive & "script.exe") ;Then to remove the drive use DriveMapDel DriveMapDel($Drive) ;This way you never need to know or hardcode a Drive letter. It will pick any unused drive letter.

Nah i need g and h sadly, the software im trying to work with is already set to use G/H. its shared data too so if i just start changing what drive it should be looking for I would jack everybody else up.

I already have .bat files that will do all this but im trying to learn to use autoit just as a hobby and I figured having autoit call a .bat file is kinda cheating myself out of learning.
While im trying to learn I dont want this thing to take a year to make ha. So i post on here for help or tips mainly to avoid doing the work 4 times as i learn theres a fuction for this or that.

As a lil test i tried using drivemapget to see G: while its subst'd and it just comes back blank. I might have to jump out to a CMD with it to clear those. ;)

#8 jdelaney

jdelaney

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 990 posts

Posted 11 June 2012 - 08:10 PM

If Not DriveMapGet("G:") = $sDriveMap Then  DriveMapDel("G:")  If Not DriveMapAdd("G:", $sDriveMap, 8) Then MsgBox(4096, "Map G:", "Unable to Map: " & $sDriveMap) EndIf


the above works for me
  • ledigeine likes this

#9 ledigeine

ledigeine

    Wayfarer

  • Active Members
  • Pip
  • 87 posts

Posted 11 June 2012 - 08:16 PM

Ok thats kinda what i was thinking id do, maybe aslo have something before adding the drive to clear g/h subst drives as well. Not even check for them just clear g/h each time.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users