D
Deno

help

Deno.Command not working for application

DDNA5/23/2023
Hello. Im trying to start an application using Deno.Command, but it for some reason doesnt work. The path itself functions normally even from powershell.
// Get the application to start
const application = body.application?.trim()?.replace(/\\/g, "/");
if (!application) return new Response(JSON.stringify({message: "error", error: "noApplication"}), {status: Status.BadRequest, headers: {"Content-Type": "text/json"}});

// If there is a space in the application, surround it with quotes
console.log(application);

const command = new Deno.Command(`${application}`, {stdin: "null"});

// Return the user the code and the time it took to execute
const start = performance.now();
const results = await command.output();
const end = performance.now();

return new Response(JSON.stringify({message: "success", code: results.code, time: end - start}), {status: Status.OK, headers: {"Content-Type": "text/json"}});
// Get the application to start
const application = body.application?.trim()?.replace(/\\/g, "/");
if (!application) return new Response(JSON.stringify({message: "error", error: "noApplication"}), {status: Status.BadRequest, headers: {"Content-Type": "text/json"}});

// If there is a space in the application, surround it with quotes
console.log(application);

const command = new Deno.Command(`${application}`, {stdin: "null"});

// Return the user the code and the time it took to execute
const start = performance.now();
const results = await command.output();
const end = performance.now();

return new Response(JSON.stringify({message: "success", code: results.code, time: end - start}), {status: Status.OK, headers: {"Content-Type": "text/json"}});
Aabi5/23/2023
Are you trying to execute a Windows shortcut? Lol you can’t do that. You need an executable.
DDNA5/23/2023
Its an .lnk Idk if thats exactly what you mean In node that previously did work perfectly fine with .lnk's
LLeokuma5/23/2023
Running a shortcut might work if you pass powershell.exe or cmd.exe as the executable for Deno.Command and the lnk file as the argument
DDNA5/23/2023
That works, thank you very much
LLeokuma5/23/2023
You can also consider use this to simplify running the commands: https://github.com/dsherret/dax
GitHub
GitHub - dsherret/dax: Cross platform shell tools for Deno inspired...
Cross platform shell tools for Deno inspired by zx. - GitHub - dsherret/dax: Cross platform shell tools for Deno inspired by zx.

Looking for more? Join the community!

Recommended Posts
Uint8Array or Float32ArrayIs there any significant difference between using a Float32Array and using a Uint8Array from the samSending proper Content-Type depending on file sentHello. Im new to Deno and TypeScript and i wanted to convert one of my older projects (NodeJs and JaReclaim an already registered module?Is it possible to reclaim an already registered third party module? For example if the module that iDeno.readDir on current script even if used like an http package.Hello !! I would like to do Deno.readDir and readFiles on files relative to the script that execute Top level awaits for `import()`How come to top-level awaits for `import()` not work? I found an issue on GitHub https://github.com/How to auto import on save?This doesn't work: { "deno.enable": true, "deno.lint": true, "deno.unstable": true, "editorRemove sink from streamIs it at all possible to "undo" adding a sink on a stream? I am trying to make it so that once the wHTTPS w/ client certificate – works in Node.js, not in DenoI am making an HTTPS call with a client certificate. It works great in Node.js, but when I try to doUsing encrypted private keys with DenoSo it seems to me that Deno doesn't provide any helpers for making HTTPS requests with encrypted priError when using readline.question()I get this error with the following code ```ts import process from 'node:process' import readline fjsx in denoHi, I have simple code that takes use of jsx. Based on deno docs, the jsx support should be ootb. IsExpress pt2 tutorial links to itselfAt the very start of the tutorial, it mentions that part 1 got up and running, but the link points tonboard is infiniteSeems like the onboarding process is broken and won't stop repeating itself You need to be a new memDeno mobile app?Anyone has made a mobile app using deno? I was planning to use Fresh and https://capacitorjs.com/ tWhat is the best way to count values with Deno.Kv?I want to show the total values in the database. It seems that the only way is with `kv.list()` and Does kv delete recursively?For example, if I have entries with keys: `['users', 1]`, `['users', 2]`, will `kv.delete(['users'])