Solved

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

Posted on 2008-06-09
2
566 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sums of coloumns in html/java 15 76
Chocolatey under PowerShell is not working properly 3 61
Coding yesterday's date 3 26
Batch file or script with password 22 44
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

778 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