use the following code:
set wsh1=server.createobject("wscript.shell")
returnObj = wsh1.run(command1,0,true)
set wsh1=nothing
this might work as it worked for me from asp.
command1 in my case is a batch file that has a simple DOS command.
(command1="c:\command1.bat")
you can always put your commands in batch and run them as i did.
can you send the error details so we can specify where we stand.
nabil
> Hi
>
> thank you all for your reply
> this was a repost of an earlier question in which I stated the code as well
> as the fact that the code does run as a .vbs file and executes fine. It only
> refuses to run as an ASP web application. I already reinstalled the windows
> scripting engine (includes whs 5.6) yet with no luck at all.
>
> The code is listed below:
>
> <%
> Dim caclscommand
> Dim wsh
> Dim wshRun
> memberName = "pmoss"
> Caclscommand = "cmd /c echo y| CACLS " & "\\dc1\home\" & userName
> Caclscommand = Caclscommand & " /E /C /G " & memberName & ":" & "C"
>
> Set wsh = server.createobject("WScript.Shell")
> wsh.Run(Caclscommand, 1, True)
>
> Set wsh = nothing
> %>
>
> The code was send to me by someone replying to my article in which i explain
> how to use cacls.exe
> the code works like a charm for me, but it doesn't run. It gives a Object
> Expected error on the .RUN
> yet it does work when the extension is changed from .asp to .vbs
>
> regards
>
> remie bolte
>
>
>
> ----- Original Message -----
> From: "nabil" <[EMAIL PROTECTED]>
> To: "ActiveServerPages" <[EMAIL PROTECTED]>
> Sent: Saturday, October 26, 2002 2:28 AM
> Subject: RE: WSH Run Problem
>
>
> > Just for testing, try adding the command you want to execute to a (.bat)
> > file. And then apllY: wsh.run(thefile.bat,1,true) and see what happens.
> >
> > Or you try creating a VB.exe file and use command() to read from the
> > input line. And the call Vb.exe using shell.run
> >
> > Another possiblity is that the wsh is not enabled on the machine you are
> > using or not even installed or corrupted, to check for that you have to
> > visit the registry and check.
> >
> > As I said before to make sure that the wsh is running try runnig the
> > .vbs that includes WSH call directly in the command line and see.
> >
> > Moreover, I am sure that run function runs (.exe, .bat) but I am not
> > sure about .vbs .
> >
> > It happened once that wsh did not work on my machine (win2000
> > professional) so all what I did is that I reinstalled internet explorer
> > 6 again and it worked.(maybe it helps wsh comes by default with IE6 and
> > above)
> >
> >
> > For more information about WSH go to:
> >
> > http://msdn.microsoft.com/scripting
> >
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script5
> > 6/html/wstsksetupofremotewsh.asp
> >
> > nabil
> >
> > -----Original Message-----
> > From: Remie Bolte [mailto:asplist@;vinrem.nl]
> > Sent: Friday, October 25, 2002 1:03 PM
> > To: ActiveServerPages
> > Subject: Re: WSH Run Problem
> >
> > Hi
> >
> > ok, tried to run it in admin context, yet no luck.
> > does anyone else have a clue?
> >
> > regards
> >
> > remie bolte
> >
> >
> > ----- Original Message -----
> > From: "Ken Schaefer" <[EMAIL PROTECTED]>
> > To: "ActiveServerPages" <[EMAIL PROTECTED]>
> > Sent: Thursday, October 24, 2002 3:20 AM
> > Subject: Re: WSH Run Problem
> >
> >
> > > First question I asked in my previous email:
> > >
> > > Different user context?
> > >
> > > (when you double-click a .vbs file it will run in the context of the
> > logged
> > > on user. If you do it in an ASP page, without using authentication, it
> > will
> > > run in the context of the anonymous internet account, which probably
> > doesn't
> > > have permissions to make the necessary changes. Run the ASP page in
> > the
> > > context of an administrator account by denying anonymous access to the
> > page)
> > >
> > > Cheers
> > > Ken
> > >
> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > From: "Remie Bolte" <[EMAIL PROTECTED]>
> > > Subject: Re: WSH Run Problem
> > >
> > >
> > > : Ok
> > > :
> > > : I had to ask the code so it took me a while.
> > > :
> > > : <%
> > > : Dim caclscommand
> > > : Dim wsh
> > > : Dim wshRun
> > > : memberName = "pmoss"
> > > : Caclscommand = "cmd /c echo y| CACLS " & "\\dc1\home\" & userName
> > '****
> > > the
> > > : code fails whether userName is dynamically assigned or static
> > > :
> > > :
> > >
> > '***********************************************************************
> > ****
> > > : *******************
> > > : '* Deletes the existing inherited permissions and adds the student's
> > > : permissions *
> > > :
> > >
> > '***********************************************************************
> > ****
> > > : *******************
> > > : Caclscommand1 = Caclscommand & " /E /C /G " & memberName & ":" & "C"
> > > :
> > > : Set wsh = server.createobject("WScript.Shell")
> > > : wsh.Run(Caclscommand1, 1, True)
> > > :
> > > : Set wsh = nothing
> > > : %>
> > > :
> > > : this code doesn't run in ASP, but it does run in .vbs mode.
> > > : can it have anything to do with IIS settings?
> > > :
> > > : regards
> > > :
> > > : remie bolte
> > > :
> > > :
> > > :
> > > :
> > > : ----- Original Message -----
> > > : From: "Ken Schaefer" <[EMAIL PROTECTED]>
> > > : To: "ActiveServerPages" <[EMAIL PROTECTED]>
> > > : Sent: Wednesday, October 23, 2002 9:35 AM
> > > : Subject: Re: WSH Run Problem
> > > :
> > > :
> > > : > Different user context?
> > > : >
> > > : > Otherwise, can you please provide code?
> > > : >
> > > : > Cheers
> > > : > Ken
> > > : >
> > > : > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > : > From: "Remie Bolte" <[EMAIL PROTECTED]>
> > > : > Subject: WSH Run Problem
> > > : >
> > > : >
> > > : > : i have received a question concerning WSH
> > > : > : it's about setting folder permissions using CACLS.
> > > : > :
> > > : > : it seems that the WSH run method works using .vbs files but
> > doesn't
> > > work
> > > : > : using .ASP files. At least at his computer, because it works
> > fine
> > for
> > > : me.
> > > : > :
> > > : > : does anyone know what to do in order to make WSH work
> > server-side
> > > trough
> > > : > : ASP?
> > > : >
> > > : > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > : >
> > > : > ---
> > > : > You are currently subscribed to activeserverpages as:
> > [EMAIL PROTECTED]
> > > : > To unsubscribe send a blank email to
> > > : %%email.unsub%%
> > > :
> > > :
> > > :
> > > : ---
> > > : You are currently subscribed to activeserverpages as:
> > [EMAIL PROTECTED]
> > > : To unsubscribe send a blank email to
> > > %%email.unsub%%
> > >
> > >
> > > ---
> > > You are currently subscribed to activeserverpages as:
> > [EMAIL PROTECTED]
> > > To unsubscribe send a blank email to
> > %%email.unsub%%
> > >
> >
> >
> >
> > ---
> > You are currently subscribed to activeserverpages as:
> > [EMAIL PROTECTED]
> > To unsubscribe send a blank email to
> > %%email.unsub%%
> >
> >
> > ---
> > You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
> > To unsubscribe send a blank email to
> %%email.unsub%%
> >
>
>
>
> ---
> You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to %%email.unsub%%
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]