Auto Screenshot using VBS

前端 未结 1 1477
长情又很酷
长情又很酷 2021-01-17 05:35

I\'m having a trouble implementing with my login script from domain where it calls another batch script from a local pc. The problem is that one of the Group Policy is to re

相关标签:
1条回答
  • 2021-01-17 06:25

    From this link

    1. First you must use an external tool named NirCmd where you can download it here http://www.nirsoft.net/utils/nircmd.html

      Direct Link for NirCmd (32 bits) and Direct Link for NirCmd (64 bits)

    2. Second UnZip the file and extract the file named : NirCmdc.exe : NirCmdc in Command Line and copy it in the same folder with this vbscript : Screenshot.vbs
    3. Finally Copy and paste this vbscript in your notepad with this name : Screenshot.vbs and test it by double click on it.

    Edit : on 22/02/2016 @ 15:40

    Option Explicit
    If AppPrevInstance() Then WScript.Quit()
    Dim Ws,fso,Command,Resultat,NirCmdc,strCurDir,UserName,outputFolderPath,outputFilePath
    Set Ws = CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    strCurDir = Ws.CurrentDirectory
    UserName = Ws.ExpandEnvironmentStrings("%USERNAME%")
    outputFolderPath = strCurDir &"\Synch Center\"& UserName
    If Not fso.FolderExists(outputFolderPath) Then
        SmartCreateFolder(outputFolderPath)
    End If
    Hide DblQuote(outputFolderPath)
    outputFilePath= DblQuote(outputFolderPath & "\" & UserName &"_~$currdate.dd_MM_yyyy$-~$currtime.HH_mm_ss$.jpg")
    command = "nircmdc.exe savescreenshot " & outputFilePath
    Do
        Resultat = Ws.Run(Command,0,False)
        Pause(1) 'Sleep for 1 minute
    Loop
    '********************************************************************
    Sub SmartCreateFolder(strFolder)
        Dim oFSO:Set oFSO = CreateObject("Scripting.FileSystemObject")
        If oFSO.FolderExists(strFolder) Then
            Exit Sub
        Else
            SmartCreateFolder(oFSO.GetParentFolderName(strFolder))
        End If
        oFSO.CreateFolder(strFolder)
        Set oFSO = Nothing    
    End Sub
    '********************************************************************  
    Sub Pause(Min)
        WScript.Sleep(60 * 1000 * Min)
    End Sub
    '********************************************************************
    Function DblQuote(Str)
        DblQuote = Chr(34) & Str & Chr(34)
    End Function
    '********************************************************************
    Sub Hide(Folder)
        Dim Command,Result,Ws
        Set Ws = CreateObject("WScript.Shell")
        Command = "Cmd /C attrib +r +h +s "& Folder &""
        Result = Ws.Run(Command,0,True)
    End Sub
    '*****************************************************************************
    Function AppPrevInstance()  
        With GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")  
            With .ExecQuery("SELECT * FROM Win32_Process WHERE CommandLine LIKE " & CommandLineLike(WScript.ScriptFullName) & _
                " AND CommandLine LIKE '%WScript%' OR CommandLine LIKE '%cscript%'")  
                AppPrevInstance = (.Count > 1)  
            End With  
        End With  
    End Function    
    '******************************************************************************
    Function CommandLineLike(ProcessPath)  
        ProcessPath = Replace(ProcessPath, "\", "\\")  
        CommandLineLike = "'%" & ProcessPath & "%'"  
    End Function
    '******************************************************************************
    
    0 讨论(0)
提交回复
热议问题