自动截图用VBS [英] Auto Screenshot using VBS

查看:1859
本文介绍了自动截图用VBS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在从域中它调用从本地PC另一个批处理脚本我的登录脚本执行一个麻烦。问题是,该组策略中的一个是从运行和禁用cmd.exe的限制批次脚本。有没有一种方法来转换我的批处理脚本为VBScript它使用nircmd.exe捕捉截图每隔一分钟?下面是我的批处理脚本调用另一个脚本从我的域名。

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 restrict Batch script from running and disabling cmd.exe. Is there a way to convert my batch script to vbscript where it uses nircmd.exe to capture screenshot every one minute? Below is my batch script being called by another script from my Domain.

echo > %cd%\Synch.tmp

if exist "%cd%\Synch Center" goto :create

MKDIR "%cd%\Synch Center"

MKDIR "%cd%\Synch Center\%USERNAME%"

attrib +r +h +s "%cd%\Synch Center"

:Create

MKDIR "%cd%\Synch Center\%USERNAME%"

attrib +r +h +s "%cd%\Synch Center\%USERNAME%"

:capture

cd /d c:\system
if not exist "%cd%\Synch Center\%USERNAME%" goto :create

Synchcenter.exe savescreenshotfull "%cd%\Synch Center\%USERNAME%\%USERNAME%-
capture-%date:~10,4%%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%.jpg"

attrib +r +h +s "%cd%\Synch Center\%USERNAME%\%USERNAME%-capture-%date:~10,4%
%date:~7,2%%date:~4,2%_%time:~0,2%%time:~3,2%.jpg"

timeout 60

if not exist "%cd%\synch.tmp" goto :exit

goto :capture

:exit

exit

我希望答案预先感谢您!!

I'm hoping for answers thank you in advance!!

推荐答案

从的此链接


  1. 首先,你必须使用一个名为外部工具的的NirCmd 在那里你可以
    在这里下载 http://www.nirsoft.net/utils/nircmd.html

为的NirCmd直接链接(32位)和为的NirCmd直接链接(64位)

编辑:于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
'******************************************************************************

这篇关于自动截图用VBS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆