Solved

Need help creating a batch file for running an audit program on a single PC

Posted on 2008-06-09
2
564 Views
Last Modified: 2010-04-21
We use OpenAudit to audit our PCs.  I need a batch file that does the following.  I'm struggling to get my version to work, and I'm not sure why.  I would script it, but I'm not well-versed at scripts yet.

1.  Change the directory to C:\wamp\www\openaudit\scripts
- I know that I can do that with cd c:\wamp\www\openaudit\scripts

2.  Ask the user for the PC name
- I have been using 'set /P choice=Name of PC?' as my command.

3.  Plug name of PC into line of code as follows: 'cscript audit.vbs [pcname]'
- Been using if commands with no luck.  Program just quits instead of running.

Also,I would like it If the PC name is left empty, generate an error, otherwise run the program.

Thoughts?  Thanks ahead of time!
0
Comment
Question by:flames1100
2 Comments
 
LVL 21

Accepted Solution

by:
JesterToo earned 500 total points
ID: 21747139
try this...

@echo off
setlocal

:begin

   C:
   CD \wamp\www\openaudit\scripts
   set /P choice=Name of PC?

   if "%choice%A"=="A" goto :error

   cscript audit.vbs %choice%
   goto :done

:error
   echo ERROR -- no computer name specified.

:done
0
 
LVL 2

Author Closing Comment

by:flames1100
ID: 31465805
Thanks so much!  That really helped.  I'll put the code I finally used below, which I modded a bit to do a little more.  I see my mistakes that I was making now.  Thanks again!

@echo off
setlocal

:begin

   C:
   CD \wamp\www\openaudit\scripts

:program

   set /P choice=Name of PC?

   if "%choice%A"=="A" goto :error

   cscript audit.vbs %choice%
   goto :done

:error
   echo ERROR -- no computer name specified.
   goto program

:error2
   echo ERROR -- invalid entry.
   goto :done

:done
set /P choice=Audit another?
if "%choice%"=="y" goto :program
if "%choice%"=="n" goto :exit
goto :error2

:exit
pause && exit
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now