#71731 - 2002-11-21 01:00 PM
Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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 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
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 ]
|
Top
|
|
|
|
#71734 - 2002-11-21 01:18 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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
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
|
Top
|
|
|
|
#71736 - 2002-11-21 01:25 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
Fresh Scripter
Registered: 2002-10-18
Posts: 20
|
Since when is Z: an NETLOGON share?
|
Top
|
|
|
|
#71738 - 2002-11-21 01:49 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
Fresh Scripter
Registered: 2002-10-18
Posts: 20
|
Aha well im running windows 2000
|
Top
|
|
|
|
#71739 - 2002-11-21 01:56 PM
Re: Want to make script wich delete's all network drives except Z:
|
Howard Bullock
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
|
Top
|
|
|
|
#71740 - 2002-11-21 02:00 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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
|
|
|
|
#71742 - 2002-11-21 02:06 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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?
|
Top
|
|
|
|
#71744 - 2002-11-21 02:13 PM
Re: Want to make script wich delete's all network drives except Z:
|
Radimus
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
|
Top
|
|
|
|
#71745 - 2002-11-21 02:18 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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
|
|
|
|
#71747 - 2002-11-21 02:22 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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
|
|
|
|
#71749 - 2002-11-21 02:32 PM
Re: Want to make script wich delete's all network drives except Z:
|
bpsysadmin
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
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 ]
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1574 anonymous users online.
|
|
|