Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 20th, 2015, 07:07 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default running batch file from ASP 3, IIS 6, windows 2003

Hi,

I setup an ASP 3 application in IIS 6 on Windows 2003 server. In a page it executes a dos batch file but does not execute it. It does not give an error either. The batch file is running fine when runs through the command prompt. It seems the problem is not in code but in the system.May someone please suggest me what is wrong.

The ASP code is like this:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html;
charset=iso-8859-1">
<TITLE>Test Nested Virtual Roots</TITLE>
</HEAD>
<BODY>

<%

dim WShShell, BatFile, Pth, RetCode

Pth = "D:\\finetest\\finetestin\\LD\\"

Set WShShell = Server.CreateObject("WScript.Shell")

WShShell.CurrentDirectory = Pth

BatFile = Pth & "simple.bat" +" " & "hello"

RetCode = WShShell.Run(BatFile, 0, true)

%>
<BR>
<P>

</BODY>
</HTML>

Simple.bat :
echo Parameteter = %1> Var.txt
Batch file and Var.txt exists in D:\finetest\finetestin\LD\


Thanks
Senp
Reply With Quote
  #2 (permalink)  
Old April 20th, 2015, 09:29 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default running batch file from ASP 3, IIS 6, windows 2003

The code will be like this :
BatFile = Pth & "simple.bat" & " " & "hello"
However that is not solving the problem.

Thanks,
senp
Reply With Quote
  #3 (permalink)  
Old April 21st, 2015, 08:02 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

IMO there is nothing wrong with your code. As you have pointed out you can not use + like you have, it must be a &.

The code for doing this is simple, there are loads of examples out there. The most common issue is permission related but this will present its self at run time so its probably not your issue. Your issue does not appear to be with the .asp page.

I use windows schedules tasks to fire .bat file personally.
__________________
Wind is your friend
Matt
Reply With Quote
The Following User Says Thank You to mat41 For This Useful Post:
senp (April 22nd, 2015)
  #4 (permalink)  
Old April 22nd, 2015, 07:23 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks Matt,
Could you please put some more info. (code please) as how you do it and also how to schedule a task for the batch file, I need to fire it when I open the page in the browser?

Thanks,
Senp.
Reply With Quote
  #5 (permalink)  
Old April 23rd, 2015, 01:10 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Using windows scheduled tasks (or cron jobs is think they are called in unix) are the unattended way to fire things. It gets fired without user interaction on a schedule. E.G daily at 6pm. This is not an option if you need your batch file to fire based on an end user action. Your code/approach is what I would do if I had this requirement.

To be honest in all my years classic ASP I have never needed to use a .bat file for anything. Can you not achieve your objective in a .asp file? Why does it need to fire a .bat file.

Lastly - I cant help you with your code. It looks good to go to me. Without an error or a specific issue I doubt may could
__________________
Wind is your friend
Matt
Reply With Quote
  #6 (permalink)  
Old April 23rd, 2015, 09:17 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mat41 View Post
Using windows scheduled tasks (or cron jobs is think they are called in unix) are the unattended way to fire things. It gets fired without user interaction on a schedule. E.G daily at 6pm. This is not an option if you need your batch file to fire based on an end user action. Your code/approach is what I would do if I had this requirement.

To be honest in all my years classic ASP I have never needed to use a .bat file for anything. Can you not achieve your objective in a .asp file? Why does it need to fire a .bat file.

Lastly - I cant help you with your code. It looks good to go to me. Without an error or a specific issue I doubt may could
Hi Matt,

Thanks for your reply.
I need actually to get some value from LDAP browser. For the one ASP page is using a batch file that calls Jar file to communicate and fetch data from LDAP. Batch file execution and getting value from LDAP was working fine in IIS 6 and Win 2003 sever, but may be some system update it stopped working. So, trying to find out the solution.

Now trying to communicate the LDAP server directly through ASp code:

var ldapurl = "LDAP://v******:**9/";
var ldapcontxt = "ou=***,ou=****,o=****,c=**";
var LDAPServerString = ldapurl + ldapcontxt;
var ldapuser = "cn=****,ou=****,ou=***, o=****,c=****";
var ldappwd = "********";


var objCommand = Server.CreateObject("ADODB.Connection");

objCommand.Provider = "ADsDSOObject";
objCommand.Properties("Encrypt Password") = 0;
objCommand.Open ("ADs Provider",ldapuser,ldappwd);

var strADOQueryString = "SELECT *****";
strADOQueryString += " FROM '"+Application("LDAPServerString")+"' ";

While running this piece of code is giving error:
Provider error '80040e37'
Table does not exist.

it's coming from this piece of code:
var strADOQueryString = "SELECT *****";
strADOQueryString += " FROM '"+Application("LDAPServerString")+"' ";

With the same properties and credentials I can see data through LDAP browser.

May you help?

Thanks,
senp
Reply With Quote
  #7 (permalink)  
Old April 23rd, 2015, 09:45 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2015
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mat41 View Post
Using windows scheduled tasks (or cron jobs is think they are called in unix) are the unattended way to fire things. It gets fired without user interaction on a schedule. E.G daily at 6pm. This is not an option if you need your batch file to fire based on an end user action. Your code/approach is what I would do if I had this requirement.

To be honest in all my years classic ASP I have never needed to use a .bat file for anything. Can you not achieve your objective in a .asp file? Why does it need to fire a .bat file.

Lastly - I cant help you with your code. It looks good to go to me. Without an error or a specific issue I doubt may could
Hi Matt,

Thanks for your reply.
I need actually to get some value from LDAP browser. For the one ASP page is using a batch file that calls Jar file to communicate and fetch data from LDAP. Batch file execution and getting value from LDAP was working fine in IIS 6 and Win 2003 sever, but may be some system update it stopped working. So, trying to find out the solution.

Now trying to communicate the LDAP server directly through ASp code:

var ldapurl = "LDAP://v******:**9/";
var ldapcontxt = "ou=***,ou=****,o=****,c=**";
var LDAPServerString = ldapurl + ldapcontxt;
var ldapuser = "cn=****,ou=****,ou=***, o=****,c=****";
var ldappwd = "********";


var objCommand = Server.CreateObject("ADODB.Connection");

objCommand.Provider = "ADsDSOObject";
objCommand.Properties("Encrypt Password") = 0;
objCommand.Open ("ADs Provider",ldapuser,ldappwd);

var strADOQueryString = "SELECT *****";
strADOQueryString += " FROM '"+Application("LDAPServerString")+"' ";

While running this piece of code is giving error:
Provider error '80040e37'
Table does not exist.

it's coming from this piece of code:
var strADOQueryString = "SELECT *****";
strADOQueryString += " FROM '"+Application("LDAPServerString")+"' ";

With the same properties and credentials I can see data through LDAP browser.

May you help?

Thanks,
senp
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
running a batch file from cmd from C# Bill_Thompson C# 2 March 29th, 2008 08:56 AM
BugBase Roles Do not Appear Windows 2003 IIS 6.0 siegelb BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 12 March 7th, 2008 04:56 AM
My batch file works, running it from VB does not Kal2219 Visual Basic 2005 Basics 3 February 26th, 2008 02:35 PM
Windows task scheduler / batch file Earl Hickey Other Programming Languages 0 February 1st, 2008 11:04 AM
IIS - Windows 2003 MAtkins Classic ASP Basics 18 April 27th, 2007 10:57 AM



All times are GMT -4. The time now is 06:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.