Jump to content

New to VBS Script


Recommended Posts

:D

I'am now to VBS scripting and need a little. A trying to figure of how to pull back what domain a machine is currently on using VBS. I know how to pull back which domain the script ran but that is not what I need. I need to I dentify what domain the machine belongs to then execute another process based on that.

Thank in advance

Link to comment
Share on other sites


That would work, but the information is not showing up in WMI.

You can have it output messages if you want. You just have to place

them in the right spot. Here is a vbs script that you type in the extention

to list all the files with that extention. It uses the WMI to search all local

hard drives. It produces a report of the all files with the extention and

there location.

Dim Act : Set Act = CreateObject("Wscript.shell")

Sd = Act.ExpandEnvironmentStrings("%systemdrive%")

Ftype = InputBox("Type In The File Extention Of The The file Type That You Want To Search For" & vbCrlf & vbCrlf & "This Can Take A Few Minutes To Complete, The Time It Take To Complete Depends, On How Large The Drives Are And How Many Files There Are Of The Type You Input." & vbCrlf & VbCrlf & "Example = BMP or bmp" & space(3) & "DLL or dll" & space(3) & "EXE or exe" & Vbcrlf & "No Period Is Needed For The Extentions","Gsm List File Type")

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colFiles = objWMIService.ExecQuery _

    ("Select * from CIM_DataFile Where Extension = '" & Ftype & "'")

If colFiles.Count = 0 Then

Act.popup "There Was No File Found With That extention", 5, "No File Found", 0 + 64

    Wscript.Quit

End If

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.CreateTextFile(Sd & "\" & Ftype & ".txt")

For Each objFile in colFiles

    objTextFile.Write("-----------------------------------------" & vbCrlf & objFile.Drive & objFile.Path)

    objTextFile.Write(objFile.FileName & "." & objFile.Extension & vbCrLf & "File Size=")

    objTextFile.Write(objFile.FileSize & vbCrLf & "-----------------------------------------" & vbCrlf)

Next

objTextFile.Close

Act.Popup "Completed The Script", 4, "List All The " & Ftype, 0 + 32

Act.run (SD & "\" & Ftype & ".txt"),1,True

A1 = Act.Popup("Would You Like To Keep The File" & vbCrLf & "Would You Like To Delete The File" & vbCrLf & "Yes To Keep The File" & vbCrLf & "No To Delete The file" & vbCrLf & "Defualt Time Out Action Is To Keep The File", 7, "Keep Or Delete", 4 + 32)

If A1 = 6 Then

Act.popup "Keeping The File" & vbCrLf & Ftype & ".txt", 4, "User Save" & Space(5) & Ftype & ".txt", 0 +32

End If

If A1 = 7 Then

CreateObject("Scripting.FileSystemObject").deletefile(Sd & "\" & Ftype & ".txt")

Act.popup "User Selected To Delete The File" & vbCrLf & Sd & "\" & Ftype & ".txt", 4, "User Deleted" & Space(5) & Ftype & ".txt", 0 +32

end If

If A1 = -1 Then

Act.popup "Time Out Occur Performing The Defualt Action" & vbCrlf & "Keeping The " & Sd & "\" & Ftype & ".txt", 4, "Keeping" & Space(5) & Ftype & ".txt", 0 +32

End If

On Error resume Next

CreateObject("Scripting.FileSystemObject").deletefile(Sd & "\ListFile.vbs")

Edited by gunsmokingman
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...