Solved

Create batch file to run a command line script.

Posted on 2004-09-29
4
9,978 Views
Last Modified: 2012-05-05
Currently we have a script that is run from a command prompt.  The script is installed on several independent machines and the user types "cscript filescrc.vbs" from the C:\ prompt.  The problem is that when a user goes to START -- RUN, types cmd and gets a command prompt, the user is usually sitting at "C:\Documents and Settings\<username>\...." or so other various place.  It is almost impossible to explain how to use "cd.." to work their way to a "C:\" prompt and we have files going everywhere.

I would like to write a simple batch file that the user can double click on the desktop.  When they click the batch file it will automatically bring up a command prompt, run the script "C:\cscript filescrc.vbs",  and the command prompt box will stay open so they can see that the .vbs script successfully completes.  I'm not worried about automatically closing the command prompt box. The user can exit the command prompt themselves.

Can this be done?  I'm sure it would only be a few lines.  If anyone knows I would sure appreciate the help.

thanks,
Jeff

0
Comment
Question by:jplagens
4 Comments
 
LVL 3

Accepted Solution

by:
PodExpert earned 300 total points
ID: 12183362
Save the following commands to the script.bat file:

@start /WAIT cscript c:\filescrc.vbs
@echo Now press any key and close the window.
@pause

It should do what you need when executed from anywhere.
0
 
LVL 5

Assisted Solution

by:kemp_a
kemp_a earned 200 total points
ID: 12186405
That will also put you in the wrong directory, try saving this to a file called script.bat which can be anywhere so try your Desktop to start with:

@ECHO OFF
c:
cd\
start /wait  cscript c:\filescrc.vbs
echo Press any key to  close the window
pause
@ECHO ON

Alternatively, you could recode your vbs script so that it starts what it needs to do from root of the C:\ drive.

Cheers
0
 
LVL 4

Author Comment

by:jplagens
ID: 12186824
That is EXACTLY what I needed.  Thank you for all of your help.  It is greatly appreciated.  I got this new script installed and taught the users to click on the batch file and it is working a lot smoother now.  Thanks!
0
 

Expert Comment

by:londell1
ID: 12316306
Hi, I have exchange 5.5 server running on Windows NT 4.0 server. In setting up server monitor and selecting launch a process, I would like to setup a script that will page me when there is a problem with the exchange server. How do I go about building a script for that purpose? Can any one help me? Many thanks!!

Londell
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

776 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