Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Volume Rename Help...

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,49154
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Volume Rename Help...
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Volume Rename Help... - 7/7/2007 4:05:07 PM   
  zkoolkyle

 

Posts: 2
Score: 0
Joined: 7/7/2007
Status: offline
Hi, My name is kyle and im still just a newb at scripting. This might seem like a simple question or a stupid mistake by me but Im in need of help for a script. I have this script but i keep getting errors when i run it? any help on why??? Its built to change a vlume name.

=======================================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
   ("Select * from Win32_LogicalDisk where DeviceID = 'C:'")
For Each objDrive in colDrives
   objDrive.VolumeName = "Finance Volume"
   objDrive.Put_

End
======================================================
 
 
 
Post #: 1
 
 RE: Volume Rename Help... - 7/8/2007 2:15:03 AM   
  dm_4ever


Posts: 2254
Score: 32
Joined: 6/29/2006
From: Orange County, California
Status: offline
If you're trying to change the name of a drive it may be easier to use the Shell object

i.e.

Option Explicit

Dim objShell : Set objShell = CreateObject("Shell.Application")
objShell.NameSpace("C:\").Self.Name = "Finance Volume"


Also there's an error in your current loop...


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
   ("Select * from Win32_LogicalDisk where DeviceID = 'C:'")
For Each objDrive in colDrives
   objDrive.VolumeName = "Finance Volume"
   objDrive.Put_

End  ' Change this to Next

< Message edited by dm_4ever -- 7/8/2007 2:18:50 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to zkoolkyle)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Volume Rename Help... Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts