Classic ASP Page Calling batch Script
I have two classic asp pages in which I had to call a batch script. The first one is working:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Roda o arquivo BAT para chamada do script powershell
Set wshell = CreateObject("WScript.Shell")
wshell.Run "\w102xnk172c$inetpubwwwrootDCT_NEWAppcopy_items.bat"
Set wshell = Nothing
'Cria o arquivo .txt de bloqueio, que o script powershell excluirá em sua finalização.
Dim fs,tfile
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set tfile = fs.CreateTextFile("\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt")
tfile.Close
Set tfile = Nothing
Set fs = Nothing
'Quando não existir mais o arquivo, a interface continua.
filename = "running_script.txt"
path_db = "\w102xnk172c$inetpubwwwrootDCT_NEWDB"
path_file = "\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
While fs.FileExists(path_file) = True
Wend
%>
This code runs my script and creates a "running_script.txt", then checks if it still exits, so no code runs until it ends. My script, at it's end, delete that file. This is working fine, and the other on is just as simple:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
page = REQUEST.QUERYSTRING("page")
If page = "ofs" Then
Set wshell = CreateObject("WScript.Shell")
wshell.Run "C:/www/gppintranet/scripts/ofs.bat"
Set wshell = Nothing
End If
response.Redirect("/gppintranet/view/home.asp")
%>
But for some reason it does not call my script. I'm automatically redirected to the home page. I've debugged, it is getting into my If
statement and the script is running properly.
I'm running this application in IIS 10.0.15063.0, if it is of use.
What is wrong? I see no difference between them.
EDIT: I have run the non-working script at the working enviroment, and it didn't work there as well. I've checked and both IIS are at the same version and with the same settings. The working script is:
@echo off
start "" http://w102xkj172/DCT_MASTER/update_dct_p2p.asp
timeout /T 5
echo Waiting for P2P DCT's information update...
:verify_locked
if exist \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCT_MASTERp2p_running.txt (
goto :verify_locked
) else (
echo Copying files...
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_PDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINEDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_1DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_3DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_4DB DCT.mdb
)
exit
And the non working is:
@echo off
START "" http://example.aspx
iis vbscript asp-classic
add a comment |
I have two classic asp pages in which I had to call a batch script. The first one is working:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Roda o arquivo BAT para chamada do script powershell
Set wshell = CreateObject("WScript.Shell")
wshell.Run "\w102xnk172c$inetpubwwwrootDCT_NEWAppcopy_items.bat"
Set wshell = Nothing
'Cria o arquivo .txt de bloqueio, que o script powershell excluirá em sua finalização.
Dim fs,tfile
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set tfile = fs.CreateTextFile("\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt")
tfile.Close
Set tfile = Nothing
Set fs = Nothing
'Quando não existir mais o arquivo, a interface continua.
filename = "running_script.txt"
path_db = "\w102xnk172c$inetpubwwwrootDCT_NEWDB"
path_file = "\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
While fs.FileExists(path_file) = True
Wend
%>
This code runs my script and creates a "running_script.txt", then checks if it still exits, so no code runs until it ends. My script, at it's end, delete that file. This is working fine, and the other on is just as simple:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
page = REQUEST.QUERYSTRING("page")
If page = "ofs" Then
Set wshell = CreateObject("WScript.Shell")
wshell.Run "C:/www/gppintranet/scripts/ofs.bat"
Set wshell = Nothing
End If
response.Redirect("/gppintranet/view/home.asp")
%>
But for some reason it does not call my script. I'm automatically redirected to the home page. I've debugged, it is getting into my If
statement and the script is running properly.
I'm running this application in IIS 10.0.15063.0, if it is of use.
What is wrong? I see no difference between them.
EDIT: I have run the non-working script at the working enviroment, and it didn't work there as well. I've checked and both IIS are at the same version and with the same settings. The working script is:
@echo off
start "" http://w102xkj172/DCT_MASTER/update_dct_p2p.asp
timeout /T 5
echo Waiting for P2P DCT's information update...
:verify_locked
if exist \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCT_MASTERp2p_running.txt (
goto :verify_locked
) else (
echo Copying files...
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_PDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINEDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_1DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_3DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_4DB DCT.mdb
)
exit
And the non working is:
@echo off
START "" http://example.aspx
iis vbscript asp-classic
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application underadministrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.
– DanB
Nov 19 '18 at 14:43
1
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
2
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.
– DanB
Nov 19 '18 at 15:40
add a comment |
I have two classic asp pages in which I had to call a batch script. The first one is working:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Roda o arquivo BAT para chamada do script powershell
Set wshell = CreateObject("WScript.Shell")
wshell.Run "\w102xnk172c$inetpubwwwrootDCT_NEWAppcopy_items.bat"
Set wshell = Nothing
'Cria o arquivo .txt de bloqueio, que o script powershell excluirá em sua finalização.
Dim fs,tfile
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set tfile = fs.CreateTextFile("\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt")
tfile.Close
Set tfile = Nothing
Set fs = Nothing
'Quando não existir mais o arquivo, a interface continua.
filename = "running_script.txt"
path_db = "\w102xnk172c$inetpubwwwrootDCT_NEWDB"
path_file = "\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
While fs.FileExists(path_file) = True
Wend
%>
This code runs my script and creates a "running_script.txt", then checks if it still exits, so no code runs until it ends. My script, at it's end, delete that file. This is working fine, and the other on is just as simple:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
page = REQUEST.QUERYSTRING("page")
If page = "ofs" Then
Set wshell = CreateObject("WScript.Shell")
wshell.Run "C:/www/gppintranet/scripts/ofs.bat"
Set wshell = Nothing
End If
response.Redirect("/gppintranet/view/home.asp")
%>
But for some reason it does not call my script. I'm automatically redirected to the home page. I've debugged, it is getting into my If
statement and the script is running properly.
I'm running this application in IIS 10.0.15063.0, if it is of use.
What is wrong? I see no difference between them.
EDIT: I have run the non-working script at the working enviroment, and it didn't work there as well. I've checked and both IIS are at the same version and with the same settings. The working script is:
@echo off
start "" http://w102xkj172/DCT_MASTER/update_dct_p2p.asp
timeout /T 5
echo Waiting for P2P DCT's information update...
:verify_locked
if exist \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCT_MASTERp2p_running.txt (
goto :verify_locked
) else (
echo Copying files...
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_PDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINEDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_1DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_3DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_4DB DCT.mdb
)
exit
And the non working is:
@echo off
START "" http://example.aspx
iis vbscript asp-classic
I have two classic asp pages in which I had to call a batch script. The first one is working:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%'Roda o arquivo BAT para chamada do script powershell
Set wshell = CreateObject("WScript.Shell")
wshell.Run "\w102xnk172c$inetpubwwwrootDCT_NEWAppcopy_items.bat"
Set wshell = Nothing
'Cria o arquivo .txt de bloqueio, que o script powershell excluirá em sua finalização.
Dim fs,tfile
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set tfile = fs.CreateTextFile("\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt")
tfile.Close
Set tfile = Nothing
Set fs = Nothing
'Quando não existir mais o arquivo, a interface continua.
filename = "running_script.txt"
path_db = "\w102xnk172c$inetpubwwwrootDCT_NEWDB"
path_file = "\w102xnk172c$inetpubwwwrootDCT_NEWDBrunning_script.txt"
Set fs = Server.CreateObject("Scripting.FileSystemObject")
While fs.FileExists(path_file) = True
Wend
%>
This code runs my script and creates a "running_script.txt", then checks if it still exits, so no code runs until it ends. My script, at it's end, delete that file. This is working fine, and the other on is just as simple:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
page = REQUEST.QUERYSTRING("page")
If page = "ofs" Then
Set wshell = CreateObject("WScript.Shell")
wshell.Run "C:/www/gppintranet/scripts/ofs.bat"
Set wshell = Nothing
End If
response.Redirect("/gppintranet/view/home.asp")
%>
But for some reason it does not call my script. I'm automatically redirected to the home page. I've debugged, it is getting into my If
statement and the script is running properly.
I'm running this application in IIS 10.0.15063.0, if it is of use.
What is wrong? I see no difference between them.
EDIT: I have run the non-working script at the working enviroment, and it didn't work there as well. I've checked and both IIS are at the same version and with the same settings. The working script is:
@echo off
start "" http://w102xkj172/DCT_MASTER/update_dct_p2p.asp
timeout /T 5
echo Waiting for P2P DCT's information update...
:verify_locked
if exist \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCT_MASTERp2p_running.txt (
goto :verify_locked
) else (
echo Copying files...
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_PDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINEDB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_1DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_3DB DCT.mdb
robocopy /IS \w102xkj172c$inetpubwwwrootPC_REPORTSexemploDCTDB \w102xnk172c$inetpubwwwrootPC_REPORTSexemploDCT_LINE_4DB DCT.mdb
)
exit
And the non working is:
@echo off
START "" http://example.aspx
iis vbscript asp-classic
iis vbscript asp-classic
edited Nov 20 '18 at 8:48
Ansgar Wiechers
140k13122183
140k13122183
asked Nov 19 '18 at 14:05
William
10412
10412
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application underadministrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.
– DanB
Nov 19 '18 at 14:43
1
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
2
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.
– DanB
Nov 19 '18 at 15:40
add a comment |
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application underadministrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.
– DanB
Nov 19 '18 at 14:43
1
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
2
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.
– DanB
Nov 19 '18 at 15:40
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application under
administrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.– DanB
Nov 19 '18 at 14:43
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application under
administrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.– DanB
Nov 19 '18 at 14:43
1
1
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
2
2
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.– DanB
Nov 19 '18 at 15:40
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.– DanB
Nov 19 '18 at 15:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376365%2fclassic-asp-page-calling-batch-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53376365%2fclassic-asp-page-calling-batch-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It's not a good idea do to that, if it works at all. You have to give too many permissions to your IUSR user to to that. To see if it's possible, run your application under
administrator
account. What actions are done by the batch file? Thoses actions cannot be done from IIS? Remember IIS run in a limited profile. Some actions, that interact with desktop/user by example, cannot be done under that profile.– DanB
Nov 19 '18 at 14:43
1
I know that this is not a good idea, but it's not my aplication and it was built that way. The script file that is working runs copy of items, the one that is not working opens a url in the default browser (IE). Both the IIS servers are the same version and have the same settings. I've tried running the non-working script at the working enviroment, and it didn't work, also. The problem is in the script. I'll update the question with it's content.
– William
Nov 19 '18 at 15:31
2
the one that is not working opens a url in the default browser (IE)
. This interact with user. The only way this can works is if the admin session is open on the server and IIS run from that session.– DanB
Nov 19 '18 at 15:40