Executing command prompt using Javascript

As a newcomer to stackoverflow, I am facing an issue with my asp.net web application. In one of the web forms, I need to execute cmd.exe from JavaScript on the server side after clicking a button.

function onRec(){
try{
var commandtoRun = "c:\\WINDOWS/system32/cmd.exe";
var commandParms = "dir"; 
alert("start recording   ");
var ws = new ActiveXObject("WScript.Shell");
ws.ShellExecute(commandtoRun, commandParms, "", "open", "1");
}
catch(err)
{
 alert(err.message):
}
}
<input type="button"  name="Record" value="Record" onclick="OnRecStart();" />

I have tried the above code but it does not seem to invoke cmd.exe properly. I also attempted the following:

string filepath= Server.MapPath("../VideoStreaming/Record.bat"); 
ProcessStartInfo oProcessStartInfo = new ProcessStartInfo(filepath);
oProcessStartInfo.Arguments = "dir";
oProcessStartInfo.UseShellExecute = false;
Process oProcess = Process.Start(oProcessStartInfo);
oProcess.Start();

Although the second code snippet works fine locally, it fails when running from IIS. This has left me puzzled and I suspect there may be a browser security issue at play. Can someone provide suggestions on how to overcome this obstacle? Your help is greatly appreciated.

Answer №1

Unfortunately, this task is impossible to complete because of potential security risks.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Draft JS to dynamically insert text in the form of span

I'm utilizing Draft.js with its mentions plugin. Occasionally, I'd like users to input a mention not by choosing from a dropdown menu, but by typing something like, for example, "@item" or "@item". In the function below, you can observe that if ...

Guide to making a toggle button with a Light/Dark mode functionality

I have implemented a light/dark toggle button and now I want to integrate the functionality for switching between light and dark themes on my webpage. The switch should toggle the theme between dark and light modes when clicked. Some basic styling has been ...

Utilizing Material UI's (MUI) date picker in conjunction with react-hook-form offers a

I'm currently developing a form with a date field utilizing MUI and react-hook-form for validation. I have experimented with two different methods of rendering the field, but when I try to submit the form, the expected value is not being returned: Me ...

What is the best way to extract the "Standard" timezone string from a given moment object?

Currently, I am tackling a project in asp.net that involves managing dates and times between a server database and client-side widgets. In order to simplify this process, I have decided to utilize moment.js. While examining my moment object during debuggi ...

Observing a class getter within Vue.js

The issue at hand I am facing a challenge in ensuring my page automatically updates when new data is available. I am using Ionic, and have a page that displays all the items collected by the user in a visually appealing manner using an ion-grid. To achiev ...

Searching through text in Node JS using Mongoose for Full-Text queries

I am facing an issue while attempting to perform a full-text search on an array of strings using Mongoose. The error message I receive is as follows: { [MongoError: text index required for $text query] name: 'MongoError', message: 'text ...

The function in which the "useStyles" React Hook is invoked is not a valid React function component or a defined custom React Hook function

After integrating Material UI with React, I encountered the following error message: React Hook "useStyles" is called in function "appBar" which is neither a React function component nor a custom React Hook function I have carefully checked the rules of ...

Boxes that change and adapt to the user's input

Need guidance on a tricky problem! I am working on a form to input various cities that the user wants to visit. The form currently consists of one form box and a submit button. My goal is to allow the user to enter multiple cities by clicking an "Add 1 ...

Step-by-step guide on printing barcode labels from a browser in ReactJS with the Wincode C342C printer

Has anyone here successfully printed from the client side using JavaScript/ReactJS to a Wincode c342c printer? I've installed the qz.io library to allow my JavaScript code to access the client's printer. I've managed to print a PDF as base6 ...

The .map() function seems to be missing some data when fetching from the database in a Node.js

I am currently tackling an exercise for a Bootcamp, and the function I am using is not yielding the desired outcome. The objective is to query the database with a first name or a part of a first name. While I can successfully execute the DB query and retri ...

Error: Failed to cast value "{ email: 'example@email.com' }" to ObjectId (type Object) for the "_id" path in the "User" model

How can I use the Mongoose ID to fetch data and send it to the client's browser? My Mongoose Database Data: {"_id":{"$oid":"6404fc0b9e6a0640b0deb716"},"username":"dddd","email":"[email&# ...

Tips on how to showcase up to 200 characters from a string

<?php include ($_SERVER['DOCUMENT_ROOT'].'/header.php'); include ($_SERVER['DOCUMENT_ROOT'].'/adtop.php'); if(mysql_num_rows($deals) > 0){ while($row = mysql_fetch_assoc($deals)){ echo '<div id= ...

Position the div in the center and enhance the function to dynamically adjust when the user attempts to resize the window

var windowHeight = $(window).height(); var windowWidth = $(window).width(); var scrollTop = $(window).scrollTop(); var scrollLeft = $(window).scrollLeft(); jQuery.fn.center = function () { this.css("position","absolute"); this.css("top", Math.max( ...

Accessing the Angular scope and making modifications using Chrome browser

I need to access the $scope value in order to update its data values via a chrome extension. I have attempted to obtain the $scope using the code below: var $scope = angular.element(document.getElementById('name')).scope() While this code wor ...

Encountered an error while handling a promise: Unable to access null properties (specifically, 'useState')

I'm having trouble understanding why I keep encountering this error with the line const [isLoading, setLoading] = useState(true);. It's initially set to true so it shouldn't be undefined. export default async function GetProducts() { c ...

incorporating theme.spacing in the declaration of the theme

The theme setup that I am working with is as follows: export const themeDefault = createTheme({ themeName: 'Default (Mortgage Hub)', spacing: 4, ...typography, palette, components: { MuiButton: { styleOverrides: { root ...

Is it possible to use jQuery to create a slide-up effect from the

Could I reverse the animation direction of my dropdown menu? Currently, it expands from the top to bottom. Is there a way to make it expand from the bottom to the top? Code snippet: animate({height:'show',opacity:'show'}, ddsmoothmenu ...

Bring in resources without specifying

Is there a way to directly import an image into a JSX tag in React without having to declare it at the top of the file using import img from './this/is/file.png'? I attempted to do so with <img src={import './this/is/file.png'} alt= ...

Sending a string array to MVC controllers through ajax

I've been struggling to pass a list of strings from a multiple select to the controller. Despite seeming like a simple requirement, I've spent hours trying to figure it out without success. I've done some research on this but haven't be ...

Special characters like ! are missing in command line parameters when the batch file is executed from Inno Setup

We are facing a unique challenge while running Java code in our system. Despite being part of a legacy setup, our team recently discovered a long-standing bug that needed fixing. Our Inno Setup installer executes a batch file after file copying. Inside th ...