Page 1 of 2 12>
Topic Options
#71731 - 2002-11-21 01:00 PM Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
Heya,

I tried this little code:
code:
  $test = USE /List   
While $test <> ""
if Instr(Substr($test, 1, 2),"Z:") <> 1
Loop
Else
$t = Substr($test, 1, 2)
USE $t /delete
Loop
ENDIF

but it doesnt work [Smile]
The only way to delete all mapped network drives except Z: is to make something like:

code:
  $shares = "E:", "F:", "G:", "H:", "I:", "J:", "K:", "L:", "M:", "N:", "O:", "P:", "Q:", "R:", "S:", "T:", "U:", "V:", "W:", "X:", "Y:"

for Each $element In $shares
USE "$element" /delete

Next

But isn't there a better method?

tnx in advance

ps: for making it a little bit more advance...
I whould like the get all the IPC$ shares which are open and I want them to get deleted.
Like: \\bla\ipc$
\\bla2\ipc$

I want it to delete all open ipc$ connections and leave the rest alone (so first it kills all drive mappings except Z: then it kills all open connections to ipc$ shares.)

[ 21. November 2002, 13:09: Message edited by: bpsysadmin ]

Top
#71732 - 2002-11-21 01:09 PM Re: Want to make script wich delete's all network drives except Z:
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
I only attempt to delete the drive if I intend to map it in the script. That way if a user wishes to make other connections I do not undo them unless I need to in order to make/connect the standard mappings.

See http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=1;t=006243;p=1#000003 for the code I use.

[ 21. November 2002, 13:10: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71733 - 2002-11-21 01:14 PM Re: Want to make script wich delete's all network drives except Z:
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
btw USE is a command ... you cannot assign it to a variable unlike you can with functions
_________________________



Top
#71734 - 2002-11-21 01:18 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
Aha, well. these computers are located in our show rooms. We just want to get on the network by filling in some credentials, but it is not funny to have to delete every connection everytime. Thats why I want to make a script which can be called and clears up all connections (& credentials offcoarse) and leaves the Z: drive in tact. Thats why I cant use "USE * /delete)
Top
#71735 - 2002-11-21 01:23 PM Re: Want to make script wich delete's all network drives except Z:
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well the 4.02 manual states:

Use USE “*” /DELETE to delete all current connections except those to a NETLOGON share and those to the drive or share from which KiXtart was started.

so it would appear that you could use just
code:
use "*" /Delete  

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71736 - 2002-11-21 01:25 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
Since when is Z: an NETLOGON share?
Top
#71737 - 2002-11-21 01:32 PM Re: Want to make script wich delete's all network drives except Z:
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
win9x computers during logon map a z: to the netlogon folder. this z: is then removed once the logon process is finished running.
Top
#71738 - 2002-11-21 01:49 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
Aha well im running windows 2000 [Big Grin]
Top
#71739 - 2002-11-21 01:56 PM Re: Want to make script wich delete's all network drives except Z:
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Well then what about:
code:
For $i = 69 to 89
Use chr($i) + ":" /Delete /Persistent
Next

_________________________
Home page: http://www.kixhelp.com/hb/

Top
#71740 - 2002-11-21 02:00 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
yeah well that whould be nice, but ehmm...now how to add the \\computer\ipc$ share deletion?
Top
#71741 - 2002-11-21 02:00 PM Re: Want to make script wich delete's all network drives except Z:
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I must still wonder, what is so important there in z: that you can't simply do:

use "*" /del /persistent
use z: "\\my\place"
_________________________
!

download KiXnet

Top
#71742 - 2002-11-21 02:06 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
because there are programs runnning from the Z:\ drive? and then it whouldn't be that nice to just delete it and remap it? [Smile]
Top
#71743 - 2002-11-21 02:07 PM Re: Want to make script wich delete's all network drives except Z:
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, they are not logging on?
_________________________
!

download KiXnet

Top
#71744 - 2002-11-21 02:13 PM Re: Want to make script wich delete's all network drives except Z:
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
see the DriveEnum() and DriveProp() functions in the UDF lib...

You can also look into Win32_NetworkConnection
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#71745 - 2002-11-21 02:18 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
It is not a logon script, it is just a cleanup script after going into the network...clean up the drives and network shares excessed so the credentials get cleared...again: It are showroom pc's, so other pc may not fool arround with it so we want to clear all the connections.
Top
#71746 - 2002-11-21 02:21 PM Re: Want to make script wich delete's all network drives except Z:
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well then, if default connections are made not persistent and z is, you can do:
use "*" /del

and it takes out all but z, which is persistent.
_________________________
!

download KiXnet

Top
#71747 - 2002-11-21 02:22 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
Well as far as I know if you do a USE * /del you delete ALL drives even persistent ones...the /persistent is only when logging of it will still be there when logging on, or am I having it wrong at the mo?
Top
#71748 - 2002-11-21 02:23 PM Re: Want to make script wich delete's all network drives except Z:
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, if you are on net now, try that out, I can't
_________________________
!

download KiXnet

Top
#71749 - 2002-11-21 02:32 PM Re: Want to make script wich delete's all network drives except Z:
bpsysadmin Offline
Fresh Scripter

Registered: 2002-10-18
Posts: 20
thnx, I tried it. When you use in dos: NET USE Z: \\pc\share /persistent:yes and then NET USE * /delete then it delete's the drive eitherway.

But if I use it in kix like:

USE Z: "\\pc\share" /persistent
USE "*" /delete
then it works, BUT there comes a red cross on the Z drive, but it is still there mapped.So now im gonna try if the red cross gives problems with the running applications...cause when you click the drive there is no problem and the red cross disappears.... thnx again

Top
#71750 - 2002-11-21 02:39 PM Re: Want to make script wich delete's all network drives except Z:
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
Here is your solution:

Obtain the WSHPIPE UDF from the "UDF Collection" (link below) and use this script.
code:
for each $line in WshPipe("net use",1)
if left($line, 2) = "OK"
$drive = substr($line, 14, 2)
$path = substr($line, 24)
$path = left($path, instr($path, " ")-1)
if $drive <> "Z:"
;use $drive $path /del /persistent
? "use $drive $path /del /persistent"
endif
endif
next

{edit} forgot the if z:

[ 21. November 2002, 14:41: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/

Top
Page 1 of 2 12>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1574 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.086 seconds in which 0.036 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