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
From this link
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)
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
'******************************************************************************