Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-09
2
Medium Priority
?
572 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 22

Accepted Solution

by:
JesterToo earned 2000 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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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.
The viewer will learn how to dynamically set the form action using jQuery.
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.
Suggested Courses

824 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