Solved

script to netsend or email disk name daily

Posted on 2006-11-15
6
448 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
A short article about problems I had with the new location API and permissions in Marshmallow
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

739 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