Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with code 1

Status
Not open for further replies.

jono261970

Programmer
Jun 28, 2002
182
GB
We have a computer suite of 40 win98 workstations and use drive image to deploy an image to all machines in one sweep. Works fine except I have to change the ID of each machine individually or there's trouble.
I boot into DOS using a win98 startup disk or by pressing F8 and run a simple registry import.

I exported the following registry file and saved it as update.reg. I then type "regedit update.reg" and it updates the machine's ID before I boot it up.

-----------------------------------------------------------
Inside update.reg file:-

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName]
"ComputerName"="W13-1"
----------------------------------------------------------
The only problem is I have to either have 40 unique disks or keep on editing the "computer name" part for each computer.

What I would like is a dos program that would ask me to type in the computer name and then change the computer name for me. Ok, I am finding this hard to explain :O)
This is what I want to do:-

please enter name?
input name$
Then the contents of name$ go into the update.reg file below:-

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName]
"ComputerName"=name$

I hope somebody can understand what I need.

Thanks in advance

jono
 
Ok, here the thing I just done.
I checked it on my Win 98 computer, so it should be workable ;)
(In DOS box, no test in DOS been done.)
The bat file to be run:
(regupd.bat)
Code:
------------------
qbasic /run regupd.bas
------------------
(obviously needs qbasic.exe to work)
The program it calls:
(regupd.bas)
Code:
------------------
PRINT
PRINT "please enter name?"
INPUT name$
'Then the contents of name$ go into the update.reg file below:-
'well, if file exists it would be re-written
OPEN "update.reg" FOR OUTPUT AS #1
PRINT #1, "REGEDIT4"
PRINT #1,
PRINT #1, "[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName]"
PRINT #1, CHR$(34) + "ComputerName" + CHR$(34) + "=" + CHR$(34) + name$ + CHR$(34)
CLOSE
'now let's see what we got
PRINT "---------------------------"
SHELL "type update.reg"
PRINT "---------------------------"
PRINT "apply? y/n"
a$ = INPUT$(1)
IF a$ = "y" OR a$ = "Y" THEN
   SHELL "regedit update.reg"
   PRINT "Update done"
ELSE
   PRINT "Update canceled"
END IF
SYSTEM 'and quits to system if was run by qbasic /run regupd.bas
------------------
Hoping to be of any help.
 
Hello TSH,

Thank you very, very much for replying. Your code worked a treat.
Now, can you tell me how to stop the qbasic program from opening :O)

At a dos prompt I type qbasic /r update.bas. It then runs the program but when it's finished qbasic is still open.

Secondly I tried to compile with first basic but it's displays an error on the "input" command.

Any ideas about how to compile a .bas file.

Again thank you for taking the time to help me.

Kind regards,

jono
 
Hello jono261970, you wrote:
>At a dos prompt I type qbasic /r update.bas.
>It then runs the program but when it's finished qbasic is still open.

Well, the command "SYSTEM" in the end of a program supposed to close it.
At least it works so then I run it with line
"qbasic /run regupd.bas"
BTW, I use version 1.1; and it doesn't recognise "/r" switch, as in
"qbasic /r update.bas".
As to compile - you'll probably have to find QB4 or 4.5 or 7.1 (as was already said by quebasic2).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top