Running vbscript from batch file
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
@echo off
%WINDIR%SysWOW64cmd.exe
cscript necdaily.vbs
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file? Thanks.
vbscript batch-file 32bit-64bit 32-bit syswow64
add a comment |
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
@echo off
%WINDIR%SysWOW64cmd.exe
cscript necdaily.vbs
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file? Thanks.
vbscript batch-file 32bit-64bit 32-bit syswow64
add a comment |
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
@echo off
%WINDIR%SysWOW64cmd.exe
cscript necdaily.vbs
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file? Thanks.
vbscript batch-file 32bit-64bit 32-bit syswow64
I just need to write a simple batch file just to run a vbscript. Both the vbscript and the batch file are in the same folder and is in the SysWOW64 directory as the vbscript can only be execute in that directory. Currently my batch file is as follows:
@echo off
%WINDIR%SysWOW64cmd.exe
cscript necdaily.vbs
But the vbscript wasn't executed and just the command prompt is open. Can anyone tell me how can i execute the vbscript when i run this batch file? Thanks.
vbscript batch-file 32bit-64bit 32-bit syswow64
vbscript batch-file 32bit-64bit 32-bit syswow64
asked Aug 10 '12 at 10:24
user918197
53461127
53461127
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
You can use %~dp0
to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Usingpushd
changes your working directory, which may be undesirable. Better docscript "%~dp0necdaily.vbs"
. Note there is no backslash between%~dp0
andnecdaily.vbs
.
– Gras Double
Apr 17 '17 at 22:42
add a comment |
This is the command for the batch file and it can run the vbscript.
C:WindowsSysWOW64cmd.exe /c cscript C:WindowsSysWOW64...necdaily.vbs
add a comment |
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call
in front of it.
- To make the batch file continue without waiting, put start ""
in front of it.
I recommend using this single line script to accomplish your goal:
@call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use @ instead of @echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
@%WINDIR%SysWOW64cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
For the 1st command, maybe thecall
isn't even needed. The script is also executed synchronously without it. Usuallycall
is used to call a second batch script without mixing execution contexts. So, a tiny@cscript "%~dp0necdaily.vbs"
does the job.
– Gras Double
Apr 17 '17 at 22:38
add a comment |
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
hope that helps :)
add a comment |
Just try this code:
start "" "C:UsersDiPeshDesktopvbscriptwelcome.vbs"
and save as .bat, it works for me
add a comment |
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%2f11899730%2frunning-vbscript-from-batch-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use %~dp0
to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Usingpushd
changes your working directory, which may be undesirable. Better docscript "%~dp0necdaily.vbs"
. Note there is no backslash between%~dp0
andnecdaily.vbs
.
– Gras Double
Apr 17 '17 at 22:42
add a comment |
You can use %~dp0
to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Usingpushd
changes your working directory, which may be undesirable. Better docscript "%~dp0necdaily.vbs"
. Note there is no backslash between%~dp0
andnecdaily.vbs
.
– Gras Double
Apr 17 '17 at 22:42
add a comment |
You can use %~dp0
to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
You can use %~dp0
to get the path of the currently running batch file.
Edited to change directory to the VBS location before running
If you want the VBS to synchronously run in the same window, then
@echo off
pushd %~dp0
cscript necdaily.vbs
If you want the VBS to synchronously run in a new window, then
@echo off
pushd %~dp0
start /wait "" cmd /c cscript necdaily.vbs
If you want the VBS to asynchronously run in the same window, then
@echo off
pushd %~dp0
start /b "" cscript necdaily.vbs
If you want the VBS to asynchronously run in a new window, then
@echo off
pushd %~dp0
start "" cmd /c cscript necdaily.vbs
edited Aug 14 '12 at 11:34
answered Aug 10 '12 at 21:50
dbenham
101k20178281
101k20178281
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Usingpushd
changes your working directory, which may be undesirable. Better docscript "%~dp0necdaily.vbs"
. Note there is no backslash between%~dp0
andnecdaily.vbs
.
– Gras Double
Apr 17 '17 at 22:42
add a comment |
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Usingpushd
changes your working directory, which may be undesirable. Better docscript "%~dp0necdaily.vbs"
. Note there is no backslash between%~dp0
andnecdaily.vbs
.
– Gras Double
Apr 17 '17 at 22:42
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
i tried all the commands but it still won't work.
– user918197
Aug 14 '12 at 6:48
1
1
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
@user918197 - ??? They work for me. Perhaps your VBS only works if the current directory matches the VBS location. Try the edits I made to the answer.
– dbenham
Aug 14 '12 at 11:37
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
does it have anything to do with 32-bit or 64-bit thing because my vbscript can't run in windows server 2008 R2 which is 64-bit and thats y i copy the whole folder containing the vbscripts into SysWOW64 directory and it was able to run when i type in the command, cscript necdaily.vbs but not in the batch file.
– user918197
Aug 15 '12 at 0:56
Using
pushd
changes your working directory, which may be undesirable. Better do cscript "%~dp0necdaily.vbs"
. Note there is no backslash between %~dp0
and necdaily.vbs
.– Gras Double
Apr 17 '17 at 22:42
Using
pushd
changes your working directory, which may be undesirable. Better do cscript "%~dp0necdaily.vbs"
. Note there is no backslash between %~dp0
and necdaily.vbs
.– Gras Double
Apr 17 '17 at 22:42
add a comment |
This is the command for the batch file and it can run the vbscript.
C:WindowsSysWOW64cmd.exe /c cscript C:WindowsSysWOW64...necdaily.vbs
add a comment |
This is the command for the batch file and it can run the vbscript.
C:WindowsSysWOW64cmd.exe /c cscript C:WindowsSysWOW64...necdaily.vbs
add a comment |
This is the command for the batch file and it can run the vbscript.
C:WindowsSysWOW64cmd.exe /c cscript C:WindowsSysWOW64...necdaily.vbs
This is the command for the batch file and it can run the vbscript.
C:WindowsSysWOW64cmd.exe /c cscript C:WindowsSysWOW64...necdaily.vbs
answered Aug 21 '12 at 0:24
user918197
53461127
53461127
add a comment |
add a comment |
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call
in front of it.
- To make the batch file continue without waiting, put start ""
in front of it.
I recommend using this single line script to accomplish your goal:
@call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use @ instead of @echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
@%WINDIR%SysWOW64cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
For the 1st command, maybe thecall
isn't even needed. The script is also executed synchronously without it. Usuallycall
is used to call a second batch script without mixing execution contexts. So, a tiny@cscript "%~dp0necdaily.vbs"
does the job.
– Gras Double
Apr 17 '17 at 22:38
add a comment |
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call
in front of it.
- To make the batch file continue without waiting, put start ""
in front of it.
I recommend using this single line script to accomplish your goal:
@call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use @ instead of @echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
@%WINDIR%SysWOW64cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
For the 1st command, maybe thecall
isn't even needed. The script is also executed synchronously without it. Usuallycall
is used to call a second batch script without mixing execution contexts. So, a tiny@cscript "%~dp0necdaily.vbs"
does the job.
– Gras Double
Apr 17 '17 at 22:38
add a comment |
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call
in front of it.
- To make the batch file continue without waiting, put start ""
in front of it.
I recommend using this single line script to accomplish your goal:
@call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use @ instead of @echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
@%WINDIR%SysWOW64cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
Batch files are processed row by row and terminate whenever you call an executable directly.
- To make the batch file wait for the process to terminate and continue, put call
in front of it.
- To make the batch file continue without waiting, put start ""
in front of it.
I recommend using this single line script to accomplish your goal:
@call cscript "%~dp0necdaily.vbs"
(because this is a single line, you can use @ instead of @echo off)
If you believe your script can only be called from the SysWOW64 versions of cmd.exe, you might try:
@%WINDIR%SysWOW64cmd.exe /c call cscript "%~dp0necdaily.vbs"
If you need the window to remain, you can replace /c with /k
edited Dec 4 '14 at 10:02
answered Dec 4 '14 at 9:46
Nico van der Stok
5113
5113
For the 1st command, maybe thecall
isn't even needed. The script is also executed synchronously without it. Usuallycall
is used to call a second batch script without mixing execution contexts. So, a tiny@cscript "%~dp0necdaily.vbs"
does the job.
– Gras Double
Apr 17 '17 at 22:38
add a comment |
For the 1st command, maybe thecall
isn't even needed. The script is also executed synchronously without it. Usuallycall
is used to call a second batch script without mixing execution contexts. So, a tiny@cscript "%~dp0necdaily.vbs"
does the job.
– Gras Double
Apr 17 '17 at 22:38
For the 1st command, maybe the
call
isn't even needed. The script is also executed synchronously without it. Usually call
is used to call a second batch script without mixing execution contexts. So, a tiny @cscript "%~dp0necdaily.vbs"
does the job.– Gras Double
Apr 17 '17 at 22:38
For the 1st command, maybe the
call
isn't even needed. The script is also executed synchronously without it. Usually call
is used to call a second batch script without mixing execution contexts. So, a tiny @cscript "%~dp0necdaily.vbs"
does the job.– Gras Double
Apr 17 '17 at 22:38
add a comment |
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
hope that helps :)
add a comment |
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
hope that helps :)
add a comment |
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
hope that helps :)
Well i am trying to open a .vbs within a batch file without having to click open but the answer to this question is ...
SET APPDATA=%CD%
start (your file here without the brackets with a .vbs if it is a vbd file)
hope that helps :)
answered Nov 19 '13 at 2:51
CustomerWhoIsJustNeedingHelp
111
111
add a comment |
add a comment |
Just try this code:
start "" "C:UsersDiPeshDesktopvbscriptwelcome.vbs"
and save as .bat, it works for me
add a comment |
Just try this code:
start "" "C:UsersDiPeshDesktopvbscriptwelcome.vbs"
and save as .bat, it works for me
add a comment |
Just try this code:
start "" "C:UsersDiPeshDesktopvbscriptwelcome.vbs"
and save as .bat, it works for me
Just try this code:
start "" "C:UsersDiPeshDesktopvbscriptwelcome.vbs"
and save as .bat, it works for me
answered Jul 29 '15 at 13:49
DIpesh
111
111
add a comment |
add a comment |
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%2f11899730%2frunning-vbscript-from-batch-file%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