George Sas
asked on
Passing options from web to a command line
Hello.
I am a totally newbie in ASP / VB programming and it is not my daily work but I would like
some help from you guys if possible.
I need an ASP /VB code that will pass some variables as options to a command line.
Let's say I need to execute a program with some options and I need the user
to select the otions from the web interface.
The command line will look something like this:
Program.exe /usename:username /password:password /options:option1,option2,o ption3
The the user will access a web page and it will be asked for the username , password and
it will be able to select the options by marking them on the page.
After the selection the command line will be executed with the selected oprions.
If somebody can point me to some example code or any hints to get me started I would
appreciated it.
It is possible to specify also the credentials the "program.exe" should run under?
Thank you in advance.
ASP , .NET and VB all accepted.
I am a totally newbie in ASP / VB programming and it is not my daily work but I would like
some help from you guys if possible.
I need an ASP /VB code that will pass some variables as options to a command line.
Let's say I need to execute a program with some options and I need the user
to select the otions from the web interface.
The command line will look something like this:
Program.exe /usename:username /password:password /options:option1,option2,o
The the user will access a web page and it will be asked for the username , password and
it will be able to select the options by marking them on the page.
After the selection the command line will be executed with the selected oprions.
If somebody can point me to some example code or any hints to get me started I would
appreciated it.
It is possible to specify also the credentials the "program.exe" should run under?
Thank you in advance.
ASP , .NET and VB all accepted.
If you decide to take this approach, there is a discussion of permissions and etc. here:
https://www.experts-exchange.com/questions/20812180/Run-a-bat-with-ASPExec.html
FtB
https://www.experts-exchange.com/questions/20812180/Run-a-bat-with-ASPExec.html
FtB
ASKER
I want the user to be able to select the options from a form check box.
First I need the code to pass the options , and I can take care of the permisions later.
First I need the code to pass the options , and I can take care of the permisions later.
ASKER
The code you rpopose it is good but it does not show me how can I ask the user for options and pass them to the command line.
That is why I asked you the question about how you want to get the variables!!!
So, what does this form look like?
Fritz the Blank
So, what does this form look like?
Fritz the Blank
ASKER
I did not made the form yet but the page will look something like :
Please select the options:
"Text box" : Insert name
"Text box" : Insert password
"check box" : Option 1
"check box" : Oprion 2
"check box" : Option 3
...
"check box" : Option X
-------------------------- ----------
Press Button : Submit (This will Execute the command Command)
And then the command line will be executed with the selected options.
like:
Program.exe /usename:username /password:password /options:selectedoption1,s electedopt ion3,selec tedoptionx
Please select the options:
"Text box" : Insert name
"Text box" : Insert password
"check box" : Option 1
"check box" : Oprion 2
"check box" : Option 3
...
"check box" : Option X
--------------------------
Press Button : Submit (This will Execute the command Command)
And then the command line will be executed with the selected options.
like:
Program.exe /usename:username /password:password /options:selectedoption1,s
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Command to be executed is longer but I need only this options passed.
Whole command line would be like :
Program.exe /source:server1 /usename:username /password:password /options:option1,option2,o ption3 /target:server1,server2,se rver3 /execute
Whole command line would be like :
Program.exe /source:server1 /usename:username /password:password /options:option1,option2,o
ASKER
ok , I know how to make the form and etc , but don't know how to pass the options selected by the user to the command line.
ASKER
We are getting close :)
so, just do this:
strOptionsText = ""
if Request.Form("option1") <>"" then
strOptionsText = strOptionsText & Request.Form("option1")
end if
if Request.Form("option2") <>"" then
strOptionsText = strOptionsText & Request.Form("option2")
end if
if Request.Form("option3") <>"" then
strOptionsText = strOptionsText & Request.Form("option3")
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
Fritz the Blank
strOptionsText = ""
if Request.Form("option1") <>"" then
strOptionsText = strOptionsText & Request.Form("option1")
end if
if Request.Form("option2") <>"" then
strOptionsText = strOptionsText & Request.Form("option2")
end if
if Request.Form("option3") <>"" then
strOptionsText = strOptionsText & Request.Form("option3")
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
Fritz the Blank
ASKER
I am totally newbie , 0 , null to ASP :)
Let me try.
Let me try.
ASKER
I get some compilation errors
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 32, column 100
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
Could you paste the whole code ?
Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/test.asp, line 32, column 100
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
Could you paste the whole code ?
Please post what you have and I'll correct.
FtB
FtB
My bad, the line should be this:
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
ASKER
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p>Name:<input type="text" name="name" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("option1") <>"" then
strOptionsText = strOptionsText & Request.Form("option1")
end if
if Request.Form("option2") <>"" then
strOptionsText = strOptionsText & Request.Form("option2")
end if
if Request.Form("option3") <>"" then
strOptionsText = strOptionsText & Request.Form("option3")
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
<form method="POST" action="--WEBBOT-SELF--">
<p>Name:<input type="text" name="name" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("option1") <>"" then
strOptionsText = strOptionsText & Request.Form("option1")
end if
if Request.Form("option2") <>"" then
strOptionsText = strOptionsText & Request.Form("option2")
end if
if Request.Form("option3") <>"" then
strOptionsText = strOptionsText & Request.Form("option3")
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
This should be closer:
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p>Name:<input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("option1") ="ON" then
strOptionsText = strOptionsText & "option1,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
FtB
<body>
<form method="POST" action="--WEBBOT-SELF--">
<p>Name:<input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("option1") ="ON" then
strOptionsText = strOptionsText & "option1,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
FtB
ASKER
After I press submit I am reditrected to :
http://testapp/--WEBBOT-SELF--
and then I get :
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
http://testapp/--WEBBOT-SELF--
and then I get :
The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.
Ah, you're using Front Page!!! Good luck...
Change this:
<form method="POST" action="--WEBBOT-SELF--">
to:
<form method="POST" action="">
Fritz the Blank
Change this:
<form method="POST" action="--WEBBOT-SELF--">
to:
<form method="POST" action="">
Fritz the Blank
Also, we need to put the conditional logic back in for the submit:
<body>
<form method="POST" action="">
<p>Name:<input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("option1") ="ON" then
strOptionsText = strOptionsText & "option1,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s erver3 /execute "
end if
%>
</body>
FtB
<body>
<form method="POST" action="">
<p>Name:<input type="text" name="username" size="20"><br>
Password: <input type="text" name="password" size="20"><br>
Option1<input type="checkbox" name="option1" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("option1") ="ON" then
strOptionsText = strOptionsText & "option1,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "Program.exe /source:server1 /usename:" & Request.Form("userName") & " /password:" & Request.Form("password") &"/options:" & strOptionsText & "/target:server1,server2,s
end if
%>
</body>
FtB
ASKER
To get a better ideea of wht I am trying to do:
http://www.microsoft.com/technet/prodtechnol/acs/reskit/acrkch11.mspx
I am trying to deploy ONLY selected applications from the web form.
My original command line looks like:
C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:*********
Well , here I can only deploy Application names : shop4all
In my case /options is /APPNAME
I need the form to let me select more than one application. and deploy only selected applications.
http://www.microsoft.com/technet/prodtechnol/acs/reskit/acrkch11.mspx
I am trying to deploy ONLY selected applications from the web form.
My original command line looks like:
C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:*********
Well , here I can only deploy Application names : shop4all
In my case /options is /APPNAME
I need the form to let me select more than one application. and deploy only selected applications.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You will be able to run the script like this:
<%
set objWSH= server.createobject("wscri pt.shell")
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
%>
<%
set objWSH= server.createobject("wscri
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
%>
Or you can use ASPExec....
Of course, I am sure that aspmaestro meant to say, "building on what Fritz has shown you"....
Of course, I am sure that aspmaestro meant to say, "building on what Fritz has shown you"....
@aspmaestro--
Sorry if I sound a little testy--I was just trying to get GeoSs as far as building the string first. Once that was done, we would move on to executing it.
FtB
Sorry if I sound a little testy--I was just trying to get GeoSs as far as building the string first. Once that was done, we would move on to executing it.
FtB
ASKER
Well, I get no more errors in compiling it.
I press Submit but nothing happends.
I press Submit but nothing happends.
hi fritz_the_blank ,
you missed to specify how to run command thru asp by wscript object !
just making a string for the command parameters doesnt run that command..yes.
you missed to specify how to run command thru asp by wscript object !
just making a string for the command parameters doesnt run that command..yes.
ASKER
My Final code :
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>
<body>
<html>
<head>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator /TARGETPASSWORD:xxx"
set wshell = server.createobject("wscri pt.shell")
intReturn = wshell.run (strCommandText)
'Response.Write(intReturn) '''if the program.exe returns any result
set wshell = nothing
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
Executing :
error '80070002'
/test.asp, line 43
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
</head>
<body>
<html>
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator
set wshell = server.createobject("wscri
intReturn = wshell.run (strCommandText)
'Response.Write(intReturn)
set wshell = nothing
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
Executing :
error '80070002'
/test.asp, line 43
Change following ...
intReturn = wshell.run (strCommandText)
to,
intReturn = wshell.run (strCommandText,0,true)
intReturn = wshell.run (strCommandText)
to,
intReturn = wshell.run (strCommandText,0,true)
ASKER
<html>
<head>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator /TARGETPASSWORD:xxx"
set wshell = server.createobject("wscri pt.shell")
intReturn = wshell.run (strCommandText,0,true)
'Response.Write(intReturn) '''if the program.exe returns any result
set wshell = nothing
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
-------------------------- ---------
error '80070002'
/test.asp, line 32
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<%
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator
set wshell = server.createobject("wscri
intReturn = wshell.run (strCommandText,0,true)
'Response.Write(intReturn)
set wshell = nothing
%>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
</body>
</html>
--------------------------
error '80070002'
/test.asp, line 32
That is strange--specified the necessary parameters above....
<%
set objWSH= server.createobject("wscri pt.shell")
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
%>
No real need to return a value....
FtB
<%
set objWSH= server.createobject("wscri
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
%>
No real need to return a value....
FtB
Try this... specify the path of cmd.exe using %comspec% as follows:
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
ASKER
@aspmaestro:
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 32
Hmmmm ....... might be , but actually I am executing the code as the Admin on the local computer.
@fritz_the_blank - no , the command does not return any value , it just executes the code.
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 32
Hmmmm ....... might be , but actually I am executing the code as the Admin on the local computer.
@fritz_the_blank - no , the command does not return any value , it just executes the code.
This should do it providing that you have the permissions configured correctly:
<html>
<head>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator /TARGETPASSWORD:xxx"
set objWSH= server.createobject("wscri pt.shell")
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
end if
%>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator
set objWSH= server.createobject("wscri
objWSH.run(strCommandText , 0, True)
set objWSH= nothing
end if
%>
</body>
</html>
ASKER
Fritz :
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
/test.asp, line 35
objWSH.run(strCommandText , 0, True)
-------------------------- ---------- ^
Microsoft VBScript compilation error '800a0414'
Cannot use parentheses when calling a Sub
/test.asp, line 35
objWSH.run(strCommandText , 0, True)
--------------------------
ASKER
I don't even push the SUBMIT button , the errors are coming when I am calling the ASP script.
ASKER
Have to go to work , I will try again later and come back with coments.
In the mean time maybe you can get it to work :(
You can just test with a "ping" command with paramanters like :
"ping hostname" or something as test where hostname is the option
or
dir c:\ > file.txt
Thank you both for the help for now. Will be back in 4-5 hours.
In the mean time maybe you can get it to work :(
You can just test with a "ping" command with paramanters like :
"ping hostname" or something as test where hostname is the option
or
dir c:\ > file.txt
Thank you both for the help for now. Will be back in 4-5 hours.
specify the %comspec% and make the run method to return a value to variable.
intreturn=wshell.run(....
intreturn=wshell.run(....
Can you check the program.exe that ur running, coz the following works fine for me.
<%
.........
set wshell = server.createobject("wscri pt.shell")
strCommandText="Ping 10.160.1.100 -t>c:\maestro.txt"
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
....
...
%>
where 10.160.1.100 is my a server in my intranet.
I get the correct output in the maestro.txt file. gud luck.
<%
.........
set wshell = server.createobject("wscri
strCommandText="Ping 10.160.1.100 -t>c:\maestro.txt"
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
....
...
%>
where 10.160.1.100 is my a server in my intranet.
I get the correct output in the maestro.txt file. gud luck.
This:
objWSH.run(strCommandText , 0, True)
may have to be:
call objWSH.run(strCommandText , 0, True)
>>Hmmmm ....... might be , but actually I am executing the code as the Admin on the local computer<<
It doesn't matter what you are logged in as--the ASP page operates under the IUSR_ and IWAM_ accounts. You will need to give the proper permissions. Here is the link that I gave you earlier about this:
https://www.experts-exchange.com/questions/20812180/Run-a-bat-with-ASPExec.html
FtB
objWSH.run(strCommandText , 0, True)
may have to be:
call objWSH.run(strCommandText , 0, True)
>>Hmmmm ....... might be , but actually I am executing the code as the Admin on the local computer<<
It doesn't matter what you are logged in as--the ASP page operates under the IUSR_ and IWAM_ accounts. You will need to give the proper permissions. Here is the link that I gave you earlier about this:
https://www.experts-exchange.com/questions/20812180/Run-a-bat-with-ASPExec.html
FtB
In particular:
C:\Program Files\Microsoft Application Center\ will need fairly liberal permissions.
FtB
C:\Program Files\Microsoft Application Center\ will need fairly liberal permissions.
FtB
ASKER
<html>
<head>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator /TARGETPASSWORD:drtyuk34"
set wshell = server.createobject("wscri pt.shell")
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
end if
%>
</body>
</html>
__________________________ ________
This will load the asp page but when executed will give me :
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 35
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator
set wshell = server.createobject("wscri
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
end if
%>
</body>
</html>
__________________________
This will load the asp page but when executed will give me :
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 35
ASKER
If I am running it like this :
<html>
<head>
<meta http-equiv="Content-Langua ge" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "cmd.exe /c C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator /TARGETPASSWORD:xxxxxx"
set objWSH= server.createobject("wscri pt.shell")
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
end if
%>
</body>
</html>
Nothing will happen.
It is executing the script and nothing :(
<html>
<head>
<meta http-equiv="Content-Langua
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Name</title>
</head>
<body>
<form method="POST" >
Shop4all<input type="checkbox" name="shop4all" value="ON"><br>
Option2<input type="checkbox" name="option2" value="ON"><br>
Option3<input type="checkbox" name="option3" value="ON"></p>
<p><br>
<input type="submit" value="Submit" name="Execute"><input type="reset" value="Reset" name="B2"></p>
</form>
<%
if request.form("Execute") = "Submit" then
strOptionsText = ""
if Request.Form("shop4all") ="ON" then
strOptionsText = strOptionsText & "shop4all,"
end if
if Request.Form("option2") ="ON" then
strOptionsText = strOptionsText & "option2,"
end if
if Request.Form("option3") ="ON" then
strOptionsText = strOptionsText & "option3,"
end if
strCommandText = "cmd.exe /c C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 " &"/APPNAME:" & strOptionsText & "/TARGETUSER:Administrator
set objWSH= server.createobject("wscri
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
end if
%>
</body>
</html>
Nothing will happen.
It is executing the script and nothing :(
ASKER
Can I somehow see what is executed by the script and what not ?
ASKER
I have also tried only like this :
<body>
<%
strOptionsText = "shop4all"
strCommandText = "AC.exe DEPLOY /START /DEPNAME:Test /SOURCE:staging1 /TARGETS:www1,www2,www3 " &" /APPNAME:"&strOptionsText& " /TARGETUSER:Administrator /TARGETPASSWORD:xxxxx"
set wshell = server.createobject("wscri pt.shell")
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
%>
Script will run without errors but nothing will happen.
<body>
<%
strOptionsText = "shop4all"
strCommandText = "AC.exe DEPLOY /START /DEPNAME:Test /SOURCE:staging1 /TARGETS:www1,www2,www3 " &" /APPNAME:"&strOptionsText&
set wshell = server.createobject("wscri
intReturn = wshell.run ("%comspec% /c " & strCommandText,0,true)
%>
Script will run without errors but nothing will happen.
ASKER
finally I tried like this to see what I get :
strCommandText = "cmd.exe /c AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxxx > e:\wwwroot\testapp\error.t xt"
set objWSH= server.createobject("wscri pt.shell")
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
Executed and found in the error.txt
Application Center 2000 Command-Line Utility. (C) Copyright 2000 Microsoft Corp.
The system returned the following error:
Access is denied. (0x80070005)
I have given full permisions to : cmd.exe and Ac.exe ......
strCommandText = "cmd.exe /c AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxxx > e:\wwwroot\testapp\error.t
set objWSH= server.createobject("wscri
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
Executed and found in the error.txt
Application Center 2000 Command-Line Utility. (C) Copyright 2000 Microsoft Corp.
The system returned the following error:
Access is denied. (0x80070005)
I have given full permisions to : cmd.exe and Ac.exe ......
ASKER
Any way to run the script under other credentials ?
ASKER
If I run like :
strCommandText = "cmd.exe /c C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:********** * > e:\wwwroot\testapp\error.t xt"
instead of launching AC.exe from e:\wwwroot\testapp I run it from Program Files , the error.txt returned will be epty , no errors , nothing happends.
strCommandText = "cmd.exe /c C:\Program Files\Microsoft Application Center\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:**********
instead of launching AC.exe from e:\wwwroot\testapp I run it from Program Files , the error.txt returned will be epty , no errors , nothing happends.
ASKER
If I am running it from another web server like :
strCommandText = "cmd.exe /c e:\testapp\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxx > e:\wwwroot\testapp\error.t xt"
set objWSH= server.createobject("wscri pt.shell")
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
I get :
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 37
Where Line 37 is >>>> call objWSH.run(strCommandText , 0, True)
strCommandText = "cmd.exe /c e:\testapp\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxx > e:\wwwroot\testapp\error.t
set objWSH= server.createobject("wscri
call objWSH.run(strCommandText , 0, True)
set objWSH= nothing
I get :
Microsoft VBScript runtime error '800a0046'
Permission denied
/test.asp, line 37
Where Line 37 is >>>> call objWSH.run(strCommandText , 0, True)
Okay, I am back now.
As I said at the beginning of the thread, you will have to be careful about setting permissions when you do this. Keep in mind that when the script runs, it is not doing under your login account, but rather, under the IUSR_ and IWAM_ anonymous accounts used by IIS.
Having said that, you need to determine what directories are involved in your script and then give the IUSR and IWAM accounts the necessary permissions.
FtB
As I said at the beginning of the thread, you will have to be careful about setting permissions when you do this. Keep in mind that when the script runs, it is not doing under your login account, but rather, under the IUSR_ and IWAM_ anonymous accounts used by IIS.
Having said that, you need to determine what directories are involved in your script and then give the IUSR and IWAM accounts the necessary permissions.
FtB
ASKER
ok , think you are right .... I will give it a try and let you know.
ASKER
Access is denied. (0x80070005)
And I gave full mermisions to IWAM and IUSR over c:\program files\Microsoft Application Ceneter\ and the wwwroot
I am almost giving up....
And I gave full mermisions to IWAM and IUSR over c:\program files\Microsoft Application Ceneter\ and the wwwroot
I am almost giving up....
So does that cover both the source and destination directories of your scripts? Do you want to give ASPExec a try?
FtB
FtB
ASKER
Tried like this :
strCommandText = "cmd.exe /c e:\wwwroot\testapp\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxx > e:\wwwroot\testapp\error.t xt"
dim ObjWshell, ObjCmd, strPResult
set ObjWshell = server.CreateObject("WScri pt.Shell")
set objCmd = objWShell.Exec(strCommandT ext)
strPResult = objCmd.StdOut.Readall()
Response.Write "<p><b>NetStat</b> Server Time: "& now
set objCmd = nothing
set ObjWshell = nothing
Response.Write "<font size=2>" & "<pre>" & replace(strPResult,vbCRlf, "<br>") & "</pre>"
Same thing ....
Application Center 2000 Command-Line Utility. (C) Copyright 2000 Microsoft Corp.
The system returned the following error:
Access is denied. (0x80070005)
Any other ideeas ?
strCommandText = "cmd.exe /c e:\wwwroot\testapp\AC.exe DEPLOY /START /DEPNAME:TestDeploy /SOURCE:staging1 /TARGETS:www1,www2,www3 /APPNAME:shop4all /TARGETUSER:Administrator /TARGETPASSWORD:xxxxxxx > e:\wwwroot\testapp\error.t
dim ObjWshell, ObjCmd, strPResult
set ObjWshell = server.CreateObject("WScri
set objCmd = objWShell.Exec(strCommandT
strPResult = objCmd.StdOut.Readall()
Response.Write "<p><b>NetStat</b> Server Time: "& now
set objCmd = nothing
set ObjWshell = nothing
Response.Write "<font size=2>" & "<pre>" & replace(strPResult,vbCRlf,
Same thing ....
Application Center 2000 Command-Line Utility. (C) Copyright 2000 Microsoft Corp.
The system returned the following error:
Access is denied. (0x80070005)
Any other ideeas ?
ASKER
YESSSSSSSSSSSSSSSSSSSSSSSS SSSSSSSSSS SSSSSSSSSS SSSSSSSSSS SSSSS
It works!!!!!!!!!!!
I use IIS6 , the only thing I had to do was to assign another working process to my application.
That working process ha to start as a Local System not as Network Service.
Everything works like a CHARM
Thank you all.
I will split the points if this is no problem for you guys.
Let me know before I do anything :)
Cool!
It works!!!!!!!!!!!
I use IIS6 , the only thing I had to do was to assign another working process to my application.
That working process ha to start as a Local System not as Network Service.
Everything works like a CHARM
Thank you all.
I will split the points if this is no problem for you guys.
Let me know before I do anything :)
Cool!
Perhaps we should try something much simpler to start? How about a batch file that creates a "Hello World" piece of text in the C:\Program Files\Microsoft Application Center\ directory? If we get that working, then we can move on from there.
FtB
FtB
ASKER
I have actually impersonated the script with the LocalSystem :) all works ok.
fritz thank you a bunch :) I think I will change my job , programming and finding sollutions is much more fun :)
fritz thank you a bunch :) I think I will change my job , programming and finding sollutions is much more fun :)
A split is fine, I guess. I'd like to request that the split follows the line of effort / time put in by each....
FtB
FtB
Of course, I would also like say CONTGATULATIONS!!!
FtB
FtB
BTW-- you may need to test to make sure the script still works when you log of the system.
FtB
FtB
ASKER
Fritz : I am thinking to give you 350 and 150 for the aspmaestro. Let me know if it is ok. If I could give more than 500 points for this question I would.
ASKER
Application Center 2000 Command-Line Utility. (C) Copyright 2000 Microsoft Corp.
Deployment started successfully.
Cool , super cool.
Deployment started successfully.
Cool , super cool.
ASKER
fritz : can I post a question like :
Hi Fritz how are you ???
And give it 500 points ? if I can and is not against the rule I will do it :)
Hi Fritz how are you ???
And give it 500 points ? if I can and is not against the rule I will do it :)
Thanks for the offer, but the new EE guidelines prohibit it.
The split above is fine, and most importantly, your problem is solved!
FtB
The split above is fine, and most importantly, your problem is solved!
FtB
ASKER
Thank you a loot guys. You saved my day. I am not a programmer and yet I succeded in doing what I needed.
Mission accomplished.
Might come back later for extending the options on the script.
Thank you again , you made a man happy.
I hope some day the EE will raise the maximum points given for a question.
Mission accomplished.
Might come back later for extending the options on the script.
Thank you again , you made a man happy.
I hope some day the EE will raise the maximum points given for a question.
Glad to have helped!
When I first started here, the maximum number of points per question was 300. However, you couldn't buy points back then, you could only accrue something like 75 a month, so even 300 point questions weren't that common.
The rule about the 500 point maximum is intended to try to keep a lid on point inflation.
See you around,
FtB
When I first started here, the maximum number of points per question was 300. However, you couldn't buy points back then, you could only accrue something like 75 a month, so even 300 point questions weren't that common.
The rule about the 500 point maximum is intended to try to keep a lid on point inflation.
See you around,
FtB
http://www.serverobjects.com/products.htm#free
Now I don't know how you want to grab the variables--from a form, a querystring?
Fritz the Blank