NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


( SS64 )
Index
Latest Posts
Search
Register
Login
You are not logged in.Topics: Active | Unanswered
Index» Windows CMD Shell» .msu and .cab installer
Pages:1
#121 May 2019 04:53
PainlessMan
Member
Registered: 20 May 2019
Posts: 1
Hey there! I'd like to share a code that I was working on, it's just install .msu or .cab files, but u need to rename all them to numbers like 1, 2, 3, 4, 5, 6, 7, 8.. anyway
I'm beginner at batch code so I'd like to get advice if possible smile
Regards

@echo off
:varSection
::i var used to install files
::count1 will be used on :checkingExtension
::count2 will be used on :checkingInfoMsu2 and :checkingInfoCab2
:varSection
set /A i=1
set /A count1=1
set /A count2=1
:checkingExtension
::code below to check if user needs to install msu or cab files, also will check if user sent anything that is not msu or cab as extension file
Color A
echo "+==================================================================+
echo "| Checking Extension... |
echo "| Supported extensions: .msu .cab |
echo "+==================================================================+
echo.
set /p fileType="#%count1% Type the file extension that you want to install - (msu/cab) only: ."
echo.
echo.
echo "+==================================================================+
echo " Extension selected: .%fileType%
echo "+==================================================================+
echo.
if /I [%fileType%] == [msu] (
cls
goto checkingInfoMsu1
)
if /I [%fileType%] == [cab] (
cls
goto checkingInfoCab1
)
if /I NOT [%fileType%] == [msu] (
goto msgBox1
)
:msgBox1
::to show message box if user sent anything that is not msu (cab isn't included)
Color C
echo set WshShell = WScript.CreateObject("WScript.shell") > %tmp%tmp.vbs
echo WScript.Quit (WshShell.Popup(".%fileType% is not a supported extension.",10,"Supported Exntensions: .msu .cab",0)) >> %tmp%tmp.vbs
cscript /nologo %tmp%tmp.vbs
del %tmp%tmp.vbs
cls
set /A count1+=1
goto checkingExtension
:checkingInfoMsu1
::var statatement
Color B
set /p files="Type how many .msu files you have in the folder: "
set /p folderPath="Copy n paste the full path that your folder is located "
::code below to check if both files quantity and folder path are correct
:checkingInfoMsu2
::checking info sent by user
Color B
cls
echo "+==================================================================+
echo "|#%count2% Number of .msu Files: %files%
echo "|#%count2% Folder Path: %folderPath%*.msu
echo "+==================================================================+
set /p checkingInfo="Is the amount of .msu files and the folder path correct? (Y/N) only: "
if /I [%checkingInfo%] == [y] (
cls
goto ifSectionMsu
)
if /I [%checkingInfo%] == [yes] (
cls
goto ifSectionMsu
)
if /I [%checkingInfo%] == [n] (
cls
set /A count2+=1
goto checkingInfoMsu1
)
if /I [%checkingInfo%] == [no] (
cls
set /A count2+=1
goto checkingInfoMsu1
)
if /I NOT [%checkingInfo%] == [y] (
goto msgBox2
)
:msgBox2
::to show message box if user sent anything that is not y/yes or n/no
Color C
echo set WshShell = WScript.CreateObject("WScript.shell") > %tmp%tmp.vbs
echo WScript.Quit (WshShell.Popup("Please type (Y/N) (%checkingInfo%) is not a valid one",10,"Y or N",0)) >> %tmp%tmp.vbs
cscript /nologo %tmp%tmp.vbs
del %tmp%tmp.vbs
cls
set /A count2+=1
goto checkingInfoMsu2
:ifSectionMsu
::%i% less than or equal %files% goto intallationMsu.. %i% greater than %files% goto doneMsu
if %i% LEQ %files% (
goto installationMsu
)
if %i% GTR %files% (
goto doneMsu
)
:installationMsu
::wusa.exe to install msu files
::code below to install all .msu files that user has in his folder
Color F
wusa.exe %folderPath%%i%.msu /quiet /norestart
echo "+==================================================================+
echo "| %i%.msu has been installed...
echo "+==================================================================+
echo.
echo.
::var being incremented
set /A i+=1
goto ifSectionMsu
:doneMsu
::All files have been installed at this time
pause
echo "+==================================================================+
echo "| |
echo "| All .msu files have been installed... |
echo "| |
echo "+==================================================================+
:msgBox3
::will show message box then exit
echo set WshShell = WScript.CreateObject("WScript.shell") > %tmp%tmp.vbs
echo WScript.Quit (WshShell.Popup("All files have been installed",10,"All done!")) >> %tmp%tmp.vbs
cscript /nologo %tmp%tmp.vbs
if %errorlevel% == 1 (
del %tmp%tmp.vbs
exit
)else (
del %tmp%tmp.vbs
exit
)
del %tmp%tmp.vbs
cls
exit
:checkingInfoCab1
::var statatement
Color B
set /p files="Type how many .cab files you have in the folder: "
set /p folderPath="Copy n paste the full path that your folder is located "
:checkingInfoCab2
::checking info sent by user
Color B
cls
echo "+==================================================================+
echo "|#%count2% Number of .cab Files: %files%
echo "|#%count2% Folder Path: %folderPath%*.cab
echo "+==================================================================+
set /p checkingInfo="Is the amount of .cab files and the folder path correct? (Y/N) only: "
if /I [%checkingInfo%] == [y] (
cls
goto ifSectionCab
)
if /I [%checkingInfo%] == [yes] (
cls
goto ifSectionCab
)
if /I [%checkingInfo%] == [n] (
cls
set /A count2+=1
goto checkingInfoCab1
)
if /I [%checkingInfo%] == [no] (
cls
set /A count2+=1
goto checkingInfoCab1
)
if /I NOT [%checkingInfo%] == [y] (
goto msgBox4
)
:msgBox4
::to show message box if user sent anything that is not y/yes or n/no
Color C
echo set WshShell = WScript.CreateObject("WScript.shell") > %tmp%tmp.vbs
echo WScript.Quit (WshShell.Popup("Please type Y or N. (%checkingInfo%) is not a valid one",10,"Y or N",0)) >> %tmp%tmp.vbs
cscript /nologo %tmp%tmp.vbs
del %tmp%tmp.vbs
cls
set /A count2+=1
goto checkingInfoCab2
:ifSectionCab
::%i% less than or equal %files% goto intallationMsu.. %i% greater than %files% goto doneMsu
if %i% LEQ %files% (
goto installationCab
)
if %i% GTR %files% (
goto doneCab
)
:installationCab
::pkgmgr /ip to install .cab files
::code below to install all .cab files that user has in his folder
Color F
pkgmgr /ip /m:%folderPath%%i%.cab /quiet /norestart
echo "+==================================================================+
echo "| %i%.cab has been installed...
echo "+==================================================================+
echo.
echo.
set /A i+=1
goto ifSectionCab
:doneCab
::All files have been installed at this time
echo "+==================================================================+
echo "| |
echo "| All .cab files have been installed... |
echo "| |
echo "+==================================================================+
:msgBox5
::will show message box then exit
echo set WshShell = WScript.CreateObject("WScript.shell") > %tmp%tmp.vbs
echo WScript.Quit (WshShell.Popup("All files have been installed",5,"All done!",0)) >> %tmp%tmp.vbs
cscript /nologo %tmp%tmp.vbs
if %errorlevel% == 1 (
del %tmp%tmp.vbs
exit
)else (
del %tmp%tmp.vbs
exit
)
del %tmp%tmp.vbs
cls
exit
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.