0

Can Any one please help me out this. i can run this command but Message pops up 'Yes' or 'No' in Command line. How i can pass through this in command line silently. I need this to put in SCCM Task sequence.

Option Explicit

' Connect to Windows Installer object

' on error resume required for registry HKLM write check (isAdmin)

On Error Resume Next

Const ERROR_INSTALL_USEREXIT = 1602

Const ERROR_INSTALL_FAILURE = 1603

Const ReferencePublisher = "APL Sector"

 

Dim installer : installer = ""

Dim isAdmin

Dim isSilent: isSilent = True

Dim noPrompt: noPrompt = False

Dim bLocalOnly: bLocalOnly = False 'set to false with parameter /local

Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError

Dim WshShell : Set WshShell = WScript.CreateObject("WScript.Shell")

Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")

Dim argCount:argCount = Wscript.Arguments.Count

If (argCount > 0) Then

    If (StrComp(WScript.Arguments(0),"/verbose",vbTextCompare) = 0) Then

                   isSilent = False

    ElseIf (StrComp(WScript.Arguments(0),"/noPrompt",vbTextCompare) = 0) Then

                   noPrompt = True   

    Else If (StrComp(WScript.Arguments(0),"/local",vbTextCompare) = 0) Then

                   bLocalOnly = True

        Else

               WScript.Echo "Script removes all APL products installed in" & vbLf &_

                                                                "APL directory of local user profile" & vbLf &_

                                                                "and 32 bit client from %Program Files%"

               WScript.Quit 0

        End If

    End If

End If

Dim product, products, version, ProductName, InstallLocation, RunCmd, InstallDir, Publisher

Dim ReturnStatus: ReturnStatus = 0

Dim LocalSetting, AppData, OSVersion

Dim ProgramFiles, ProgramFilesx86 : ProgramFilesx86 = Empty

Dim bfound : bfound = False

Dim bAdminRequired : bAdminRequired = False

Dim bCleanUp : bCleanup = True 'set to false if other products found in %ProgramFiles%

Dim UninstProducts(64,5) 'product, ProductName,Version, InstallLocation

Dim index: index = 0 'index for UninstProducts

Dim LocalProducts: LocalProducts = 0

Dim APLInstallFolder

APLInstallFolder = Left(WScript.ScriptFullname,InStr(1,WScript.ScriptFullname,"\Setup\" & WScript.ScriptName,vbTextCompare))

'Show "Uninstall complete APL RTC",2

Show ">>> Start removing client at " & Now,0

Show "Computername: " + WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%"),0

Show "User: " + WshShell.ExpandEnvironmentStrings("%USERNAME%"),0

OSVersion = WshShell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")

Show "OS version " + OSVersion,0

If InStr (1,OSVersion, "6.",vbTextCompare) > 0 Then

    Rem registry key AppData used for NT 5.x does not exist any longer at least not on Server 2008 SP1

    Rem NT 6.0 does not localize "Local Settings" in file system (explorer only)

    LocalSetting = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")

    Rem if CHARM 134372 is solved

    Rem LocalSetting = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") + "\AppData\Local"

    Rem directory Apps is used by AT boot strapper currently, even on NT 6

    AppData = LocalSetting + "\AppData\Local"

Else

    LocalSetting = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Local Settings")

    AppData = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Local AppData")

End If

ProgramFiles = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")

ProgramFilesx86 = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")

If (ProgramFilesx86 = "%ProgramFiles(x86)%") Then

    Rem environemnt not set -> 32 bit OS

    ProgramFilesx86 = Empty

Dim product, products, version, ProductName, InstallLocation, RunCmd, InstallDir, Publisher

Dim ReturnStatus: ReturnStatus = 0

Dim LocalSetting, AppData, OSVersion

Dim ProgramFiles, ProgramFilesx86 : ProgramFilesx86 = Empty

Dim bfound : bfound = False

Dim bAdminRequired : bAdminRequired = False

Dim bCleanUp : bCleanup = True 'set to false if other products found in %ProgramFiles%

Dim UninstProducts(64,5) 'product, ProductName,Version, InstallLocation

Dim index: index = 0 'index for UninstProducts

Dim LocalProducts: LocalProducts = 0

Dim syngoInstallFolder

syngoInstallFolder = Left(WScript.ScriptFullname,InStr(1,WScript.ScriptFullname,"\Setup" & WScript.ScriptName,vbTextCompare))

'Show "Uninstall complete RTC",2

Show ">>> Start removing client at " & Now,0

Show "Computername: " + WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%"),0

Show "User: " + WshShell.ExpandEnvironmentStrings("%USERNAME%"),0

OSVersion = WshShell.RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\CurrentVersion")

Show "OS version " + OSVersion,0

If InStr (1,OSVersion, "6.",vbTextCompare) > 0 Then

            Rem registry key AppData used for NT 5.x does not exist any longer at least not on Server 2008 SP1

            Rem NT 6.0 does not localize "Local Settings" in file system (explorer only)

            LocalSetting = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")

            Rem if CHARM 134372 is solved

            Rem LocalSetting = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") + "\AppData\Local"

            Rem directory Apps is used by AT boot strapper currently, even on NT 6

            AppData = LocalSetting + "\AppData\Local"

Else

            LocalSetting = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Local Settings")

            AppData = WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Local AppData")

End If

ProgramFiles = WshShell.ExpandEnvironmentStrings("%ProgramFiles%")

ProgramFilesx86 = WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")

If (ProgramFilesx86 = "%ProgramFiles(x86)%") Then

            Rem environemnt not set -> 32 bit OS

            ProgramFilesx86 = Empty

End If

CheckAdmin

Err.Clear

Rem ------------------------------------------------

Rem call the CUS Uninstall firstly

Rem get a confirmation before

Rem ------------------------------------------------

If not bLocalOnly Then

            If isAdmin Then

              Show "You are going to uninstall  Space. Do you want to continue?",3

              dim ClientUpdateService: ClientUpdateService = Empty

              RunCmd = Empty

              if ( syngoInstallFolder <> Empty ) then

                ClientUpdateService = ClientInstallFolder + "bin\ClientBootstrapping.exe"

                if ( fso.FileExists(ClientUpdateService) ) Then

                  RunCmd = """" + ClientUpdateService + """" + " /UnInstall"

                end if

              end if



              Rem ------------------------------------

              Rem do the CUS call

             Rem ------------------------------------

              Dim iRet

              If ( RunCmd <> Empty ) Then

                           UninstallDCClient

                Show "Calling " & RunCmd,0

                             iRet = WshShell.Run(RunCmd,1,true)

                Show "Return status from Client Update Service = " & iRet,0

                If 0 = iRet Then

                  Show "Wait for ClientUpdateService processes to stop ...", 0

                  WaitForNoCUSRunning

                  Show "No ClientUpdateServices are running anymore", 0

                             Show "Remove %TEMP%\IXP*.TMP %TEMP%\VSD*.tmp",0 

                  CleanUpTemp

                End If

              else

                Show "No Client Update Service found"

              End If

            Else

                           If InStr (1,OSVersion, "6.",vbTextCompare) Then

                                           Show "Administrator rights are required to uninstall client" & vbLf &_

                                           "Please contact your administrator or use 'Run As Administrator'",4

                           Else

                                           Show "Administrator rights are required to uninstall client" & vbLf &_

                                           "Please contact your administrator",4

                           End If

            End If

End If

. . . Function CleanUpTemp

            Dim f,sf,f1

            'remove temporary setup directories IXPxxx.TMP with Common.Stater.BootStrapper.exe and VSD*.tmp with PreCheck

            Set f = fso.GetFolder(WshShell.ExpandEnvironmentStrings("%TEMP%"))

            Set sf = f.SubFolders

            For Each f1 in sf

                           'do not remove files of current setup / date

                           If Not (StrComp(Left(f1.DateLastAccessed,10),Left(Now,10)) = 0 ) Then

                                           If (StrComp(Right(f1.name,4),".TMP") = 0 ) Then

                                                           If (StrComp(Left(f1.name,3),"IXP") = 0 ) Then

                                                                           If fso.FileExists(f1.Path + "\Common.Starter.BootStrapper.exe") Then

                                                                                          Show "Found " + f1.Path + "\Common.Starter.BootStrapper.exe",0

                                                                                          Show "Removing " + f1.Path,1

                                                                                          f1.Delete

                                                                           End If

                                                           End If

                                           Else

                                                           If (StrComp(Right(f1.name,4),".tmp") = 0 ) Then

                                                                           If (StrComp(Left(f1.name,3),"VSD") = 0) Then

                                                                                          If (fso.FolderExists(f1.Path + "\PreCheck")) Then

                                                                                                          Show "Found " + f1.Path + "\PreCheck",0

                                                                                                          Show "Removing " + f1.Path,1

                                                                                                          f1.Delete

                                                                                          End If

                                                                           End If

                                                           End IF

                                           End If

                           End if

            Next

End Function

Function CleanUpDir(directory)

            If fso.FolderExists(directory) Then

                           Show "Removing """ & directory & """ ...",1

                           WshShell.Run "cmd /c rmdir /s /q """ & directory & """",0,true

            End If

End Function

Function Show(msg,mode)

            'mode 0 - echo in cscript only, 1 - pop up for wscript,

            'mode 2 - MsgBox (ok/cancel) in wscript

            'mode 3 - MsgBox (yes/no) in wscript

            'mode 1,2 skip in /silent mode

            LogMsg msg

            If (Instr(WScript.FullName,"wscript.exe") > 0) Then

                           Select Case mode

                           Case 1:

                                           If Not (isSilent) Then

                                                           WshShell.PopUp msg,2, "Space Setup",64

                                           End If

                           Case 2: 'MsgBox 289 -> OK/Cancel

                                           If Not (isSilent) Then

                                                           If (MsgBox (msg,289,"Space Setup") = 2 ) Then

                                                                           LogMsg "Canceled by user"

                                                                           LogMsg "Removing client quit at " & Now & " <<<"

                                                                           WScript.Quit (1)

                                                           End If

                                           End If

                           Case 3:

                               If (noPrompt) Then

                                           LogMsg "Silent Unistallation triggered"

                                           else

                                                           'MsgBox 292 -> Yes/No

                                                           If (MsgBox (msg,292,"Space Setup") = 7 ) Then

                                                                           LogMsg "Canceled by user"

                                                                           LogMsg "Removing client quit at " & Now & " <<<"

                                                                           WScript.Quit (1)

                                                           End If

                                           End If

                           Case 4: 'MsgBox 64 -> Info OK

                                           MsgBox msg,64,"Space Setup"

Commandline

5
  • Please provide a Minimal, Reproducible Example: stackoverflow.com/help/minimal-reproducible-example Commented Jun 5 at 18:44
  • Edit Remove_RTC.vbs and remove the prompt. Post the vbs code if you want more help. Also put everything in the question (i.e. command line and screenshots). There's no need to use external links. Commented Jun 5 at 19:02
  • My objective is to uninstall the software using command line. when i add the following commands in SCCM Task Sequence i am getting error. during test i have found that while running the command line Yes and No msg pops up during uninstallation. the script is too long. i cannot post here. how to post the script here. Commented Jun 5 at 20:02
  • This question is similar to: vbscript output to console. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Jun 6 at 7:09
  • @Nicky Please sort your code block formatting out the post is a mess since you’ve edited it. Commented Jun 8 at 11:04

1 Answer 1

1

Use this in SCCM:

cscript.exe "Remove_RTC.vbs" /noPrompt //B //Nologo

Also check in the vbs that:

  1. "Show()" function does not force a dialog

  2. All input arguments are parsed and handled without needing user confirmation

If you still get a "Yes"/"No" dialog, it's almost certainly from Show() or a MsgBox call that is not gated by noPrompt.

Good luck.

Sign up to request clarification or add additional context in comments.

5 Comments

Hi i have tried. its not working . when i deploy in clients its getting Error.
i have udated the script here. can any one please check and advice.
i have Tested Till Now. Finally find the solution with your Help. i have Tested Locally first then it was successfully implemented in SCCM Task Sequence Working fine, Thanks a Ton for the Help. i dont know how i say.
"C:\Program Files\xxxx\xxx.xxxx.xxx\Setup\Wrapper.bat" start wscript Remove_RTC.vbs /noPrompt
Fantastic, ignored all advice. You realise if there is an issue wscript will still generate a GUI. if you wanted this to work in the command line without interruption you should be using cscript as the dup target explains.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.