473,666 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I use Wscript.shell in ASP .Net

40 New Member
hello frnds,

I have written a simple asp .net code in button click event, in which should run "xx.cmd" file when pressed

(below is the code)

Partial Class _Default
Inherits System.Web.UI.P age

Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim oShell
oShell = Server.CreateOb ject("wscript.s hell")
oShell.Run("""C :\sampscripts\x xxx.cmd""")
oShell = Nothing
End Sub
End Class


but its not executing (below is the msg I m getting)

*************** *************** *************** *************** *************** *********
{"The component 'wscript.shell' cannot be created. Apartment threaded components can only be created on pages with an <%@ Page aspcompat=true %> page directive."}
*************** *************** *************** *************** *************** *********
I also need to pass some parameters to the xxxx.cmd from the above code, how do I do this....any help is highly appreciated....


Thanks

Fida
Oct 26 '07 #1
24 17450
Plater
7,872 Recognized Expert Expert
Have you tried doing what it says and adding the "<%@ Page aspcompat=true %> " to your page?

You are aware that currently, the script will run on the server and not on the client right?
Oct 26 '07 #2
mdfidahussain
40 New Member
Thanks very much Patel

I am actaully a sys admin, not much aware of programming in .net, I havent tried <%@ Page aspcompat=true %> this..can you plz suggest me how do I proceed with this?
but, yes, I just know that the script is running on server not on client
....


any suggestions?

thnx
Oct 26 '07 #3
Plater
7,872 Recognized Expert Expert
In your aspx page, at the top there should be a "<%@ Page " statement. Check for the "aspcompat" property and make it "=true", if it's not there, add it in?
Oct 26 '07 #4
mdfidahussain
40 New Member
That's really gr8 Plater, I ve got the prog successfully run, now I have some more problems:

1. I need to pass parameters to the xxxx.cmd <srv1>, <srv2> , may I know how do I modify this appropriately.

2. Second and most important is, I get the output in cmd prompt and thts wht I want, but this is not stopping, it vanishes once it gives the output.

tried with this, but still not halting, how do I halt this....??

oShell.Run("""C :\sampscripts\x xxx.cmd""", 1, True)

any suggestions?

Thnx

Fida
Oct 26 '07 #5
Plater
7,872 Recognized Expert Expert
You want the window to stay open?
Add a "Pause" at the end of the commands inside the .cmd file
Oct 26 '07 #6
mdfidahussain
40 New Member
Thanks for your reply Plater, "Pause" is NOT working, any other suggestions? where in I can modify the asp .net code.

and how do I pass parameters to .cmd file in the below code?

oShell.Run("""C :\sampscripts\x xxx.cmd""", 1, True)

Awaiting for your valuable reply.

thnx

Fida
Oct 26 '07 #7
Plater
7,872 Recognized Expert Expert
I am unfamiliar with the wscript.shell object you have. I use Process.Start() to start my programs.

And I've always used Pause in .cmd/.bat files, but perhaps true wscript doesn't allow for it.

Why do you want to keep it open anyway? wouldn't that result in a lot of open windows?
Oct 26 '07 #8
mdfidahussain
40 New Member
I need to see the output untill I close the window.

I have got one idea, I have created one text box with multiline option and want to paste or re-direct all the output to it coming in from the cmd prmpt, can you please suggest (with code) how to proceed.

thnx much for ur valuable reply

Fida
Oct 26 '07 #9
Plater
7,872 Recognized Expert Expert
I suggest you look into using the Process object instead, it has the ability you are looking for.
Oct 26 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
24137
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and I'm not sure what changed. (I had applied ALL the W2K update patches... but... I'm not sure if the problem started before or after that.) Did any recent W2K patches change the way createObject, wScript.shell, or "NET SEND" works?
0
7095
by: Kyle | last post by:
To any who chose to provide an answer, or even any suggestions to this problem, I thank you greatly in advance. +200 pts. for any valid solutions. I am currently in the process of converting a website from an existing web host to our servers. This website used the WScript.Shell command to execute a series of Java commands that would send an encrypted email. I ran these commands directly on the server and they execute properly,
2
8476
by: Marcin Zmyslowski | last post by:
Hello all! I have installed MSDE on my local computer - Windows 2000 Professional. I have created a function which runs me a link whose path is placed in the input field. This function looks like this: function runCommand(zmienna) { if (zmienna==-1) {
2
12203
by: rcmail14872 | last post by:
I have seen some very general suggestions for alternative code to the WScript.Shell code, but nothing specific. In the two lines of code below (I think) the first line creates a text file on the hard drive. When I get to this line I get runtime error 429 "ActiveX component can't create object". I know I should not use WSH but I haven't been able to figure out an alternative. I tried looking through the VBA editor help file for "file"...
2
19272
by: Mike John | last post by:
I am trying to use the shell object to send keys to the explorer browser to run the send page funcion. I am receiving the above error only when I put my html file in the web server folder.However if I am runing the file local it will work Any reason, why when the file is in the web server folder the create object failed to created the shell object. Systax:
0
2674
by: edurran | last post by:
Hi all, I have spent the last three days on this problem. Looked in many forums and not found the answer as yet. Hopefully ye can help. I have two functions. One works fine, the second does not. First Function Function try1 SET objShell = CreateObject("Wscript.Shell")
0
4602
by: AirYT | last post by:
Done a bunch of searching on this topic and i have come up with nothing. I have a .vbs script that i wish to execute by calling an asp page. i am working on a W2K server with IIS5.0 & SP4. My stopwebsite.vbs file is as follows: === On Error Resume Next
0
1337
by: arunpatil84 | last post by:
Hi , I am working on one ASP.NET application which zips the document files and allow the user to download the files. For that I am using Izarc command line freeware utility to zip the files. I am able to create zip the file from if the source files are in local machine as well as if the files to be zipp are in other machines from the network. My code is as follow as
2
10477
by: =?Utf-8?B?VG9kZA==?= | last post by:
Hello I'm using the following script to try and ping: <% Response.Buffer = true %> <% url = "www.espn.com" Set objWShell = CreateObject("WScript.Shell") Set objCmd = objWShell.Exec("ping " & url) strPResult = objCmd.StdOut.Readall() set objCmd = nothing: Set objWShell = nothing
0
8444
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.