Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Batch script start up from RunOnce registry fails !

- - - - -

  • Please log in to reply
15 replies to this topic

#1
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag
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 !


How to remove advertisement from MSFN

#2
Yzöwl

Yzöwl

    Wise Owl

  • Member
  • PipPipPipPipPipPipPipPipPip
  • 4,532 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

[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!

#3
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag
Yzöwl, thanks for your respond, I will post all code, and the structure of files and folders !

http://snag.gy/QTBDF.jpg


Posted Image


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

#4
DosProbie

DosProbie

    Friend of MSFN

  • MSFN Sponsor
  • 732 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag

Donator

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 Posted Image
@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, 11 May 2013 - 05:55 AM.


#5
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag

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 Posted Image

@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 !

#6
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,256 posts
  • OS:none specified
  • Country: Country Flag
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

#7
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag

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 ?

#8
Geej

Geej

    Senior Member

  • Member
  • PipPipPipPip
  • 635 posts
  • OS:XP Pro x86
  • Country: Country Flag
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

#9
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,256 posts
  • OS:none specified
  • Country: Country Flag

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

#10
DosProbie

DosProbie

    Friend of MSFN

  • MSFN Sponsor
  • 732 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag

Donator

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, 12 May 2013 - 09:02 AM.


#11
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag
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, 12 May 2013 - 09:30 AM.


#12
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,256 posts
  • OS:none specified
  • Country: Country Flag

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

#13
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag


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, 12 May 2013 - 12:46 PM.


#14
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,256 posts
  • OS:none specified
  • Country: Country Flag

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

#15
ZYklon

ZYklon

    Newbie

  • Member
  • 16 posts
  • OS:Windows 7 x86
  • Country: Country Flag
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

#16
DosProbie

DosProbie

    Friend of MSFN

  • MSFN Sponsor
  • 732 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag

Donator

Glad u got it working now!!:D

Just a suggestion but when installing your 14 apps why don't you just consolate them all together in the "apps" folder, then further streamline your code with a set variable and oneliner like so..
@echo off
:: Set current directory for apps
set cd=%~dp0

:: Silent Installs
echo. Set restore point..
wscript /nologo %cd%apps\RestorePt.vbs 
echo. Installation Completed!
cls
echo. Installing registry tweaks..
regedit /s %cd%apps\RegTwksW7.reg
echo. Installation Completed!
cls
echo. Installing office 2010..
%cd%apps\office\setup.exe /config %cd%apps\office\proplus.ww\config.xml
echo. Installation Completed!
cls
echo. Installing adobe reader xl..
%cd%apps\AdbeRdr11003_en_US.exe /sAll /msi /norestart ALLUSERS=1 EULA_ACCEPT=YES
echo. Installation Completed!
cls
echo. Installing cdburner xp..
%cd%apps\cdbxp_setup_4.5.1.4003.exe /verysilent /suppressmsgboxes /norestart /sp- 
echo. Installation Completed!
cls
echo. Installing flashplayer..
%cd%apps\FlashPlayer11.plugin.msi /qn
echo. Installation Completed!
cls
echo. Installing toolbar cleaner..
rundll32.exe advpack.dll,LaunchINFSectionEx %cd%\apps\tbc\ToolbarCleaner.inf,,,4
echo. Installation Completed!
cls
echo. Installing winrar..
%cd%apps\winrar.exe /s
echo. Installation Completed!
cls
pause

Edited by DosProbie, 14 May 2013 - 11:31 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN