Solved

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

Posted on 2008-06-09
2
568 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
[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
2 Comments
 
LVL 22

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

756 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