Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

can  a file with .cmd extension be executed by a shell comman?

Posted on 2011-02-17
8
Medium Priority
?
305 Views
Last Modified: 2012-05-11
Hello,
   I'm not exactly sure if the title makes sense or not but any input would be appreciated. Thanks
0
Comment
Question by:sn1fflez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Accepted Solution

by:
sharkbot221984 earned 668 total points
ID: 34917993
Yes. A plaintext file with a .bat or .cmd extension will be executed by the shell program -usually COMMAND.  Typically used for 'batch' scripting.
0
 
LVL 8

Expert Comment

by:sharkbot221984
ID: 34918008
Try it for yourself: create a new text file called 'test.cmd' (note you will need to be able to view extensions) with this content:

@echo off
echo test
pause

change the extension to .bat

you'll get the same thing.
0
 
LVL 1

Expert Comment

by:Kidwell_03
ID: 34918010
I agree with sharkbot221984.  Any plaintext file with a .bat or. cmd extenstion can be executed via powershell.
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:sn1fflez
ID: 34918148
Thank you for the quick responses. Maybe you guys can tell me why the code below doesn't work?
retval = CStr(Shell("C:\Program\INT_Fortran_ComLink.cmd", 1))

retval is declared as string

Open in new window

0
 
LVL 5

Assisted Solution

by:rdhoore108
rdhoore108 earned 668 total points
ID: 34918322
I don't know Visual Basic very well, but I believe the problem is that you can't execute a cmd script, you need to execute it through cmd.exe:

retval = CStr(Shell("cmd.exe /c C:\Program\INT_Fortran_ComLink.cmd", 1))
0
 
LVL 58

Expert Comment

by:Bill Prew
ID: 34919900
==> Maybe you guys can tell me why the code below doesn't work?

Is that VB6 code that you are working with?  If so, I did think that you could initiate the BAT file directly from the Shell() function, without using cmd.exe.  What type of error or problem are you seeing?

~bp
0
 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 664 total points
ID: 34930575
You can execute a batch script from a batch script by using CALL command as follows...

Call C:\Program\INT_Fortran_ComLink.cmd

0
 

Author Closing Comment

by:sn1fflez
ID: 35018353
sorry it took me so long to respond. I eventually got it to work and what you guys said helped a lot. Thanks
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question