Page 1 of 1 1
Topic Options
#172481 - 07/01/07 01:52 PM Identifying a drive mapping, writing to then readfing from file
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
Hi all,

Absolute newbie to Kixtart, with no previous scripting experience, so please be kind to me

I want to use Kix to perform the following functions:

1. Find out the server and full share name of a mapped drive letter, eg P:. This share can include spaces, & etc.

2. If the drive is not mapped, write out to an appended error file. If the drive exists, write out the unc path to a file. Should only need to be a single line.

3. I then need to be able to read the line of the file, so that I can use it to map a new drive letter against the share.

Not sure about how to attack part 1, for part 2 and 3 I think I need a combination of writeline, readline and obviously use commands. I am looking for assistance for a nice easy way of doing it, so I can start to understand and modify as I go.

Thanks for the anticipated help.
Willy

Top
#172482 - 07/01/07 03:09 PM Re: Identifying a drive mapping, writing to then readfing from file [Re: Willmaykett]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
hmm...
why you want to write to file?
_________________________
!

download KiXnet

Top
#172483 - 07/01/07 04:12 PM Re: Identifying a drive mapping, writing to then readfing from file [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
please provide some info about the actual write process and why you need it.
simply writing a textfile might not be the best way if you wanna use the info with some other script or program.
if you want the file for logging purposes only, then it's another deal.
_________________________
!

download KiXnet

Top
#172484 - 07/01/07 04:27 PM Re: Identifying a drive mapping, writing to then readfing from file [Re: Lonkero]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
I'm confused why KiX would have to pull the info back from the text file. I mean, if KiX wrote it in the first place it should already know the value unless the script that wrote it is different from the one reading it.

In that case a serial text file is probably not the way to go. Use an INI file instead.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172494 - 07/01/07 09:56 PM Re: Identifying a drive mapping, writing to then readfing from file [Re: Les]
Sealeopard Offline
KiX Master
*****

Registered: 01/04/25
Posts: 11161
Loc: Boston, MA, USA
Drive mappings are stord in the registry under HKCU\Network. You can then use ArrayEnumKey UDF to enumerate the mapped drive letters.
_________________________
There are two types of vessels, submarines and targets.

Top
#172496 - 07/01/07 10:36 PM Re: Identifying a drive mapping, writing to then readfing from file [Re: Sealeopard]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 01/06/05
Posts: 22294
Loc: Claremore, OK
hmm...
there is udf's for enuming the mapped drives too.
don't think that's the issue now.
at least I wanna hear back from this guy before offering anything deeper...
_________________________
!

download KiXnet

Top
#172499 - 07/01/08 12:39 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Lonkero]
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
Thanks for all the responses!

These are the requirements behind the intial request.

Currently, each user ( about 400 ) use a multitude of dos batch files when logging in. There exists a batch file which maps a P: drive to their own unique location, so the current batch file has 400 or If %username% = user , then map p: to \\server\share\xxxxx. Same goes for the group mappings, Really cool.... not. As you can imaging, there are people who do not have a P: drive, then stuff breaks and call the HelpDesk cause someone goofed in the batch file.

I have started implementing kix to replace the horrendous group drives, and that works well. But the P: drive is a bit more interesting, especially as a migration is underway at the moment.

1. I need to determine their existing P: drive when they login in, rather than try and find what they currently map too in the batch file.
2. I am required to write this file into their home directory.
3. Whenever they log back in, this file is then parsed to determine the share folder and directory.
4. The drive is then mapped accordingly.
5. Whenever the user logs off a script will be used to check and rewrite the contents of the file if they have changed the P: drive mapping.

The reason for this method is that the local IT department has determined that this is the way they want to control the users P: drive and can then update for the user as needed.

Willy

I hope this make more sense.

Top
#172501 - 07/01/08 02:18 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Willmaykett]
Allen Moderator Offline
KiX Supporter
*****

Registered: 03/04/19
Posts: 4241
Loc: USA
If all of your workstations are Windows 2000 or higher you could make your life a whole lot easier. Just rename the users folders to match their user names. Then share the Users folder. IE...
Root
  Users <--shared
    User1
    User2
    User3

Finally in your kixscript...

use p: "\\Server\Share\" + @userid

Top
#172502 - 07/01/08 02:59 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Allen]
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
The P: drive mapping is used by the users to map to different folder structures within a common share, often referred to as the "personal preference drive". This is in addition to their normal home drive, so unfortunately, I can't use your suggestion.

I need the following:

Stage 1:

1. Read the users current P: drive.
2. Write the results to a text file. Should only be a single line with \\server\share\folder

stage 2:
1. Read the contents of the text file from step 2 above
2. Then do a use command to map a drive.

There must be a file created that is stored in the users home directory.

Thanks

Top
#172505 - 07/01/08 03:51 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Willmaykett]
Sealeopard Offline
KiX Master
*****

Registered: 01/04/25
Posts: 11161
Loc: Boston, MA, USA
Set a default personla preference file if one doesn't exist yet.
_________________________
There are two types of vessels, submarines and targets.

Top
#172506 - 07/01/08 04:05 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Sealeopard]
Les Offline
KiX Master
*****

Registered: 01/06/11
Posts: 12734
Loc: fortfrances.on.ca
Having different drive mappings in a common share area is just a bad idea. When users create links within shared documents, their link would be to their *preference* and be broken for others.

I do not use any sort of *preference* mappings in my logon script but some of my users map personal drives and are forever causing problems with invalid links. They also make verbal reference to them causing support calls.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#172507 - 07/01/08 04:05 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Sealeopard]
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
Thats exactly what I want to do, is to generate the file.

Started exploring the HCU option, and then writing that to the file.

Any code ideas?

Top
#172508 - 07/01/08 04:33 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Willmaykett]
Allen Moderator Offline
KiX Supporter
*****

Registered: 03/04/19
Posts: 4241
Loc: USA
I'm glad to help you with this... but I got to tell you, fixing this problem rather than putting a bandaid on it is your best bet... What if they delete this file after you create it? Anyway... not trying to preach ;\)

Using EnumNetworkDrives()
Code:
For each $Drive in EnumNetworkDrives()  
  $letter=Split($Drive,",")[0]
  $path= Split($Drive,",")[1]
  if $letter="p:"
    ? $letter + " " + $path
    ;Write this info to a text file or ini file
  endif
Next 
 

Top
#172509 - 07/01/08 05:12 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Allen]
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
Hi Allen,

I can certainly understand your point, but they have been used to it for a number of years, and let's say... " We had it for a number of years, we like it, why should we change it....." and believe me, it ain't worth the frustration. As they say, you want a mini minor, I will give you a mini minor, but not without trying to upsell first. Response...Pass on that thanks....

BTW - The files live in a configuration folder, and users know if they delete any files in there, they cop the wrath of the IT support lady...

That looks nice and easy, I will incorporate that in the script.

thanks!

Top
#172510 - 07/01/08 06:37 AM Re: Identifying a drive mapping, writing to then readfing from file [Re: Willmaykett]
Willmaykett Offline
Fresh Scripter

Registered: 07/01/07
Posts: 21
Hi Allen,

Incorporated the EnumNetworkDrives() UDF and you code snippet, I have now successfully been able to write out the text file. I have incorporated the kix script into the users normal login scripts and I have been able to extract everyones P: drive !!

Thanks heaps for your help!! Onya

Willy

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 113 anonymous users online.
Newest Members
schnuggel, h315060, johnnyutah, pmk31, ArserHsieh
17412 Registered Users

Generated in 0.036 seconds in which 0.01 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org