Answer the question
In order to leave comments, you need to log in
How to lock a file in JScript(WSH)?
I want to block the file with parameters for the execution time, so that when accessing it, access is denied. Tried like this:
var fso = new ActiveXObject('Scripting.FileSystemObject');
var Lockeds = new ActiveXObject("Scripting.Dictionary");
function LockFile(path) {
if (!Lockeds.Exists(path)) {
//открываю указанный файл в режиме добавления содержимого, и не закрываю его
Lockeds.Add(path, fso.OpenTextFile(path, 8));
}
}
function UnLockFile(path) {
if (Lockeds.Exists(path)) {
//Закрываю файл
Lockeds.Item(path).Close();
Lockeds.Remove(path);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question