MS Used To Save Drive Mapping Config

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

MS Used To Save Drive Mapping Config

Post by CyberCitizen » Thu Jul 27, 2006 3:10 am

Hey Guys,

I have an issue with a script that I have.

What I am trying to do is to create a MS exe that I can give to users that they can run & it will save a txt file to their Z: drive with all there current drive mappings.

Now this part I have, I also have it so that it displays the drive mapping in a Message Box.

What I am wanting to do is to add an option on the dialog to auto map the drives via the dos command. Any suggests or code would be great as I am at a lost. I am thinking about reading the lines to read the mapping config, however not sure how to go.

Code: Select all

Let>APP_TITLE=Drive Mapping CFG Saver

Dialog>DriveCFG
   Caption=Drive Map CFG
   Width=161
   Height=155
   Top=CENTER
   Left=CENTER
   Max=0
   Min=0
   Close=1
   Resize=0
   Label=Drive Mapping Config Saver,8,8,true
   Button=Save Config File,8,24,137,25,3
   Button=Load Saved Config File,8,56,137,25,4
   Button=Exit,8,88,137,25,2
EndDialog>DriveCFG

Show>DriveCFG

Label>ActionLoop
GetDialogAction>DriveCFG,Result
if>Result=2,Exit
if>Result=3,Save
if>Result=4,Read
Goto>ActionLoop

//Write Drive Mapping CFG
Label>Save
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Run Program>cmd /c net use > Z:\DriveMapping.txt
Let>RP_WINDOWMODE=1
Let>RP_WAIT=0
Goto>Read

//Read Drive Mapping CFG
Label>Read
ReadFile>Z:\DriveMapping.txt,MappingInformation
Let>MSG_HEIGHT=300
Let>MSG_WIDTH=500
MessageModal>%MappingInformation%
ResetDialogAction>DriveCFG
Goto>ActionLoop

Label>Exit
FIREFIGHTER

hvdberg
Junior Coder
Posts: 39
Joined: Wed Jul 12, 2006 1:50 pm
Location: Netherlands

Post by hvdberg » Thu Jul 27, 2006 4:28 am

Hi Cybercitizen,

Check out the ReadLn command. Combined with MidStr you should be able to extract the UNC-path from every individual drive mapping and reassemble the required NET USE command text.

If you need help parsing the lines from your Drivemapping.txt file, drop a message and I'll see what I can do for you.

Best,
Henk

User avatar
JRL
Automation Wizard
Posts: 3517
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jul 27, 2006 4:50 am

Cy,

I am doing something similar but the code is at work and I am at home. To get you started, I'm using an INI file format for the saved configuration. As I recall its something like.

[Username]
drive1=L
server1=servername
resourse1=resourcename
password1=*****

drive2=lpt1
server2=servername
resourse2=resourcename
password2=*****

etc
I have the password encrypted and the script decrypts it.
If the password field does not exist then the username and password are not passed to the net use line. when driveX does not exist the script ends.

I see Henk just posted and I agree. the midstr> function can be used to parse the individual lines to login or in my case to create the INI file. The main reason I went with the INI rather than simply saving the net use info and parsing to login was that I need to have the user name and password information for my users to login.

Hope this info is useful, If this is a path you'd consider let me know and I can get more detailed when I have my actual code to refer to.

Later,
Dick

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts