Solved

script to netsend or email disk name daily

Posted on 2006-11-15
6
447 Views
Last Modified: 2012-06-22
Hi,

I need a script that can be set to run daily with task manager that will net send (1st preference) or email (least preferable) the volume name of an attached USB drive.

WHY= I have 12 servers that use USB drive for backups. Usually G: drive.
The drives are named Monday, Tuesday, Wednesday etc. etc.

At 4.00PM I want all the servers to notify our backup admin which drive is attached so that if one site forgot to change the drive over, he can contact them in advance to the backup job failing later in the evening.

THanks a lot.
0
Comment
Question by:viperacom
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Christopher Kile
ID: 17947816
Write a VBScript that does the job, then schedule it using Scheduled Tasks.

The FileSystemObject provides objects and methods for you to use to get the volume name.
0
 
LVL 7

Expert Comment

by:yotamsher
ID: 17950733
here is a script similar to what you need:
it sneds through netsend (to * which you have to change) the labels of all removable drives on the computer.
if you need assistance with running it through scheduled tasks, please post here
be sure to run it, with cscript

'-----------------------------------------
'              drives.vbs
'-----------------------------------------

dim filesys, filetxt, getname, path, compname
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Drives = filesys.Drives
Set WshNetwork = WScript.CreateObject("WScript.Network")
compname = WshNetwork.ComputerName
for each DiskDrive in Drives
      if DiskDrive.IsReady then
            DriveLetter = DiskDrive.DriveLetter
            DT = DiskDrive.DriveType
            Volume = DiskDrive.VolumeName
            Select Case DT
                  Case "0" DriveType = "Unknown type of drive"
                  Case "1" DriveType = "Removable drive"
                  Case "2" DriveType = "Fixed drive"
                  Case "3" DriveType = "Network drive"
                  Case "4" DriveType = "CD-ROM drive"
                  Case "5" DriveType = "RAM Disk"
            End Select


            WScript.echo DriveLetter  & ": type=" & DriveType
            if DT = 1 then
                  Dim shell
                  dim command
                  command ="net send * " & Chr(34) &"[" & compname & "] "& DriveLetter  & ": (" & Volume & ") type=" & DriveType & Chr(34)  
                  WScript.echo command
                  Set shell = CreateObject("WScript.Shell")
                  shell.Run command , 1, false
                  Set shell = Nothing
            end if
      end if

next
set WshNetwork = nothing
Set Drives = nothing
set filesys = nothing      
0
 
LVL 1

Author Comment

by:viperacom
ID: 17951823
awesome that works really well.

PS: Can I make it net send "no removable drive" if one is not found?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:viperacom
ID: 17953093
ahh... problem... the USB hard drives show up as fixed disk.
Tell you what, I know that they are usually G: Drive so can you please show how to make it just send the volumename of G: Drive?

thank you.
0
 
LVL 1

Author Comment

by:viperacom
ID: 17953099
oh sorry, and can it send the amount of free space and filenames contained (there are only ever around 10 files in total).
I am happy to award more pionts
0
 
LVL 7

Accepted Solution

by:
yotamsher earned 500 total points
ID: 17959393
Hey

here is what you asked for
the files part, is looking for files in g:\, not in sub directories

'-----------------------------------------
'              drives-2.vbs
'-----------------------------------------

dim filesys, filetxt, getname, path, compname
Set filesys = CreateObject("Scripting.FileSystemObject")
Set Drives = filesys.Drives
Set WshNetwork = WScript.CreateObject("WScript.Network")
compname = WshNetwork.ComputerName
Set DiskDrive = filesys.Drives("G")
if DiskDrive.IsReady then
      DriveLetter = DiskDrive.DriveLetter
      DT = DiskDrive.DriveType
      Select Case DT
            Case "0" DriveType = "Unknown type of drive"
            Case "1" DriveType = "Removable drive"
            Case "2" DriveType = "Fixed drive"
            Case "3" DriveType = "Network drive"
            Case "4" DriveType = "CD-ROM drive"
            Case "5" DriveType = "RAM Disk"
       End Select


      WScript.echo DriveLetter  & ": type=" & DriveType
      Volume = DiskDrive.VolumeName
      FreeSpace=DiskDrive.AvailableSpace
      dim files
      files = "files: "
      Set objFolder = filesys.GetFolder("g:\")
      Set colFiles = objFolder.Files
      For Each objFile in colFiles
            files = files & objFile.Name & " ,"
      Next

      Dim shell
      dim command
      command ="net send * " & Chr(34) &"[" & compname & "] "& DriveLetter  & ": (" & Volume & ") type=" & DriveType & " ["& FreeSpace & "] free " & files & Chr(34)
      WScript.echo command
      Set shell = CreateObject("WScript.Shell")
      shell.Run command , 1, false
      Set shell = Nothing
end if

set WshNetwork = nothing
Set Drives = nothing
set filesys = nothing    
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

820 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