Jump to content

Batch script start up from RunOnce registry fails !


Recommended Posts

Hi, Im trying to make a batch file, that installs a bunch of applications silently, and works awesome on Windows XP, but WIndows 7 with UAC Enabled is problem, I tryed a lot of tricks to bypass it, and failed !

However Im trying to Disable Windows UAC with this line of batch code !

reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v DisableUAC /t REG_DWORD /d 0 /f

And works perfectly, since to take effect machine must reboot, and it's not good choice since bypassing UAC would make all work easier, and I add another reg key to RunOnce, when machine starts up, launch that .bat file which installs silently applications !


set BATDIR=%~dp0
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /f /v One_Click_Installer /t REG_SZ /d "%BATDIR%win7.bat"
shutdown -r -f -t 5 -c "Machine will reboot within 5 sec's !"

And it reboots, on startup launches win7.bat, which is batch file containing code to start installing applications, but I don't know whats the difference launchin this bat file on startup, it doesnt work, it's like just showing for example 'application x installed finished' but actually it's going fast to all applications but it doesnt work, when I double click to the same batch file, works perfeclty !

If you want I can post that .bat file code, win7.bat .

So I just want to know, whats the difference, when same batch file launched directly works, when it starts up with RunOnce registry fails ?

If anyone has any trick that can run batch file, that executes exe's silently bypassing UAC, would be good to tell me !

Thanks !

Link to comment
Share on other sites


[if you want I can post that .bat file code, win7.bat

I would suggest that you'd have been better advised to post the 'bat' file which isn't working instead of the code which is!

Link to comment
Share on other sites

Yzöwl, thanks for your respond, I will post all code, and the structure of files and folders !

http://snag.gy/QTBDF.jpg

6oMZJ.jpg

Code of Launch.bat, which is in root folder, it detects what OS is machine runing, and If it is Windows XP calls winxp.bat in tools folder, If it is Windows 7, calls sched.bat !

@echo off
color 0f

ECHO Hey %username%,please wait,detecting OS !
ECHO+
ver | find "2003" > nul
if %ERRORLEVEL% == 0 goto ver_2003

ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto ver_xp

ver | find "2000" > nul
if %ERRORLEVEL% == 0 goto ver_2000

ver | find "NT" > nul
if %ERRORLEVEL% == 0 goto ver_nt

if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit > nul

systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i

echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto ver_7

echo %vers% | find "Windows Server 2008" > nul
if %ERRORLEVEL% == 0 goto ver_2008

echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto ver_vista

goto warnthenexit

:ver_7
:Run specific commands
cls
echo Windows 7 Detected !
call tools/sched.bat
goto exit

:ver_2008
:Run Windows Server 2008 specific commands here.
echo Windows Server 2008
goto exit

:ver_vista
:Run Windows Vista specific commands here.
echo Windows Vista
goto exit

:ver_2003
:Run Windows Server 2003 specific commands here.
echo Windows Server 2003
goto exit

:ver_xp
echo Windows XP
CD tools
call winxp.bat

goto exit

:ver_2000
:Run Windows 2000 specific commands here.
echo Windows 2000
goto exit

:ver_nt
:Run Windows NT specific commands here.
echo Windows NT
goto exit

:warnthenexit
echo Machine undetermined.
pause
:exit

sched.bat code works good, adds registry keys, successfuly, and reboots machine !


@echo off
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

set BATDIR=%~dp0
reg add HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce /f /v One_Click_Installer /t REG_SZ /d "%BATDIR%win7.bat"
pause
shutdown -r -f -t 5 -c "Machine will reboot within 5 sec's !"

win7.bat works only If I click directly, starts to install applications silently, when starts from RunOnce registry, immediatly shows message 'All Applications installed !' , actually just skips all other commands, and pauses in the end !

This is really weird, If you can help me what is wrong ?

@ECHO off
CD..
CD "apps/winrar/"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !

CD..
CD teamviewer
cls
ECHO Installing TeamViewer
teamviewer.exe /S
cls
ECHO Installation Completed

CD..
CD chrome
cls
ECHO Installing Chrome
chrome.exe /silent /install
cls
ECHO Installation completed !
ECHO.
cls
ECHO All Applications installed !

pause > NUL

I will upload all this root folder, containing, apps folder and .batch files, it's 40MB as Chrome size is ~ 30MB, If anyone want to test it out easier !

Download link

https://mega.co.nz/#!RRwz3RQB!j2NOFRjiV-N7s6r6CqWdXGA8ovUJ2_xW0y9OSN6J2oo

Link to comment
Share on other sites

Don't see where your have a path set for your first run for your apps, also instead of putting in your switch flags in code, works better if you just create a winrar sfx file for each app with switch , If you want to install your apps after uac is disabled and system is rebooted on runonce first run try something like this.. DP yes.gif

@echo off
:: STEP 1 - Before reboot
::Setup First Run for your apps
:: FIRST-RUN (Setup SFX App Installs-Put all your sfx .exe files in the Run distribution folder)
set source="C:\Windows\System32\run\First-Run.cmd"
reg add "hklm\software\microsoft\windows\currentversion\run" /v "First-Logon" /t REG_SZ /d "%source%" /f >nul

::Disable UAC (Requires a reboot)
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v enableLUA /t REG_DWORD /d 0 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v PromptOnSecureDesktop /t REG_DWORD /d 1 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 2 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v ConsentPromptBehaviorUser /t REG_DWORD /d 1 /f>nul

::Restart for changes..
shutdown.exe -r -t 00 -f

::STEP 2 - After reboot - will run all your apps from desktop then cleanup everything..
:: FirstRun.cmd file from Run directory in System32
@echo off
cd %~dp0
cls&color e&echo ==Installing "WINDOWS 7 APPS"...Please Wait!
ping.exe 127.0.0.1 -n 4 >nul

::Variables..
set rd=rd /s/q
set del=del /q/f::INSTALL YOUR SFX .EXE FILES
::Sfx App Installer (Installs in alphabetical order)..
for /f "delims=" %%a in ('dir/b "%source%\*.exe"') do (
echo == Installing Apps == "%%a"
:: Delay..
ping -n 2 localhost 1>nul
start "" /wait "%source%\%%a"
)
cls
popD
::CLEANUP INSTALL CRAP
::Remove from MSConfig Run..
reg delete "hklm\software\microsoft\windows\currentversion\run" /v "First-Logon" /f>nul

::Temp..
attrib -r -a -s -h "%localappdata%\tmp" /d /s && attrib -r -a -s -h "%localappdata%\tmp\*.*" /s /d
rd /s /q "%tmp%" >nul
if not exist %tmp% md %tmp% >nul

::Desktop Shortcuts..
attrib -r -a -s -h "%userprofile%\desktop\desktop.ini">nul /d /s && attrib -r -a -s -h "%systemdrive%\users\public\desktop\desktop.ini">nul /d /s
for %%a in (ini lnk) do %del% %userprofile%\desktop\*.%%a>nul && for %%a in (ini lnk) do %del% %systemdrive%\users\public\desktop\*.%%a>nul

::Run Directory Multi file and folder cleanup..
for %%a in (cmd reg vbs xml) do %del% %~dp0\*.%%a>nul&%rd% dat scripts>nul 2>&1
cls
Echo.&Echo. == ALL Installation's Done! ==
ping.exe 127.0.0.1 -n 4 >nul
exit

Edited by DosProbie
Link to comment
Share on other sites

Don't see where your have a path set for your first run for your apps, also instead of putting in your switch flags in code, works better if you just create a winrar sfx file for each app with switch , If you want to install your apps after uac is disabled and system is rebooted on runonce first run try something like this.. DP yes.gif

@echo off
:: STEP 1 - Before reboot
::Setup First Run for your apps
:: FIRST-RUN (Setup SFX App Installs-Put all your sfx .exe files in the Run distribution folder)
set source="C:\Windows\System32\run\First-Run.cmd"
reg add "hklm\software\microsoft\windows\currentversion\run" /v "First-Logon" /t REG_SZ /d "%source%" /f >nul

::Disable UAC (Requires a reboot)
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v enableLUA /t REG_DWORD /d 0 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v PromptOnSecureDesktop /t REG_DWORD /d 1 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 2 /f>nul
reg add "hklm\software\microsoft\windows\currentversion\policies\system" /v ConsentPromptBehaviorUser /t REG_DWORD /d 1 /f>nul

::Restart for changes..
shutdown.exe -r -t 00 -f

::STEP 2 - After reboot - will run all your apps from desktop then cleanup everything..
:: FirstRun.cmd file from Run directory in System32
@echo off
cd %~dp0
cls&color e&echo ==Installing "WINDOWS 7 APPS"...Please Wait!
ping.exe 127.0.0.1 -n 4 >nul

::Variables..
set rd=rd /s/q
set del=del /q/f::INSTALL YOUR SFX .EXE FILES
::Sfx App Installer (Installs in alphabetical order)..
for /f "delims=" %%a in ('dir/b "%source%\*.exe"') do (
echo == Installing Apps == "%%a"
:: Delay..
ping -n 2 localhost 1>nul
start "" /wait "%source%\%%a"
)
cls
popD
::CLEANUP INSTALL CRAP
::Remove from MSConfig Run..
reg delete "hklm\software\microsoft\windows\currentversion\run" /v "First-Logon" /f>nul

::Temp..
attrib -r -a -s -h "%localappdata%\tmp" /d /s && attrib -r -a -s -h "%localappdata%\tmp\*.*" /s /d
rd /s /q "%tmp%" >nul
if not exist %tmp% md %tmp% >nul

::Desktop Shortcuts..
attrib -r -a -s -h "%userprofile%\desktop\desktop.ini">nul /d /s && attrib -r -a -s -h "%systemdrive%\users\public\desktop\desktop.ini">nul /d /s
for %%a in (ini lnk) do %del% %userprofile%\desktop\*.%%a>nul && for %%a in (ini lnk) do %del% %systemdrive%\users\public\desktop\*.%%a>nul

::Run Directory Multi file and folder cleanup..
for %%a in (cmd reg vbs xml) do %del% %~dp0\*.%%a>nul&%rd% dat scripts>nul 2>&1
cls
Echo.&Echo. == ALL Installation's Done! ==
ping.exe 127.0.0.1 -n 4 >nul
exit

First of all thanks for your answer !

Don't see where your have a path set for your first run for your apps

First run Launch.bat detects OS, If XP just calls winxp.bat and installation begins, and finish successfuly, If Os is Windows 7, Launch.bat calls sched.bat, which adds registry and adds path of win7.bat, which needed on next startup to launch and install applications as UAC is disabled !

I dont know path you asking exaclty, however your solution does not solve my problem, as all exe's I have to install silently, let it be known that I have 14 exe's files to install, I just ripped out the code so you can review it easier, and all these exe's are not packed with SFX, but are original exe's If you noticed there are different switches for every each exe to install silently, some are /S another /s, and others /silent etc !

So what is really different of launching of .bat file from RunOnce registry, this is really confusing me ?

Any solution for this problem thanks !

Link to comment
Share on other sites

Try running this modified win7.bat, both form command line and from runonce....

@ECHO off
DIR ../apps/winrar/
ECHO Does this throw an error?
PAUSE
DIR
ECHO In which PATH (directory) am I?
PAUSE

CD..
CD "apps/winrar/"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
ECHO All Applications installed !

pause > NUL

jaclaz

Link to comment
Share on other sites

Try running this modified win7.bat, both form command line and from runonce....

@ECHO off
DIR ../apps/winrar/
ECHO Does this throw an error?
PAUSE
DIR
ECHO In which PATH (directory) am I?
PAUSE

CD..
CD "apps/winrar/"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
ECHO All Applications installed !

pause > NUL

jaclaz

Thanks for your respond, but runing directly it works installs WinRAR, but from RunOnce fails.

I have recorded whole process, so you can watch it !

http://vimeo.com/65975371

Any idea how to fix this ?

Link to comment
Share on other sites

You could add this code in Launch.bat to detect win7 as you did for earlier OS version.

(and remove those few lines using systeminfo command.

ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_7

For win7.bat, I made these small changes

@ECHO off
CD %~dp0 <-----new code
CD..
CD "apps/winrar/"
ECHO Installing WinRAR
start "winrar" /wait winrar.exe /s <-----modify code
cls
ECHO WinRAR Installation completed !

Note: I tested under VM win7x86 with winrar.exe only. (I have admin-right with UAC enabled)

I still get UAC warning prior to install winrar.exe

If I allow to install, Winrar installed successfully.

Cheers

Link to comment
Share on other sites

Thanks for your respond, but runing directly it works installs WinRAR, but from RunOnce fails.

I have recorded whole process, so you can watch it !

http://vimeo.com/65975371

Any idea how to fix this ?

I thought my idea was clear enough and anyway Geej explicited it.

Did you notice how the output of the added DIR command was NOT the same in the two runs? :unsure:

In the original batch you are using relative paths" that may be NOT the same when you run the app manually and when you run it from runonce.

The:

CD %~dp0   

should make a whole lot of difference (at least the program will run always from the directory where win7.bat resides.

jaclaz

Link to comment
Share on other sites

If you install apps with install.bat in current directory you can do a runonce including your switches like so..

[

@echo off

cd %~dp0

::POST INSTALLS-(root of cd/usb/hard drive)::

for %%i in (d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%i:\apps\install.bat set cd=%%i:

set key=hklm\software\microsoft\windows\currentversion\runonceex

reg add %key%\02 /v 1 /d "%cd%\apps\7zx64.msi /qn" /f

reg add %key%\04 /v 1 /d "%cd%\apps\winrar.exe /s" /f

<remainer of apps with silent switches>

Edited by DosProbie
Link to comment
Share on other sites

Thank you all for your answers, after a lot of testings going on, I have solve part of my problem, I will describe below !

Now even my code in the begining of this thread works now, the problem was win7.bat, as DosProbie asked me about me that the path is not set, I didnt understand and now I set path in the begining of win7.bat like this

@ECHO off
CD %~dp0
CD..
CD "apps/winrar/"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !

CD..
CD teamviewer
cls
ECHO Installing TeamViewer
teamviewer.exe /S
cls
ECHO Installation Completed

CD..
CD chrome
cls
ECHO Installing Chrome
chrome.exe /silent /install
cls
ECHO Installation completed !
ECHO.
cls
ECHO All Applications installed !

pause > NUL

But now the problem appears when I launch this script from USB Flash Disk, after I paused the code, after scripts launches I saw the path was on C:\Windows then scripts fails at all finding folders path's of exe's !

How this problem can be solved, now when script starts from USB Flash disk script fails !?

Edited by ZYklon
Link to comment
Share on other sites

But now the problem appears when I launch this script from USB Flash Disk, after I paused the code, after scripts launches I saw the path was on C:\Windows then scripts fails at all finding folders path's of exe's !

How this problem can be solved, now when script starts from USB Flash disk script fails !?

Let's start again from scratch, OK?

HOW is the directory structure you use made?

Example (this is what I would personally use):

ROOT

--------->Mynicebats

-------------------------->Launch.bat

-------------------------->Winxp.bat

-------------------------->Win7.bat

-------------------------->Apps [DIR]

------------------------------------------>Winrar [DIR]

------------------------------------------------------------>winrar.exe

------------------------------------------>Chrome [DIR]

------------------------------------------------------------>chrome.exe

... etc.

Now, you can use:


@ECHO off
CD /D %~dp0
CD "apps\winrar\"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
....

Which will change the directory (no matter which drive it is) to the "Mynicebats" directory and then change it to Mynicebats\apps\winrar or do something easier (two possibilities):


@ECHO off
CD /D %~dp0apps\winrar
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
....

There is seemingly no need to actually change directory at all.


@ECHO off
ECHO Installing WinRAR
%~dp0apps\winrar\winrar.exe /s
cls
ECHO Installation completed !
....

or:


@ECHO off
ECHO Installing WinRAR
START /WAIT "" %~dp0apps\winrar\winrar.exe /s
cls
ECHO Installation completed !
....

jaclaz

Link to comment
Share on other sites

But now the problem appears when I launch this script from USB Flash Disk, after I paused the code, after scripts launches I saw the path was on C:\Windows then scripts fails at all finding folders path's of exe's !

How this problem can be solved, now when script starts from USB Flash disk script fails !?

Let's start again from scratch, OK?

HOW is the directory structure you use made?

Example (this is what I would personally use):

ROOT

--------->Mynicebats

-------------------------->Launch.bat

-------------------------->Winxp.bat

-------------------------->Win7.bat

-------------------------->Apps [DIR]

------------------------------------------>Winrar [DIR]

------------------------------------------------------------>winrar.exe

------------------------------------------>Chrome [DIR]

------------------------------------------------------------>chrome.exe

... etc.

Now, you can use:


@ECHO off
CD /D %~dp0
CD "apps\winrar\"
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
....

Which will change the directory (no matter which drive it is) to the "Mynicebats" directory and then change it to Mynicebats\apps\winrar or do something easier (two possibilities):


@ECHO off
CD /D %~dp0apps\winrar
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !
....

There is seemingly no need to actually change directory at all.


@ECHO off
ECHO Installing WinRAR
%~dp0apps\winrar\winrar.exe /s
cls
ECHO Installation completed !
....

or:


@ECHO off
ECHO Installing WinRAR
START /WAIT "" %~dp0apps\winrar\winrar.exe /s
cls
ECHO Installation completed !
....

jaclaz

Thanks jaclaz for your answer, and this code you provided I tryed first example worked with your files & folders structure, works from USB Flash Drive and from example Desktop, but my structure is little bit different, and would be awesome If you can help me to work on this structure I will explain below -->

ROOT

--------------->OneClickInstaller [DIR]

--------------->Launch.bat

------------------------>tools [DIR]

-----------------------------> sched.bat

-----------------------------> winxp.bat

-----------------------------> win7.bat

------------------------.>apps [DIR]

------------------------------> Chrome [DIR]

--------------------------------------> chrome.exe

------------------------------> Teamviewer [DIR]

--------------------------------------> teamviwer.exe

------------------------------->Winrar [DIR]

-------------------------------------->winrar.exe

Let me explain, why I put winxp.bat, win7.bat and sched.bat on tools folder, well I want to be automated, when Launch.bat is clicked, user doesnt need to be worried anymore, just all apps start to install silently, so I want this structure !

I tryed this

CD %~dp0
CD..
CD /D %~dp0apps\chrome
and rest of code ...

Didnt worked, so just need one directory back, as win7.bat is now in tools folder !?

Thanks in advance !

Edited by ZYklon
Link to comment
Share on other sites

Didnt worked, so just need one directory back, as win7.bat is now in tools folder !?

Not really :no: (you don't *need* one directory back, you *want* one directory back, it's not the same thing).

And then you want two directories down.

And you didn't take more than 1 second to try and understand the syntax of the example. :w00t:

The idea is:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

CD .. <- this changes to one directory up, in your case ROOT\OneClickInstaller\

CD .\apps\chrome <- this changes to two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0..\apps\chrome <- this changes to one directoty up to the one in which Win7.bat is, no matter on which drive , two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

CD ..\apps\chrome <- this changes to two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

..\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

CD /D %~d0 <- this changes current directory to the ROOT of the drive in which Win7.bat is, no matter on which drive, in your case ROOT\

.\OneClickInstaller\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

%~d0\OneClickInstaller\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

%~dp0..\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

It makes (to me) very little sense to have a \tools directory containing just three (lousy :ph34r:) batches and a separate \apps directory, where, additionally you have a \winrar directory containing a wirar.exe file, a \chrome directory containing a chrome.exe file, etc., i.e. it seems to me like you are making it more complex than needed.

jaclaz

Link to comment
Share on other sites

Thanks all of you for your answers, now it's working how I wanted, with 'my' structure of files and folders :thumbup

Thanks to, Yzöwl, DosProbie, Geej

Special thanks goes to jaclaz

Didnt worked, so just need one directory back, as win7.bat is now in tools folder !?

Not really :no: (you don't *need* one directory back, you *want* one directory back, it's not the same thing).

And then you want two directories down.

And you didn't take more than 1 second to try and understand the syntax of the example. :w00t:

Actually, I tryed but not too much, as I was thinking to post here, you know !

The idea is:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

CD .. <- this changes to one directory up, in your case ROOT\OneClickInstaller\

CD .\apps\chrome <- this changes to two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0..\apps\chrome <- this changes to one directoty up to the one in which Win7.bat is, no matter on which drive , two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

CD ..\apps\chrome <- this changes to two directory down, in your case ROOT\OneClickInstaller\apps\chrome\

chrome.exe /silent /install <- this executes the file from the current directory

Or:

CD /D %~dp0 <- this changes current directory to the one in which Win7.bat is, no matter on which drive, in your case ROOT\OneClickInstaller\tools\

..\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

CD /D %~d0 <- this changes current directory to the ROOT of the drive in which Win7.bat is, no matter on which drive, in your case ROOT\

.\OneClickInstaller\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

%~d0\OneClickInstaller\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Or:

%~dp0..\apps\chrome\chrome.exe /silent /install <- this executes the file from the directory

Thank you, for this detailed explanation, now I understand better syntax, I tryed all options, using 'DIR' and 'PAUSE' to see in which 'PATH' I am, so to understand better syntax !

It makes (to me) very little sense to have a \tools directory containing just three (lousy :ph34r:) batches and a separate \apps directory, where, additionally you have a \winrar directory containing a wirar.exe file, a \chrome directory containing a chrome.exe file, etc., i.e. it seems to me like you are making it more complex than needed.

jaclaz

I don't know, but I posted already on my previous posts, that, I ripped out this win7.bat code, so you can view the code easier, as I have 14 exe's to install, and some of them have some additional files like .ini files, I don't want to complicate to myself all this coding stuff, neither to you, but I will update time by time these exe's and thats the reason I wanted seperated folders to each exe file !

ALL this mess is just for that stupid UAC thingy in Windows 7, I know that exists some of methods to bypass it, I tryed once before, failed, even I created a topic here about bypassing UAC, but could not find solution, however after a while, I will research and maybe go to that topic and ask about it :)

For the sake of others, and being thankful, I will post my final win7.bat code that works for me !

Files and folders structure

ROOT
--------------->OneClickInstaller [DIR]
--------------->Launch.bat
------------------------>tools [DIR]
-----------------------------> sched.bat
-----------------------------> winxp.bat
-----------------------------> win7.bat
------------------------.>apps [DIR]
------------------------------> Chrome [DIR]
--------------------------------------> chrome.exe
------------------------------> Teamviewer [DIR]
--------------------------------------> teamviwer.exe
------------------------------->Winrar [DIR]
-------------------------------------->winrar.exe

win7.bat


@ECHO off
CD /D %~dp0

CD /D %~dp0..\apps\winrar\
ECHO Installing WinRAR
winrar.exe /s
cls
ECHO Installation completed !

CD..
CD teamviewer
cls
ECHO Installing TeamViewer
teamviewer.exe /S
cls
ECHO Installation Completed

CD..
CD chrome
cls
ECHO Installing Chrome
chrome.exe /silent /install
cls
ECHO.
ECHO Installation completed !
ECHO.
cls
ECHO All Applications installed !

pause > NUL

Zyklon

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...