Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

dos scripting question

Name: darkness_and_light 2008-06-24 1:44

Working on a hardware/software inventory project for a museum.  For budget reasons they can't afford to buy software to do the data collection.  As an intern they basically dropped the project in my lap and told me to have fun.

I could just write the project proposal to have each department fill out a paper form for each computer they own, which basically means interns in other departments will do my work for me.  However I've decided to cobble together something to do the data collection for them (also saving me the trouble of data entry).

I've written a batch file to take care of the data collection on each local computer.  Now I'm wondering how I'm going to process all these files once they all get sent back to me.  One idea I have is to put all the data files(hopefully with unique names) into one directory, route the results of a DIR into a .txt file then sequentially operate on the file matching each of the names in the .txt file.

Anyone have any better ideas or suggestions on another way to do this?  I've worked with C++, Java, and VB but I haven't done anything with them involving working with directories or files.

Name: Anonymous 2008-06-24 1:45

Here is the batch file I wrote if anyone is interested:

@echo off

name.vbs

echo Checking registry for software licenses
rem Adobe licenses
regedit.exe /e photoshopcs2.txt HKEY_LOCAL_MACHINE\SOFTWARE\ADOBE\PHOTOSHOP\9.0\
regedit.exe /e photoshopcs3.txt HKEY_LOCAL_MACHINE\SOFTWARE\ADOBE\PHOTOSHOP\10.0\
regedit.exe /e illustratorcs2.txt HKEY_LOCAL_MACHINE\SOFTWARE\ADOBE\ILLUSTRATOR\11.0\
regedit.exe /e illustratorcs3.txt HKEY_LOCAL_MACHINE\SOFTWARE\ADOBE\ILLUSTRATOR\12.0\

rem Microsoft Office licenses
regedit.exe /e office2000.txt HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\OFFICE\9.0\
regedit.exe /e officexp.txt HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\OFFICE\10.0\
regedit.exe /e office2003.txt HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\OFFICE\11.0\
regedit.exe /e office2007.txt HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\OFFICE\12.0\

rem FileMaker licenses
regedit.exe /e filemakerpro8.txt "HKEY_LOCAL_MACHINE\SOFTWARE\FILEMAKER\FILEMAKER PRO\8.0\"
regedit.exe /e filemakerpro9.txt "HKEY_LOCAL_MACHINE\SOFTWARE\FILEMAKER\FILEMAKER PRO\9.0\"

rem Macromedia Dreamweaver licenses
regedit.exe /e dreamweaver8.txt "HKEY_CURRENT_USER\SOFTWARE\DREAMWEAVER 8\"

echo Checking version of Windows
copy C:\WINDOWS\system32\prodspec.ini version.txt

echo Checking system information
winmsd /categories +SystemSummary-Resources-Components+ComponentsStorageDrives-SWEnv-InternetExplorer-Apps /report systeminfo.txt

complete.vbs

Name: Anonymous 2008-06-24 1:50

if anyone is interested

Name: Anonymous 2008-06-24 2:23

Let me be the first to say, nice job so far.  Posts >>5-999 will be shit.

Name: Anonymous 2008-06-24 2:49

>>2
This don't look like DOS to me.

Name: Anonymous 2008-06-24 2:52

>>1
Why don't you just use one of Lisp, perl, FIOC, &c? Lisp especially, since if you dump out your data as sexps you can read it in with READ, making it directly useful without regexes and shit.

Name: darkness_and_light 2008-06-24 3:16

>>5
It is DOS,  I'm calling Microsoft applications from the command line to generate log files in .txt format.  The only real DOS command I'm using so far is copy.

>>6
I'm writing it with DOS and some .vbs because thats what I know how to use.  The data comes out in the format used by the Microsoft regedit.exe and winmsd.exe applications.  I have another batch file that checks for the existence of the regedit output files then writes a 0 or 1 in the summary.txt file on the appropriate line.  Alternatively I could have just output the entire HKEY_LOCAL_MACHINE\SOFTWARE\ tree and parsed it, but this seemed easier.  I will have to write something to parse the winmsd.exe output though.


The problem isn't processing the data for the individual computers, thats more or less done.  The problem is processing all of the reports generated by all 200+ computers.  The name.vbs script at the top of the batch file should get them to generate a unique name for each computer's report, but once I receive them all I'm trying to figure out how to process them into a single file that I'm in turn going to feed into a database, which I'm researching how to do right now too.

I'm just glad I don't have to do this for the Macs littered around the grounds, apparently one of the department heads already took care of it.

Name: Anonymous 2008-06-24 3:26

>>7
What's a DOS machine doing with a registry and VBscript? I do not believe you.

The problem isn't processing the data for the individual computers, thats more or less done.  The problem is processing all of the reports generated by all 200+ computers.
Right. This is the task that Lisp, perl, or FIOC would be perfect for. No need to deliver the necessities for the language to the users' machines, so you can use what you like. Munging this data with a batch file would be insane.

Name: darkness_and_light 2008-06-24 3:43

>>8

Its a Window XP Pro machine, but I'm writing a .bat file using notepad which uses DOS commands. 

Basically I'm going to have 200+  files named ento01.txt, anthro5.txt, astro04.txt, or whatever that I'm going to dump into the same directory.  The files are probably going to be in something like:

Windows XP Professional
x86 Family 6 Model 15 Stepping 2 GenuineIntel ~1728 Mhz
2,048.00
106.72 GB
0
1
0
0
0
0
1
1
0
etc.

I studied Perl for a little bit, but I don't remember a way to sequentially execute a process on the contents of a directory.  Actually now that you bring up Perl I should ask at the web development place I intern at if SQL might have functions built in I could use.

Name: Anonymous 2008-06-24 3:51

>>1
If all the computers are in a LAN, you should take a look at OCS-NG : http://www.ocsinventory-ng.org/

Name: Anonymous 2008-06-24 3:55

Its a Window XP Pro machine, but I'm writing a .bat file using notepad which uses DOS commands.
you're not using DOS commands. you're using Windows commands.

Name: Anonymous 2008-06-24 4:28

1. They are windows commands. Terminal != DOS.
2. Here's how you do it with perl:

# for all *.txt files
for my $filename(<*.txt>){

    # open file
    open HANDLE,$filename;
   
    # do things with file, like
    my $line=<HANDLE> # read line from file
    read <HANDLE>,my $data,12 # read 12 bytes from file
   
    # close file; not really necessary
    close HANDLE;
}

Name: darkness_and_light 2008-06-24 4:43

>>11
Do we really have to argue semantics?  The command prompt is functionally and visually similar to DOS.  Yes, I realize its just a virtual machine.

Name: darkness_and_light 2008-06-24 4:51

>>12

So its a for-loop using a function built into the scalar variable type?  I'll look into it.

Name: Anonymous 2008-06-24 5:12

>>1
VBScript should have all the tools you need for text file parsing.

e.g. here is code to read a file line by line:

Set FSO = CreateObject("Scripting.FileSystemObject")
set TS = FSO.OpenTextFile("text.txt")

Do Until TS.AtEndOfStream
  L = TS.ReadLine
  '
  ' TODO: everything else
  '
Loop

Name: Anonymous 2008-06-24 5:13

>>13
Do we really have to argue semantics?
This is /prog/, arguing semantics is considered good sport here.

Name: Anonymous 2008-06-24 5:17

>>13
It's not semantics, namefag. Calling Windows XP DOS is like calling Plan 9 Linux.

Name: Anonymous 2008-06-24 5:24

>>15
And you can also access databases with it using ADO objects, e.g.

Set con = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
con.ConnectionString = "..." ' your data source. see http://www.connectionstrings.com/ for hints
con.Open
Set cmd.ActiveConnection = con
cmd.CommandText = "insert boards (name, useless) values ('/prog/', 'yes')"
cmd.Execute

Name: darkness_and_light 2008-06-24 5:26

>>17

I used those commands on my Dad's old IBM PC before I even heard of Windows.  The platform they are running on may have changed, but I used them on DOS first so I call them DOS commands so yes it is just semantics. 

Note I am not calling the Command Prompt DOS, I am calling the commands I use at the Command Prompt DOS commands because thats where they came from.

Name: Anonymous 2008-06-24 5:27

>>17
The Windows command line is directly derived from the one in DOS, and contains a superset of its commands. It's no real stretch to refer to it as "DOS scripting".

Name: Anonymous 2008-06-24 5:39

>>20
That was true in Windows 95/98/Me but not in NT.

>>19
Try taking the copy.com file from Windows XP and running it on DOS. It probably won't work.

Name: Anonymous 2008-06-24 5:45

>>21
The COPY command has always been built in to the command shell.

Name: Anonymous 2008-06-24 5:47

>>21
By "derived", I didn't mean binary compatibility, or even evolution of source code. More like how Linux is derived from Unix, for example.

Name: darkness_and_light 2008-06-24 5:48

Except for the calls to VB scripts which are really only there to get the users attention and easily replaced with DOS commands and assuming there were equivalent DOS utilities with the same flags, and the files the utilities access were in the correct place it would work just fine.

Name: Anonymous 2008-06-24 5:52

>>24
wat

Name: Anonymous 2008-06-24 5:55

>>22
I was hoping he'd spend a couple hours trying to find it, you idiot!

>>23
Except in this case it's more like how Plan 9 is derived from Unix.

Name: darkness_and_light 2008-06-24 5:58

But back on topic, another thought occurred to me.  I'm not limited to just DOS batch files, I can use Windows scripts.  Windows scripting is probably better equipped to work with files and directories.  The actual program performing the parsing can be VB, C++ or whatever.

Thanks, anon.  Arguing semantics actually gave me a push in the right direction.

Name: Anonymous 2008-06-24 6:02

>>26
NO U

Name: Anonymous 2008-06-24 6:17

>>27
Why don't you get it? You are already using windows scripts. NT added a bunch of unix functionality but that won't help you.

Go and write the damn program already in your visual basic.

Name: Anonymous 2008-06-24 7:39

Now I'm wondering how I'm going to process all these files once they all get sent back to me.  One idea I have is to put all the data files(hopefully with unique names) into one directory, route the results of a DIR into a .txt file then sequentially operate on the file matching each of the names in the .txt file.
This is trivial in unix. Install Cygwin or MinGW and learn basic unix commands (find, xargs, grep, sed probably suffice) and command piping.

Name: Anonymous 2008-06-24 8:13

Name: Anonymous 2008-06-24 8:52

>>1-2,7,9,13-14,19,24,27
10/10. Truly masterful troll.

Name: Anonymous 2008-06-24 9:00

Nice name.

Name: Anonymous 2008-06-24 9:20

>>32
Think about it. He wrote almost more than we all replied. Do you call that ``Truly masterful troll''? Or do you have no idea what ``troll'' means?

Name: Anonymous 2008-06-24 9:25

>>31
Why are you a stupid faggot?  Use GnuWin32 moron.

Name: Anonymous 2008-06-24 9:55

WELCOME TO THE 198O'S BITCHES, FUCKING BUMP

Name: Anonymous 2008-06-24 11:16

>>13
It's not a virtual machine. It's all Win32. Yes, there is/was some kind of virtual machine too, but only for real DOS programs.

Name: Anonymous 2008-06-24 16:54

>>13
>>37
I lold. I was this close (--> ||) to posting that.

Name: Anonymous 2009-06-16 18:09

test

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List