MSFN Forum: New to VBS Script - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

New to VBS Script VBS Script question Rate Topic: -----

#1 User is offline   blkpawns 

  • Group: Members
  • Posts: 2
  • Joined: 08-August 05

Posted 08 August 2005 - 10:52 AM

: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


#2 User is offline   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 08 August 2005 - 11:51 AM

Sounds like you need to use WMI
Here is a link to The Hey, Scripting Guy! they may have a script that may do what you want.

#3 User is offline   blkpawns 

  • Group: Members
  • Posts: 2
  • Joined: 08-August 05

Posted 09 August 2005 - 08:41 AM

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

#4 User is offline   gunsmokingman 

  • MSFN Addict
  • Group: Super Moderator
  • Posts: 1,991
  • Joined: 02-August 03
  • OS:none specified
  • Country: Country Flag

Posted 09 August 2005 - 12:25 PM

blkpawns, on Aug 9 2005, 03:41 PM, said:

That would work, but the information is not showing up in WMI.
<{POST_SNAPBACK}>

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.

Quote

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

This post has been edited by gunsmokingman: 10 August 2005 - 02:32 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy