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 12884 times)

0 Members and 1 Guest are viewing this topic.

gumbaz

    Topic Starter


    Intermediate

    copy names & info from disk drives to a .txt file
    « on: June 26, 2008, 12:24:08 AM »
    I want to copy the drive letter, drive name, and the hardware name of a disk drive over into a .txt file...
    how can i do this with batch code..??

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: copy names & info from disk drives to a .txt file
    « Reply #1 on: June 26, 2008, 12:47:24 AM »
    You can get the drive letter by using echo %cd:~0,3% but how do you find the drive name and hardware name?

    To export this to a text file, try this: (example)

    Code: [Select]
    echo %cd:~0,3% >>"C:\Documents and settings\%username%\desktop\file.txt"

    gumbaz

      Topic Starter


      Intermediate

      Re: copy names & info from disk drives to a .txt file
      « Reply #2 on: June 26, 2008, 01:22:09 AM »
      drive name is "USB"
      Hardware name is "SanDisk U3 Cruzer Micro USB Device"
      is there anyway to copy those names into the .txt file as well..??

      Carbon Dudeoxide

      • Global Moderator

      • Mastermind
      • Thanked: 169
        • Yes
        • Yes
        • Yes
      • Certifications: List
      • Experience: Guru
      • OS: Mac OS
      Re: copy names & info from disk drives to a .txt file
      « Reply #3 on: June 26, 2008, 03:58:36 AM »
      I don't think you can do this, at least not with Command Prompt (batch).

      gumbaz

        Topic Starter


        Intermediate

        Re: copy names & info from disk drives to a .txt file
        « Reply #4 on: June 26, 2008, 11:49:44 PM »
        any way to do it with vbs or something similar ..??

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: copy names & info from disk drives to a .txt file
        « Reply #5 on: June 27, 2008, 04:49:46 AM »
        The information you're seeking is scattered throughout the registry which you should be able to enumerate providing you know the registry keys. An easier way would be a VBScript with the WMI classes as a framework.

        Code: [Select]
        On Error Resume Next

        Const wbemFlagReturnImmediately = &h10
        Const wbemFlagForwardOnly = &h20

        strComputer = "."
        Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
        Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)
        For Each objItem In colItems
          WScript.Echo "Caption: " & objItem.Caption
          WScript.Echo "Description: " & objItem.Description
          WScript.Echo "Model: " & objItem.Model
          WScript.Echo "Name: " & objItem.Name
          WScript.Echo
        Next

        Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_CDROMDrive", "WQL", _
                                       wbemFlagReturnImmediately + wbemFlagForwardOnly)
        For Each objItem In colItems
          WScript.Echo "Caption: " & objItem.Caption
          WScript.Echo "Description: " & objItem.Description
          WScript.Echo "Manufacturer: " & objItem.Manufacturer
          WScript.Echo "Name: " & objItem.Name
        Next

        Save the script with a VBS extension and run at the command prompt as: cscript scriptname.vbs Use redirection if you need the output in a file: cscript //nologo scriptname.vbs > report.txt

         8)

        « Last Edit: June 27, 2008, 05:09:20 AM by Sidewinder »
        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 #6 on: June 27, 2008, 03:51:11 PM »
          SWEET, THANKS A MILLION..!!!  ;D

          But how would i use this to copy only the info from one specific drive into a .txt file..??

          and also is there any way to put some more .vbs code in there to copy over the UserName, ComputerName, and a Date + Time-Stamp into the .txt file..??

          Ex:
          Code: [Select]
          UserName__ComputerName__2008_06_27__09.52.07---Fri
          DEVICE: SanDisk U3 Cruzer Micro USB Device
          TYPE: Disk drive
          Model: SanDisk U3 Cruzer Micro USB Device
          Name: \\.\PHYSICALDRIVE1

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: copy names & info from disk drives to a .txt file
          « Reply #7 on: June 27, 2008, 04:38:36 PM »
          To specifically filter a device, use the WHERE clause on the query:

          Code: [Select]
          On Error Resume Next

          Const wbemFlagReturnImmediately = &h10
          Const wbemFlagForwardOnly = &h20

          Set WshShell = CreateObject("Wscript.Shell")
          Username = WshShell.ExpandEnvironmentStrings("%Username%")
          Compname = WshShell.ExpandEnvironmentStrings("%Computername%")

          strComputer = "."
          Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
          Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive Where Model = 'SanDisk U3 Cruzer Micro USB Device'", "WQL", _
                                         wbemFlagReturnImmediately + wbemFlagForwardOnly)

          WScript.Echo Username & "__" & Compname & "__" & Date & "__" & Time
          For Each objItem In colItems
            WScript.Echo "Caption: " & objItem.Caption
            WScript.Echo "Description: " & objItem.Description
            WScript.Echo "Model: " & objItem.Model
            WScript.Echo "Name: " & objItem.Name
            WScript.Echo
          Next

          Check out the Scriptomatic which can assist you in writing WMI scripts.

           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 #8 on: June 27, 2008, 06:11:13 PM »
            thanks again for the help.
            but in the situation that im going to be using this code in, i wont really be able to specifically filter a device, because my batch app searches for available drives on the PC and then once they're all found i want it to copy the user-name, computer-name, time-stamp & device info all over into a .txt file into the root of each specific drive. so each drive found will have a report.txt sent the root of its drive with only its corresponding drive info inside it and not any of the other drives infos..

            this is just a ruft draft template of how i hope to do this..
            im pretty sure it wont work this way, but could you please help me edit it to make it work propperly. thanks.

            there 2 .vbs files im using in conjuction with my batch code they are: drivetype.vbs & DriveInfo.vbs..
            drivetype.vbs  is used with the batch code to find all avaible dives on the pc.
            DriveInfo.vbs is the code you gave me to copy the drive infos over into a .txt file.

            Code: [Select]
            DriveType.vbs
            -------------------------------------------------------------------------
            Option Explicit
            Dim filesys,Drives,DriveLetter,DriveType,DiskDrive,drtype
            set filesys = CreateObject("Scripting.FileSystemObject")
            For Each DiskDrive in filesys.Drives
            DriveLetter = DiskDrive.DriveLetter
            DriveType = DiskDrive.DriveType
            select case DriveType
                case 0: drtype = "Unknown"
                case 1: drtype = "Removable"
                case 2: drtype = "Fixed"
                case 3: drtype = "Network"
                case 4: drtype = "CD-ROM"
                case 5: drtype = "RAM Disk"
            end Select
            WScript.Echo "Drive "&DriveLetter &" is :" &drtype
            Next

            -----------------------------------------------------------------------
            -----------------------------------------------------------------------
            DriveInfo.vbs
            -----------------------------------------------------------------------
            On Error Resume Next

            Const wbemFlagReturnImmediately = &h10
            Const wbemFlagForwardOnly = &h20

            Set WshShell = CreateObject("Wscript.Shell")
            Username = WshShell.ExpandEnvironmentStrings("%Username%")
            Compname = WshShell.ExpandEnvironmentStrings("%Computername%")

            strComputer = "."
            Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
                                           wbemFlagReturnImmediately + wbemFlagForwardOnly)
            For Each objItem In colItems
              WScript.Echo "Device: " & objItem.Caption
              WScript.Echo "Type: " & objItem.Description
              WScript.Echo "Model: " & objItem.Model
              WScript.Echo "Name: " & objItem.Name
              WScript.Echo
            Next

            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_CDROMDrive", "WQL", _
                                           wbemFlagReturnImmediately + wbemFlagForwardOnly)

            WScript.Echo Username & "__" & Compname & "__" & Date & "__" & Time
            For Each objItem In colItems
              WScript.Echo "Device: " & objItem.Caption
              WScript.Echo "Type: " & objItem.Description
              WScript.Echo "Manufacturer: " & objItem.Manufacturer
              WScript.Echo "Name: " & objItem.Name
            Next
            ----------------------------------------------------------------------------
            ----------------------------------------------------------------------------
            BATCH CODE APP
            ----------------------------------------------------------------------------

            CD %SYSTEMDRIVE%

            for /f "tokens=1,2,3,4,5,6 delims=: " %%A in ('cscript /nologo DriveType.vbs') do (

               if "%%D"=="Fixed" (

             Echo Copying Info To "FIXED DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt

                  )

               if "%%D"=="CD-ROM" (
                 
             Echo Copying Info To "CD-ROM DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt

                  )

               if "%%D"=="Removable" (
                 
             Echo Copying Info To "REMOVABLE DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt

                  )

               if "%%D"=="Network" (
                 
             Echo Copying Info To "NETWORK DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt
                 
                  )

               if "%%D"=="Unknown" (
                 
             Echo Copying Info To "UNKNOWN DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt
                 
                  )

               if "%%D"=="RAM Disk" (
                 
             Echo Copying Info To "RAM DISK DRIVE" %%B:\
            cscript //nologo DriveInfo.vbs > %%B:\report.txt
                 
                  )
            )

            so what needs to be fixed..??

            Sidewinder



              Guru

              Thanked: 139
            • Experience: Familiar
            • OS: Windows 10
            Re: copy names & info from disk drives to a .txt file
            « Reply #9 on: June 27, 2008, 08:09:54 PM »
            Using the Win32_DiskDrive class gets you all the properties of each physical device, but you seem to want the data for each logical device.

            This little snippet uses the Win32_LogicalDisk class for which I cherry picked some fields for your report. Feel free to change them.

            Code: [Select]
            Const wbemFlagReturnImmediately = &h10
            Const wbemFlagForwardOnly = &h20
            Const ForWriting = 2


            Set WshShell = CreateObject("Wscript.Shell")
            Username = WshShell.ExpandEnvironmentStrings("%Username%")
            Compname = WshShell.ExpandEnvironmentStrings("%Computername%")

            strComputer = "."

            Set fso = CreateObject("Scripting.FileSystemObject")
            Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
            Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk Where DriveType <> '5'", "WQL", _
                                             wbemFlagReturnImmediately + wbemFlagForwardOnly)

            For Each objItem In colItems
               Set tx = fso.OpenTextFile(objItem.Caption & "\report.txt",ForWriting,True)
               tx.WriteLine(Username & "__" & Compname & "__" & Date & "__" & Time)
               tx.WriteLine("Caption: " & objItem.Caption)
               tx.WriteLine("Description: " & objItem.Description)
               tx.WriteLine("DriveType: " & objItem.DriveType)
               tx.Writeline("VolumeName: " & objItem.VolumeName)
               tx.Close
            Next

            Note: CD drive has been filtered out...VBScript cannot do packet writing.

            The script is self-contained and will write each report to the proper drive. Should you need data from the Win32_DiskDrive class, we may have to rewrite this with associators.

             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 #10 on: June 27, 2008, 10:39:29 PM »
              im getting this error when i run it

              gumbaz

                Topic Starter


                Intermediate

                Re: copy names & info from disk drives to a .txt file
                « Reply #11 on: June 28, 2008, 12:49:32 AM »
                is there anyway to just specify a drive letter variable in the batch code app then have the DriveInfo.vbs read from that drive letter variable and then just get only the drive infos for that specific drive-device and then copy that info into a .txt file in the root of that specific drive. instead of having it do it for all of the drive-devices at once.

                i need it to copy only the infos of the drive i specify inside the batch code app.
                how can i do that..??

                Sidewinder



                  Guru

                  Thanked: 139
                • Experience: Familiar
                • OS: Windows 10
                Re: copy names & info from disk drives to a .txt file
                « Reply #12 on: June 28, 2008, 06:25:19 AM »
                I cannot reproduce the error, so you'll need to debug the script at your end.

                Quote
                Using the Win32_DiskDrive class gets you all the properties of each physical device, but you seem to want the data for each logical device.

                Quote
                is there anyway to just specify a drive letter variable in the batch code app then have the DriveInfo.vbs read from that drive letter variable and then just get only the drive infos for that specific drive-device and then copy that info into a .txt file in the root of that specific drive. instead of having it do it for all of the drive-devices at once.

                The DriveInfo script cannot select by drive letter. There is no drive letter property in the Win32_DiskDrive class. In order to pull info from multiple classes, you need to associate each class via a common field; in this case by way of the Win32_DiskDriveToDiskPartition and Win32_LogicalDiskToPartition classes. (Think: Six Degrees Of Separation)

                Having two scripts and a batch file only complicates matters. The idea is to keep it simple relatively simple.

                Code: [Select]
                Const ForWriting = 2

                strComputer = "."

                Set objArgs = WScript.Arguments
                Set fso = CreateObject("Scripting.FileSystemObject")
                Set wmiServices  = GetObject ("winmgmts:{impersonationLevel=Impersonate}!//" & strComputer)
                Set wmiDiskDrives =  wmiServices.ExecQuery ("SELECT Caption, DeviceID, Model, Description, Name 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 UCase(wmiLogicalDisk.Caption) = UCase(objArgs(0)) Then
                           Set tx = fso.OpenTextFile(wmiLogicalDisk.Caption & "\report.txt", ForWriting, True)
                             tx.Writeline("     Drive: " & wmiLogicalDisk.Caption)
                             tx.Writeline("     Model: " & wmiDiskDrive.Model)
                             tx.Writeline("     Type:  " & wmiDiskDrive.Description)
                             tx.Writeline("     Name:  " & wmiDiskDrive.Name)
                             tx.Close
                                End If
                        Next 
                    Next
                Next

                Pass the drive letter along the command line: cscript scriptname.vbs driveletter:
                You must include the colon with the drive letter.

                You can change the script to prompt for the drive at the command line or through an input box, but the main line logic is correct.

                Good luck.  8)

                FYI: you could have simplified your batch file with:

                Code: [Select]
                @echo off
                cd %systemdrive%
                for /f "tokens=1-4 delims=: " %%a in ('cscript //nologo drivetype.vbs') do (
                  echo copying info to %%d %%b:\
                cscript //nologo driveinfo.vbs > %%b:\report.txt
                  )
                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 #13 on: June 28, 2008, 06:45:02 PM »
                  Thanks Again for the help.. I really appreciate it..

                  Your BAT Code didn't seem to work right for me so i tweaked it to this:
                  Code: [Select]
                  CD %SYSTEMDRIVE%
                  for /f "tokens=1,2,3,4,5,6 delims=: " %%A in ('cscript /nologo DriveType.vbs') do (

                     if "%%D"=="Fixed" (

                   Echo Copying Info To "FIXED DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:

                        )

                     if "%%D"=="CD-ROM" (
                       
                   Echo Copying Info To "CD-ROM DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:

                        )

                     if "%%D"=="Removable" (
                       
                   Echo Copying Info To "REMOVABLE DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:

                        )

                     if "%%D"=="Network" (
                       
                   Echo Copying Info To "NETWORK DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:
                       
                        )

                     if "%%D"=="Unknown" (
                       
                   Echo Copying Info To "UNKNOWN DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:
                       
                        )

                     if "%%D"=="RAM Disk" (
                       
                   Echo Copying Info To "RAM DISK DRIVE" %%B:\
                  cscript driveinfo.vbs %%B:
                       
                        )
                  )
                  theres just a few things now that  I want to change though..
                  in this line in the "DriveInfo.vbs"
                  Code: [Select]
                  Set tx = fso.OpenTextFile(wmiLogicalDisk.Caption & "\report.txt", ForWriting, True)how can i change it to write the drive infos into a .INF file and also not overwrite any existing text thats in that .INF file but rather write the Drive INFOs below the text thats already existing in that .INF file.. can that be done at all..??

                  and also, is there a way to use the "Volume Lable Name" in place where the:
                  "Name:  \\.\PHYSICALDRIVE1"  is..??

                  Sidewinder



                    Guru

                    Thanked: 139
                  • Experience: Familiar
                  • OS: Windows 10
                  Re: copy names & info from disk drives to a .txt file
                  « Reply #14 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  8)

                  The true sign of intelligence is not knowledge but imagination.

                  -- Albert Einstein

                  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.