Registry/Run problem with .bat file.

Mobz

New Member
I`m having some problems with an automatic application/updates installer script.
I have 3 different bat files, the 1st one containing different applications to install without user interruption, works fine. And the 2nd bat file containing Service Pack 2 installation, unattended install. And finally the 3rd bat file installs different windows update files, also unattended. And they all works perfectly fine, exactly as i want them to do:)

Problem:
That i have to be there when the computer restarts after bat1 to start bat2 and finally to start bat 3. (Ive written a script in the first bat file that turns off the UAC prompt, and then when almost finished with the 3rd one turns it on again).

Solution (I tought):
Would be to write to the registry run command and then when its done delete the entries in registry. And that works fine.
Code (example):
set var=%~dp0
REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\run /v Testauto /t REG_SZ /d %var%BAT2.bat
shutdown /r /f /t 05


Why i have set var=%~dp0 is because its stored on a usb stick, and that it will be given different drive paths on different computers.

Register entry:
Data name:Testauto Datavalue: G:\BAT2.bat
And everything looks good, exactly as i want.

Unsolved problem:
When my computer restarts it starts the BAT2.bat with all the commands ive given it.
But it doesnt run from the G:\ *all commands*. It starts the commands from C:\windows\system32 *all commands*. Why???
If i for example open the run box, and type:G:\BAT2.bat it starts as its supposed to.
Its like when it starts from the run in registry, its just call the bat file from cmd.exe.

Please tell me someone has a solution for this problem, because it starts to drive me crazy. (Sorry for my bad english im from Sweden).

Very very much thanks in advance.
/Mobz
 

My Computer

I`m having some problems with an automatic application/updates installer script.
I have 3 different bat files, the 1st one containing different applications to install without user interruption, works fine. And the 2nd bat file containing Service Pack 2 installation, unattended install. And finally the 3rd bat file installs different windows update files, also unattended. And they all works perfectly fine, exactly as i want them to do:)

Problem:
That i have to be there when the computer restarts after bat1 to start bat2 and finally to start bat 3. (Ive written a script in the first bat file that turns off the UAC prompt, and then when almost finished with the 3rd one turns it on again).

Solution (I tought):
Would be to write to the registry run command and then when its done delete the entries in registry. And that works fine.
Code (example):
set var=%~dp0
REG ADD HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\run /v Testauto /t REG_SZ /d %var%BAT2.bat
shutdown /r /f /t 05


Why i have set var=%~dp0 is because its stored on a usb stick, and that it will be given different drive paths on different computers.

Register entry:
Data name:Testauto Datavalue: G:\BAT2.bat
And everything looks good, exactly as i want.

Unsolved problem:
When my computer restarts it starts the BAT2.bat with all the commands ive given it.
But it doesnt run from the G:\ *all commands*. It starts the commands from C:\windows\system32 *all commands*. Why???
If i for example open the run box, and type:G:\BAT2.bat it starts as its supposed to.
Its like when it starts from the run in registry, its just call the bat file from cmd.exe.

Please tell me someone has a solution for this problem, because it starts to drive me crazy. (Sorry for my bad english im from Sweden).

Very very much thanks in advance.
/Mobz

Tjenare,

Would this work?

string value of any name into HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run, and set the value to the path of the batch file.
 

My Computer

System One

  • Manufacturer/Model
    Custom
    CPU
    AMD AM2 6000+
    Motherboard
    Nvidia M2N-E SLI
    Graphics Card(s)
    GeForce 7600GT
    Screen Resolution
    1280x1024
    Hard Drives
    WD
    Case
    Cooler Master
    Cooling
    Three fans
    Keyboard
    Dell Quietkey
    Mouse
    Dell Optical
    Internet Speed
    10 MBPS
Back
Top