Tuesday, February 20, 2007

Copy Code To Clipboard

This text will be copied onto the clipboard when you click the button below. Try it! It will also retain the indentation and add proper end-of-line sequences.


  (SECURITY SETTINGS - NEEDS TO BE TRUSTED SITE)

Dim objWMIService
Dim colFiles
Dim oFile
Dim iReturn, sReturn

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\"& strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery("Select * from CIM_DataFile where Extension = 'cpy'")

For Each oFile in colFiles
	wscript.Echo "OLDNAME:" & oFile.Name
	sNewName = oFile.Path & oFile.FileName & ".log"
	wscript.Echo "NEWNAME:" & sNewName
	iReturn = oFile.rename( sNewName )
	If Return <> 0 Then
		Select Case iReturn
			Case0 : sReturn = "Success" 
			Case2 : sReturn = "Access denied"
			Case8 : sReturn = "Unspecified failure"
			Case9 : sReturn = "Invalid object"
			Case 10 : sReturn = "Object already exists"
			Case 11 : sReturn = "File system not NTFS"
			Case 12 : sReturn = "Platform not Windows NT or Windows 2000"
			Case 13 : sReturn = "Drive not the same"
			Case 14 : sReturn = "Directory not empty"
			Case 15 : sReturn = "Sharing violation"
			Case 16 : sReturn = "Invalid start file"
			Case 17 : sReturn = "Privilege not held" 
			Case 21 : sReturn = "Invalid parameter"
		End Select
	MsgBox sReturn & ">>>>" & oFile.Name
	End If

Next

No comments:

Post a Comment