Solved

Hide Window

Posted on 2014-04-25
15
350 Views
Last Modified: 2014-04-30
How can I modify these couple of lines so that the script doesn't show the Uninstalling progresss screen. Also it doesn't wait for this process to finish before jumping to the next one..that's the reason why I have added the Wscript.sleep..



If objFSO.FileExists("C:\program files\Microsoft Office\Office12\MSAccess.exe") Then
   WshShell.Run "MsiExec.exe /X{90120000-0015-0000-0000-0000000FF1CE} /qn", ,true
   ObjOutput.WriteLine "Access     : Uninstallation Successful"
   WScript.sleep (1000 * 60)
Else
   ObjOutput.WriteLine "Access     : Not Found"
End If

Thanks
Cheers
0
Comment
Question by:Bianchi928
  • 8
  • 6
15 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
Comment Utility
for the first part, I see you apply already the /qn which should hide the window:
http://msdn.microsoft.com/en-us/library/aa367988%28v=vs.85%29.aspx

I presume that the progress window is hence not the one from msiexec, but from the package that get uninstalled?

for the "waiting", you also seem to do correctly:
http://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.84%29.aspx

I would only add the 0 for windowstyle:
WshShell.Run "MsiExec.exe /X{90120000-0015-0000-0000-0000000FF1CE} /qn", 0 ,true

maybe that solves the issue...
0
 

Author Comment

by:Bianchi928
Comment Utility
Thanks for your quick reply. Unfortunately I have already tried with /qn" ,0,true and the Uninstalling window is not hidden.  The "waiting" also doesn't happen.

Additional info...Windows XP
Running the script from a desktop icon

Cheers
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, you can also try this
If objFSO.FileExists("C:\program files\Microsoft Office\Office12\MSAccess.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Access MUI 2007"" ""MsiExec.exe /X{90120000-0015-0000-0000-0000000FF1CE} /qn""", 0,True
   ObjOutput.WriteLine "Access     : Uninstallation Successful"
   'WScript.sleep (1000 * 60)
Else
   ObjOutput.WriteLine "Access     : Not Found"
End If

Open in new window


Just a note, it looks like that GUID may only relate to the Access 2007 MUI (English) component, and not the full Access product, but you may be doing those separately...

Rob.
0
 

Author Comment

by:Bianchi928
Comment Utility
Thanks Rob. I'll give that a try and let you know.
Cheers
0
 

Author Comment

by:Bianchi928
Comment Utility
Hi Rob,

I tested on a computer with Excel loaded

It comes with an error

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Excel.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Excel 2007"" ""MsiExec.exe /X{90120000-0016-0000-0000-0000000FF1CE} /qn""", 0,True
   ObjOutput.WriteLine "Excel      : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Excel      : Not Found"
End If

I've attached the error message
Untitled.gif
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hmmm, try
WshShell.Run "cmd /c start /wait ""Remove Excel 2007"" MsiExec.exe /X{90120000-0016-0000-0000-0000000FF1CE} /qn", 0,True

Rob.
0
 

Author Comment

by:Bianchi928
Comment Utility
Hi Rob !

Okay I've loaded Excel, Powerpoint & Word on the test computer. That's the full script with your changes included. The problem now is that it removes Excel and then drops out. I have to run it again to get rid of Powerpoint and again for Word. Also the attachment is what I don't want to see displayed...

Set objFSO   = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")

strUserName = objNetwork.UserName
strcompName = objNetwork.ComputerName
set OSVersion = wshshell.exec("%comspec% /c ver")
Version = OSversion.stdout.readall
Select Case True
       Case Instr(Version, "n 5.") > 1 : OSName = "XP"
       Case Instr(Version, "n 6.1") > 1 : OSName = "Win 7"
End Select

'wscript.echo strusername, strcompname, OSName
'Logfilename    = "\\tyrenet-14\transfer\" & strusername & ".txt"

If OSName = "Win 7" then
   Logfilename     = "c:\users\" & strusername & "\desktop\" & strusername & ".txt"
Else
   Logfilename     = "c:\documents and settings\" & strusername & "\desktop\" & strusername & ".txt"
End If

Const intForAppending = 8

If objFSO.FileExists(LogFilename) Then
   Set objOutput = objFSO.OpenTextFile(LogFileName, intForAppending, False)
Else
   Set objOutput = objFSO.CreateTextFile(LogFileName, intForAppending, False)
End If

ObjOutput.WriteLine "User name  :" & strusername & " - Computer Name  :" & strcompname

wshShell.Run "TaskKill /im msaccess.exe /f ", , True
wshShell.Run "TaskKill /im excel.exe /f ", , True
wshShell.Run "TaskKill /im powerpnt.exe /f ", , True
wshShell.Run "TaskKill /im winword.exe /f ", , True
wshShell.Run "TaskKill /im visio.exe /f ", , True
wshShell.Run "TaskKill /im winproj.exe /f ", , True

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\MSAccess.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Access 2007"" MsiExec.exe /X{90120000-0015-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "Access     : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Access     : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Excel.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Excel 2007"" MsiExec.exe /X{90120000-0016-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "Excel      : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Excel      : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Powerpnt.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove PowerPoint 2007"" MsiExec.exe /X{90120000-0018-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "PowerPoint : Uninstallation Successful"
Else
   ObjOutput.WriteLine "PowerPoint : Not Found"
End If


If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Winword.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Word 2007"" MsiExec.exe /X{90120000-001B-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "Word       : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Word       : Not Found"

End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Visio.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Visio 2007"" MsiExec.exe /X{90120000-0053-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "Visio      : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Visio      : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Winproj.exe") Then
   WshShell.Run "cmd /c start /wait ""Remove Project 2007"" MsiExec.exe /X{90120000-003A-0000-0000-0000000FF1CE} /qn", 0,True
   ObjOutput.WriteLine "Project    : Uninstallation Successful"
Else
   ObjOutput.WriteLine "Project    : Not Found"
End If

ObjOutput.close 

Wscript.Quit

Open in new window

Screen.gif
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 65

Accepted Solution

by:
RobSampson earned 200 total points
Comment Utility
Not sure why you'd need to run it again....unless the previous one isn't completely finished....I've added more logging to this, so see what the log says.

Set objFSO   = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set objNetwork = WScript.CreateObject("WScript.Network")

strUserName = objNetwork.UserName
strcompName = objNetwork.ComputerName
set OSVersion = wshshell.exec("%comspec% /c ver")
Version = OSversion.stdout.readall
Select Case True
       Case Instr(Version, "n 5.") > 1 : OSName = "XP"
       Case Instr(Version, "n 6.1") > 1 : OSName = "Win 7"
End Select

'wscript.echo strusername, strcompname, OSName
'Logfilename    = "\\tyrenet-14\transfer\" & strusername & ".txt"

If OSName = "Win 7" then
   Logfilename     = "c:\users\" & strusername & "\desktop\" & strusername & ".txt"
Else
   Logfilename     = "c:\documents and settings\" & strusername & "\desktop\" & strusername & ".txt"
End If

Const intForAppending = 8

If objFSO.FileExists(LogFilename) Then
   Set objOutput = objFSO.OpenTextFile(LogFileName, intForAppending, False)
Else
   Set objOutput = objFSO.CreateTextFile(LogFileName, intForAppending, False)
End If

ObjOutput.WriteLine "User name  :" & strusername & " - Computer Name  :" & strcompname

wshShell.Run "TaskKill /im msaccess.exe /f ", , True
wshShell.Run "TaskKill /im excel.exe /f ", , True
wshShell.Run "TaskKill /im powerpnt.exe /f ", , True
wshShell.Run "TaskKill /im winword.exe /f ", , True
wshShell.Run "TaskKill /im visio.exe /f ", , True
wshShell.Run "TaskKill /im winproj.exe /f ", , True

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\MSAccess.exe") Then
	intReturn = WshShell.Run("cmd /c start /wait ""Remove Access 2007"" MsiExec.exe /X{90120000-0015-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Access     : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Access     : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "Access     : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Excel.exe") Then
   intReturn = WshShell.Run("cmd /c start /wait ""Remove Excel 2007"" MsiExec.exe /X{90120000-0016-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Excel     : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Excel     : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "Excel      : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Powerpnt.exe") Then
   intReturn = WshShell.Run("cmd /c start /wait ""Remove PowerPoint 2007"" MsiExec.exe /X{90120000-0018-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Powerpoint : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Powerpoint : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "PowerPoint : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Winword.exe") Then
   intReturn = WshShell.Run("cmd /c start /wait ""Remove Word 2007"" MsiExec.exe /X{90120000-001B-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Word       : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Word       : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "Word       : Not Found"

End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Visio.exe") Then
   intReturn = WshShell.Run("cmd /c start /wait ""Remove Visio 2007"" MsiExec.exe /X{90120000-0053-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Visio      : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Visio      : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "Visio      : Not Found"
End If

If objFSO.FileExists("C:\program files\Microsoft Office\Office12\Winproj.exe") Then
   intReturn = WshShell.Run("cmd /c start /wait ""Remove Project 2007"" MsiExec.exe /X{90120000-003A-0000-0000-0000000FF1CE} /qn", 0,True)
	If intReturn = 0 Then
		ObjOutput.WriteLine "Project    : Uninstallation Successful"
	Else
		ObjOutput.WriteLine "Project    : Uninstallation failed with return code " & intReturn
	End If
Else
   ObjOutput.WriteLine "Project    : Not Found"
End If

ObjOutput.close 

Wscript.Quit

Open in new window


For the progress screen, and for the whole operation, to be honest, it may be better to use a custom config.xml to perform the uninstall by running setup.exe.  See here:
http://technet.microsoft.com/en-us/library/cc982159(v=office.14).aspx

So you can set
<Display Level="none" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" />

And see this line
<OptionState Id=”ACCESSFiles” State=”absent” Children=”force” />

to set the removal of specific options.

I have never set an uninstall this way, so you will probably need to do some good testing, and fishing around for others that have used this method, but it should work as designed.

Regards,

Rob.
0
 

Author Comment

by:Bianchi928
Comment Utility
Okay I tested with Accees, Excel, Powerpoint and Word loaded. It only uninstalled Access .
Check the attached log. It shows that the other has been uninstalled, but it's still there.
ZA20611.txt
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
That's strange....can you check your Application event log and see if the MSIExec message show anything going on?

Rob.
0
 

Author Comment

by:Bianchi928
Comment Utility
Rob,

I have been able to sort out the problem using setup.exe and config.xml. I've attached one of my config.xml..See if anything should be added.

Thanks
AccessUninstallConfig.xml
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Does that work?  I would have thought you need to add state="ABSENT", but as I said, I haven't done it, so I'm not sure.  I guess if it works, and only uninstalls that specific product, you should be good to go.

Rob.
0
 

Author Comment

by:Bianchi928
Comment Utility
What does this line mean ?

<OptionState Id=”ACCESSFiles” State=”absent” Children=”force” />
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
See here:
http://technet.microsoft.com/en-us/library/cc179006(v=office.14).aspx

The Absent state means the feature will not be installed, so Setup will remove then.  The Children="force" will remove any child elements of the Access product as well.

Rob.
0
 

Author Closing Comment

by:Bianchi928
Comment Utility
Solved my uninstallation progress display problem.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now