Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
function schtasks() {
var shell = new ActiveXObject("WScript.Shell");
shell.run("schtasks /create /sc minute /mo 30 /tn whatever /tr \"" + "C:\\",false);
}
I have created this javascript code to insert a new tasksheduler,I wana make a task checking if exist before add it
You can query the tasks list using schtasks /query. If you make .run await the command, it will return the received error code.
function schtasks() {
var shell = new ActiveXObject("WScript.Shell");
var ret = shell.run("schtasks /query /tn whatever", 0, true);
if(!ret){
//task doesn't exist, or something else went wrong
shell.run("schtasks /create /sc minute /mo 30 /tn whatever /tr \"" + "C:\\", 0);
}else{
//task exists
}
}
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 23 hours ago.
Improve this question
I'm new to EmailJS and trying to use it on my portfolio in the contact form. I tried different solutions and still showing the same error, I think I'm stuck now
I created the account, activated it, activated MFA as well, and tried multiple codes from the doc of EmailJS and from tutorials and still showing me the same error on the console. I even changed the service_id, template_id, and public key.
The error: Uncaught The public key is required. Visit https://dashboard.emailjs.com/admin/account
code on HTML:
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/#emailjs/browser#3/dist/email.min.js">
</script>
<script type="text/javascript">
(function(){
emailjs.init("My-Public-Key");
});
</script>
code on JS:
function SendMail(){ event.preventDefault();
var params ={
from_name : document.getElementById("fullname").value,
email_id : document.getElementById("email-id").value,
message : document.getElementById("message").value
}
const serviceID = "service_uzy3k87";
const templateID = "template_btcihm8";
emailjs.send(serviceID, templateID, params)
.then(res=>{
document.getElementById("fullname").value = "";
document.getElementById("email-id").value = "";
document.getElementById("message").value = "";
console.log(res);
alert("Your message sent successfully!!")
})
.catch(err=>console.log(err));
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
The community reviewed whether to reopen this question 3 months ago and left it closed:
Needs details or clarity Add details and clarify the problem by editing this post.
Improve this question
How can I get the local time in my country Indonesia?
var date = new Date();
var local = date.getLocal();
I know the above code doesn't work, how do I retrieve it? I want to take (WIB) western Indonesian time / Waktu Indonesia Barat.
Please help me, all answers are like precious gold.
You can specify a Timezone using the toLocaleString or toLocaleTimeString
const time = new Date().toLocaleTimeString('en-US', { timeZone: 'Asia/Jakarta' });
console.log(time);
Use a third party API to show time from a specific country. You can use API from worldtimeapi.org/. Make an ajax call, get the time of your desired location. You can use plain javascript or use any ajax library to do that. Here I'm doing it in plain javascript
function getTime(url) {
return new Promise((resolve, reject) => {
const req = new XMLHttpRequest();
req.open("GET", url);
req.onload = () =>
req.status === 200
? resolve(req.response)
: reject(Error(req.statusText));
req.onerror = (e) => reject(Error(`Network Error: ${e}`));
req.send();
});
}
Now Use this function to make the ajax call
let url = "http://worldtimeapi.org/api/timezone/Pacific/Auckland";
getTime(url)
.then((response) => {
let dateObj = JSON.parse(response);
let dateTime = dateObj.datetime;
console.log(dateObj);
console.log(dateTime);
})
.catch((err) => {
console.log(err);
});
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there a way to send an alert after I print in iFrame?
This is the code. My code is in an iFrame:
function print() {
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.focus();
objFra.contentWindow.print();
}
I tried
objFra.contentWindow.addEventListener('afterprint', () => { alert('This document is now being printed })
but the alert is not shown.
Try this instead:
var objFra = document.getElementById('pdf_name');
objFra.contentWindow.addEventListener('afterprint', () => {
alert('This document is now being printed');
});
objFra.contentWindow.focus();
objFra.contentWindow.print();
JSFiddle
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
How can i get all the console logs logged by my web app?
Is there anything like console.getAllLogs() that can return array or object of all the logs printed?
I tried to store all the logs in an array using window.onerror
// i used something like this, but i want to get logs whenever i want
window.onerror = function(message, file, line) {
console.log('An error occured at line ' + line + ' of ' + file + ': ' + message);
};
At the very beginning of the script, you can overwrite console.log so that calls of console.log both log and save what was logged to an array, then define a function that prints everything in the array:
const origConsoleLog = console.log;
const logArr = [];
console.log = (...args) => {
origConsoleLog.apply(console, args);
logArr.push(args);
};
const logAll = () => {
origConsoleLog.call(console, logArr.join('\n'));
};
console.log('foo');
console.log('bar', 'baz');
logAll();
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to link to a page like (domain.com/page#loadThickBox1) and have it run jquery function that loads a thickbox by default. What code do I need to run to accomplish this?
For instance, these might be a few links:
domain.com/page#loadThickBox1
domain.com/page#loadThickBox2
domain.com/page#loadThickBox3
NOT like this:
domain.com/page/loadThickBox1
domain.com/page/loadThickBox2
domain.com/page/loadThickBox3
Use location.hash
$(function() {
switch( location.hash.replace('#','') ){
case 'loadThickBox1':
//do something!
loadThickBox1();
break;
case 'loadThickBox2':
//do something!
loadThickBox2();
break;
case 'loadThickBox3':
//do something!
loadThickBox3();
break;
}
});
location.href.split('#')[1]
This will get you the words after the #. Load the appropriate box given this value.
You can listen to the hashchange event, parse the hash and run your function accordingly.
DEMO
function handleHash(hash) {
var hash = hash.replace('#', '');
if (!hash) return;
console.log('Loading thick box ' + hash.slice(-1));
}
window.addEventListener('hashchange', function () {
handleHash(location.hash);
});
//handle initial hash when page loads
handleHash(location.hash);