[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Remove all mapped drives on all machines in the txt file.

Posted on 2009-02-14
11
Medium Priority
?
442 Views
Last Modified: 2012-05-06
Hi,

Remove all mapped drives on all machines in the txt file.
Any way to disconnect all mapped drives.

REgards
Sharath
0
Comment
Question by:bsharath
  • 6
  • 4
11 Comments
 
LVL 10

Expert Comment

by:GuruGary
ID: 23643667
I am not sure what you mean by "in the txt file".  But a simple command to remove all network share drive mappings in a command prompt or BAT/CMD file is:
net use * /delete
@echo off
net use * /delete

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 23643928
Ok..

I need to do this for a lot of different computers . Whose names are in a txt file...

Machinename1
machinename2
0
 
LVL 11

Author Comment

by:bsharath
ID: 23643929
Ok..

I need to do this for a lot of different computers . Whose names are in a txt file...

Machinename1
machinename2
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 14

Expert Comment

by:yehudaha
ID: 23644389
why don't do it with a logon script ?
0
 
LVL 14

Accepted Solution

by:
yehudaha earned 2000 total points
ID: 23644435
try this

change log file and list file path

Set objlist = objfso.OpenTextFile("c:\list.txt", ForReading)
Set objlog = objfso.CreateTextFile("c:\log.txt", ForWriting)

download psexec from here:
http://download.sysinternals.com/Files/PsTools.zip

and change toll path here:
strTool = "\\server\share\psexec.exe"
Const ForReading = 1
Const ForWriting = 2
  
Set objfso = CreateObject("Scripting.FileSystemObject")
Set objlist = objfso.OpenTextFile("c:\list.txt", ForReading)
Set objlog = objfso.CreateTextFile("c:\log.txt", ForWriting)
 
strTool = "\\server\share\psexec.exe"
 
Do Until objlist.AtEndOfStream
strComputer = objlist.ReadLine
If Reachable(strComputer) Then
   If per(strComputer) then
strCommand = strTool & " \\" & strComputer & " net use * /delete /y"
objshell.Run(strCommand)
   Else
     objlog.WriteLine "You Don't Have Permission On " & strComputer & vbCrLf
   End if
Else
objlog.WriteLine strComputer & " Isn't Reachable" & vbCrLf
End if
Loop
 
 
Function Reachable(strComputer)
 
 strCmd = "ping -n 1 " & strComputer
 
 Set objShell = CreateObject("WScript.Shell")
 Set objExec = objShell.Exec(strCmd)
 strTemp = UCase(objExec.StdOut.ReadAll)
 
 If InStr(strTemp, "REPLY FROM") Then
 Reachable = True 
 Else
 Reachable = False
 End If
End Function
 
Function per(computer)
	strcomputer = computer
	On Error Resume Next
	Set objWMIService = GetObject("winmgmts:" _
	& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
	If err.number <> 0 Then
		err.Clear
		per = False
		On Error goto 0
	Else
		per = True
		On Error goto 0
	End If
End Function

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 23644643
I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Map drives removal.vbs
Line:      6
Char:      1
Error:      Permission denied
Code:      800A0046
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
0
 
LVL 11

Author Comment

by:bsharath
ID: 23644644
I get this

---------------------------
Windows Script Host
---------------------------
Script:      C:\Map drives removal.vbs
Line:      6
Char:      1
Error:      Permission denied
Code:      800A0046
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 23644648
sorry the script have other problems try to figure it how
0
 
LVL 11

Author Comment

by:bsharath
ID: 23644668
Ok thanks
0
 
LVL 11

Author Comment

by:bsharath
ID: 23644669
Ok thanks
0
 
LVL 14

Expert Comment

by:yehudaha
ID: 23670163
i don't have a way

sorry
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question