Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: copy names & info from disk drives to a .txt file  (Read 12971 times)

0 Members and 1 Guest are viewing this topic.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: copy names & info from disk drives to a .txt file
« Reply #15 on: June 30, 2008, 07:03:09 PM »
would the fsutil command return excess information?
Code: [Select]
fsutil fsinfo volumeinfo C:\   (or d, or E...)
I was trying to dereference Null Pointers before it was cool.

gumbaz

    Topic Starter


    Intermediate

    Re: copy names & info from disk drives to a .txt file
    « Reply #16 on: July 01, 2008, 04:24:47 AM »
    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..???


    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  8)



    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: copy names & info from disk drives to a .txt file
    « Reply #17 on: July 01, 2008, 05:41:17 AM »
    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.

     8)

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

    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    gumbaz

      Topic Starter


      Intermediate

      Re: copy names & info from disk drives to a .txt file
      « Reply #18 on: July 01, 2008, 06:22:58 PM »
      what is the  runas command..??
      what does it do..??
      how to use it in my case..??

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: copy names & info from disk drives to a .txt file
      « Reply #19 on: July 01, 2008, 07:23:09 PM »
      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?

       8)
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      gumbaz

        Topic Starter


        Intermediate

        Re: copy names & info from disk drives to a .txt file
        « Reply #20 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..???

        ghostdog74



          Specialist

          Thanked: 27
          Re: copy names & info from disk drives to a .txt file
          « Reply #21 on: July 01, 2008, 09:15:09 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.