I need help executing a batch file from a client (accessing via HTTP intranet executing using ASP Classic).
OS used:
- Client (Windows XP) - Here is where the user will access the HTML page.
- Server (Windows server 2003) - Here is where the folder is being created including the batch file. This is also where the ASP pages and HTML pages is stored and run through IIS
Scenario:
The user will access an HTML page that is linked to an asp page....
HTML code:
<html>
<body>
<form method="GET" action="default.asp">
Name<input type="text" name="firstname"/>
Uname<input type="text" name="username"/>
Fulname<input type="text" name="fullname"/>
Pass<input type="text" name="password"/>
Qwarning<input type="text" name="qwarning"/>
Qlimit<input type="text" name="qlimit"/>
<input id="submit" type="submit" value= "submit" />
</form>
</body>
</html>
After filling the forms the following asp codes will execute.
-The following code will create a folder and create a batch file that will create a user account and set its account permission
ASP CODE:
<%
'Folder Creation
dim fs
Dim name,uname,fulname,pass,qlimit,qwarning
name = Request.QueryString("firstname")
uname = Request.QueryString("username")
fulname = Request.QueryString("fullname")
pass = Request.QueryString("password")
qlimit = Request.QueryString("qlimit")
qwarning = Request.QueryString("qwarning")
'Batch File Creation
set fs=Server.CreateObject("Scripting.FileSystemObject")
if NOT fs.FolderExists("c:\dept\" & name ) Then
fs.Createfolder("c:\dept\" & name)
response.write name &" successfully created"
else
response.write name &" is already exist!"
end if
set fs=nothing
dim fsc,cfile
set fsc=Server.CreateObject("Scripting.FileSystemObject")
set cfile=fsc.CreateTextFile("c:\dept\" & name & ".bat")
'User Creation
cfile.writeline("echo off")
cfile.writeline("cd\")
cfile.writeline("Net User " & uname & " " & pass & " /add /comment:""Created by Mystic System"" /expires:never /fullname:""" & fulname & """ /passwordchg:no")
cfile.writeline("WMIC USERACCOUNT WHERE ""Name='" & uname & "'"" SET PasswordExpires=False")
'USER QUOTA
cfile.writeline("fsutil quota modify c: 104857600 209715200 WINDOWS-GDKLDNY\" & uname)
'Creation OF Permision to folder
cfile.WriteLine("cacls c:\dept\" & name & " /e /P Administrator:F")
cfile.WriteLine("cacls c:\dept\" & name & " /e /P " & uname & ":R")
cfile.WriteLine("cacls c:\dept\" & name & " /e /G " & uname & ":W")
cfile.WriteLine("del /a " & "c:\dept\" & name & ".bat")
cfile.close
set cfile=nothing
set fsc=nothing
set perm=nothing
set wshell = CreateObject("WScript.Shell")
wshell.run "c:\dept\" & name & ".bat"
set wshell = nothing
%>
ERRORS:
"No errors has been displayed."
-I have already grant the IUSR,IWAM,IIS_WPG including the NETWORK SERVICE full permission to the root folder due to desperation.. :(
Problem:
The batch file is not executing or maybe not being read (its like the batch file is not opening to execute its content). If i run it manually or hit enter on the batch file it runs perfectly. What seems to be the problem? is it on my ASP?
-I've already monitored the process or the file being accessed by the client using "Filemon" application and the results are all success from the w3wp.exe and cmd.exe.
-I've tried creating a vbscript to execute that batch and the vbscript is being called by the asp.
Still no luck. :(