1.

Solve : copy names & info from disk drives to a .txt file?

Answer»

would the fsutil command return excess information?
Code: [Select]fsutil fsinfo volumeinfo C:\   (or d, or E...)
thanks for the help..Sidewinder..!! it works nice under Admin accounts..
the only thing is that when i try to use this driveinfo.vbs in a guest account on WIN xp pro it gives me this error:
E:\driveinfo.vbs(7, 1) MICROSOFT VBScript runtime error: Permission denied: 'GetObject'

and it also wont follow through by copying the drives infos over to the report.inf
is there anyway at all to make this script work propperly in a guest account..


Quote from: Sidewinder on June 28, 2008, 07:21:56 PM

gumbaz,

This script is self-contained, no need for any batch files or supporting VBScripts.

Code: [Select]Const ForAppending = 8

strComputer = "."

Set objArgs = WScript.Arguments
Set fso = CreateObject("Scripting.FileSystemObject")
Set wmiServices  = GetObject ("winmgmts:{impersonationLevel=Impersonate}!//" & strComputer)
Set wmiDiskDrives =  wmiServices.ExecQuery ("SELECT * FROM Win32_DiskDrive")

For Each wmiDiskDrive In wmiDiskDrives
    Set wmiDiskPartitions = wmiServices.ExecQuery( _
    "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" _
         & wmiDiskDrive.DeviceID & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition")   

    For Each wmiDiskPartition In wmiDiskPartitions
        Set wmiLogicalDisks = wmiServices.ExecQuery _
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" _
             & wmiDiskPartition.DeviceID & "'} WHERE AssocClass = Win32_LogicalDiskToPartition")
        For Each wmiLogicalDisk In wmiLogicalDisks
        If wmiLogicalDisk.Caption = UCase(objArgs(0)) Then
        Set tx = fso.OpenTextFile(wmiLogicalDisk.Caption & "\report.inf", ForAppending, True)
          tx.Writeline("     Drive: " & wmiLogicalDisk.Caption)
          tx.Writeline("     Model: " & wmiDiskDrive.Model)
          tx.Writeline("     Type:  " & wmiDiskDrive.Description)
          tx.Writeline("     Vol:   " & wmiLogicalDisk.VolumeName)
          tx.Close
          End If
        Next 
    Next
Next

All previous instructions concerning passing the drive letter on the command line with the colon apply here also.

Get a copy of Scriptomatic. Not only can it help you write your scripts in VBScript, Perl, JScript or Python, but you can learn about the WMI classes.

Good luck 


Quote
is there anyway at all to make this script work propperly in a guest account..

As far as I know, only local Administrators have permission to ACCESS WMI. You could try using the runas command or perhaps Group Policy.

 

PS. Glad to hear the script is working for you.

what is the  runas command..??
what does it do..??
how to use it in my case..??Runas is a utility that allows you to run jobs under another user's credentials.

Type runas /? at a commnad prompt for full details.

Runas is a security breach in that passwords must be shared. Check out Group Policy which may offer a better solution.

Question: why does the guest account need to run this script?

 WELL basically im making a batch app to log what kind of devices get plugged into my public PC and then dump the infos into a file for later viewing. but I want it to work on my guest account though.. Quote from: gumbaz on July 01, 2008, 08:42:44 PM
well basically im making a batch app to log what kind of devices get plugged into my public PC and then dump the infos into a file for later viewing. but I want it to work on my guest account though..
the problem is how are you going to log anything if the guy plugs in and out the device before you execute your script? And when running such "monitoring" mechanism, why would you want to run it as guest, if you are the administrator? makes no sense.

USBs, CD and any kind of removable devices can be logged by utilities already created to do such stuff. If you want to do it from scratch, you may want to try configuring your PC to log such events (if possible) and write scripts to query the logs. Or you could write a script that MONITORS removable devices and run it as a service.


Discussion

No Comment Found