我一直在研究一个程序,它要求使用Node.JS重新启动某个应用程序 我知道Python可以关闭另一个应用程序,但是Node.JS可以吗?
例如,如果某个函数被触发,我需要它从Node.JS进程中关闭Spotify。
谢谢!
答案 0 :(得分:2)
https://nodejs.org/api/process.html#process_process_kill_pid_signal
protected void btnsign_signup_Click(object sender, EventArgs e) { if (Page.IsValid) { Users u1 = new Users(); if (u1.Username.Contains(txtSignname.Text)) { txtSignname.Text = "This Name has already Taken"; } else if(u1.Email.Contains(txtsigneamil.Text)) { txtsigneamil.Text = "This Email has already Taken"; } else { db.Sp_InsertnewUser(txtSignname.Text, txtsignpass.Text, txtsigneamil.Text); db.SaveChanges(); Response.Redirect("Home.aspx"); } }
方法将var x = new Date(1960,07,16); var y = new Date(1950,04,28); var z = new Date(1940,01,07); var playerData = [ {name: "John", date: x.getTime()}, {name: "Bill", date: y.getTime()}, {name: "Greg", date: z.getTime()}, ]; function findHighScore() { var highDateSoFar = null; var result; for (var i = 0; i < playerData.length; i++) { if (playerData[i].date > highDateSoFar) { result = playerData[i]; highDateSoFar = playerData[i].date; } else if (playerData[i].date === highDateSoFar) { result = 'equal'; } } return result; } var highPlayer = findHighScore(); var highPlayerName = highPlayer.name; var highPlayerDate = highPlayer.date; var highPlayerIndex = playerData.indexOf(highPlayer); console.log({highPlayer});
发送到process.kill(pid[, signal])
所标识的进程。
当然,这假设您已经知道要结束的进程的pid。如果不这样做,则必须首先find it。