Solved

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

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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 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 how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

739 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