#172481 - 2007-01-07 01:52 PM
Identifying a drive mapping, writing to then readfing from file
|
Willmaykett
Fresh Scripter
Registered: 2007-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
|
|
|
|
#172499 - 2007-01-08 12:39 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Lonkero]
|
Willmaykett
Fresh Scripter
Registered: 2007-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
|
|
|
|
#172502 - 2007-01-08 02:59 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Allen]
|
Willmaykett
Fresh Scripter
Registered: 2007-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
|
|
|
|
#172507 - 2007-01-08 04:05 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Sealeopard]
|
Willmaykett
Fresh Scripter
Registered: 2007-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 - 2007-01-08 04:33 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Willmaykett]
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4545
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()
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 - 2007-01-08 05:12 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Allen]
|
Willmaykett
Fresh Scripter
Registered: 2007-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 - 2007-01-08 06:37 AM
Re: Identifying a drive mapping, writing to then readfing from file
[Re: Willmaykett]
|
Willmaykett
Fresh Scripter
Registered: 2007-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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 515 anonymous users online.
|
|
|