Scriptin’ 4

 
 
How to pushVNC on a remote computer with enabled (managed) windows firewall
Jak push ‘Nout’ VNC na vzdálenou stanici se zapnutým (řízeným) firewallem
 
 
 
‘ Lze spustit, resp. vypnout pouze lokalne
 
Set objFirewall = CreateObject("HNetCfg.FwMgr")
Set objPolicy = objFirewall.LocalPolicy.CurrentProfile
objPolicy.FirewallEnabled = FALSE
_______________________________________________
‘ Nakopíruj soubor
 
Const ForReading = 1
Const OverwriteExisting = TRUE
strComputer = "stanice-001"
Set objFSO = CreateObject("Scripting.FileSystemObject")
strRemoteFile = "\\" & strComputer & "\C$\script.vbs"
    objFSO.CopyFile "D:\Scripts\script.vbs", strRemoteFile, OverwriteExisting
___________________________________________________________________
‘ Spust hidden job z naplanovanych uloh
 
strComputer = "stanice-001"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create _
    ("wscript.exe c:\script.vbs", "20080725092700.000000+120", _
        False, 0, , True, JobID)
‘ False indikuje, ze job se nebude opakovat       
‘ pokud prepisu 0 na 1 tak job probehne ve stanoveny cas a pak jeste v pondeli, 2 ut. atd.
‘ True indikuje, ze job ma probehnout hidden
________________________________________________________________________________
 
 

 

 

Scriptin’ 3

 
Služby, Services, Servisy atd.
 
 
‘ Start AutoStart Services that have Stopped
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
    ("Select * from Win32_Service Where State = ‘Stopped’ and StartMode = " _
        & "’Auto’")
For Each objService in colListOfServices
    objService.StartService()
Next
_____________________________________________________________________________________________________________________________________
 
‘ Stop Service
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
strServiceName = "Service Name"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name =’" & strServiceName & "’")
For Each objService in colListOfServices
    objService.StopService()
Next
Loop
___________________________________________________________________________________________________________
‘ Start Service
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
strServiceName = "Service Name"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name =’" & strServiceName & "’")
For Each objService in colListOfServices
    objService.StartService()
Next
Loop
________________________________________________________________________________
  Service name? :

Scriptin’ 2

 
 
‘********************************* ***
‘ Zjisti velikost vsech *.pst souboru na disku C:\
‘********************************* ***
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = ‘pst’ AND Drive = ‘C:’")
For Each objFile in colFiles
    ObjOutputFile.WriteLine objFile.Drive & objFile.Path
    ObjOutputFile.WriteLine objFile.FileName & "." & objFile.Extension
    ObjOutputFile.WriteLine objFile.FileSize / (1024 ^ 2)  & " MB" & vbNewLine
   
Next
Loop
______________________________________________________________________________
‘**************************************** *******
‘ Zjisti velikost vsech *.pst souboru na disku C:\ Podle IP
‘**************************************** *******
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
intStartingAddress = 1
intEndingAddress = 254
strSubnet = "192.168.1."
For i = intStartingAddress to intEndingAddress
    strComputer = strSubnet & i
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_DataFile Where Extension = ‘pst’ AND Drive = ‘C:’")
For Each objFile in colFiles
    ObjOutputFile.WriteLine objFile.Drive & objFile.Path
    ObjOutputFile.WriteLine objFile.FileName & "." & objFile.Extension
    ObjOutputFile.WriteLine objFile.FileSize / (1024 ^ 2)  & " MB" & vbNewLine
 
Next
Next
 
______________________________________________________________________________
‘******************** ***
‘ One folder size, attributes
‘ ******************** ***
On Error Resume Next
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("comps.txt", 1, True)
Set objOutputFile = fso.OpenTextFile("vystup.txt", 8, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.ReadLine
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\folder\")
ObjOutputFile.WriteLine "Date created: " & objFolder.DateCreated
ObjOutputFile.WriteLine "Date last accessed: " & objFolder.DateLastAccessed
ObjOutputFile.WriteLine "Date last modified: " & objFolder.DateLastModified
ObjOutputFile.WriteLine "Size: " & objFolder.Size /(1024*1024*1024) & " GB"
Loop