Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


App Uninstall/Install

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,33734
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> App Uninstall/Install
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 App Uninstall/Install - 4/20/2006 11:09:39 PM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
Guys,

I am attempting to create my first VB script to uninstall an application and then install the new version of this application. I have my code below, it fails at the %windir% section and I'm not sure what is going on. Can anyone point me in the correct direction to resolve this please? Thank you.

-Brian

Const ALL_USERS = True

Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install(""%windir%\IsUninst.exe -a -y -f"C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu""", , ALL_USERS)


Set objService = GetObject("winmgmts:")
Set objSoftware = objService.Get("Win32_Product")
errReturn = objSoftware.Install("\\sjmhfs1\packages\wirelessclient\messenger.msi /qn", , ALL_USERS)
 
 
Post #: 1
 
 RE: App Uninstall/Install - 4/21/2006 1:06:46 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Search the fora for ExpandEnvironmentString.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 2
 
 RE: App Uninstall/Install - 4/23/2006 10:46:34 PM   
  mbouchard


Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Also, take a look at GetSpecialFolders in the WSH Document, and since the link seems to be dead and MS seems to have not listed the doc for downloading, I will need to check, here is the info on GetSpecialFolders

quote:


GetSpecialFolder Method
See Also

GetAbsolutePathName Method | GetBaseName Method | GetDrive Method | GetDriveName Method | GetExtensionName Method | GetFile Method | GetFileName Method | GetFileVersion Method | GetFolder Method | GetParentFolderName Method | GetTempName Method
Applies To: FileSystemObject Object
Language

   * JScript
   * VBScript
   * Show All

Returns the special folder object specified.

object.GetSpecialFolder(folderspec)
Arguments

object
   Required. Always the name of a FileSystemObject.
folderspec
   Required. The name of the special folder to be returned. Can be any of the constants shown in the Settings section.

Settings

The folderspec argument can have any of the following values:
Constant     Value     Description
WindowsFolder     0     The Windows folder contains files installed by the Windows operating system.
SystemFolder     1     The System folder contains libraries, fonts, and device drivers.
TemporaryFolder 2     The Temp folder is used to store temporary files. Its path is found in the TMP environment variable.

The following example illustrates the use of the GetSpecialFolder method.

[VBScript]
Dim fso, tempfile
Set fso = CreateObject("Scripting.FileSystemObject")

Function CreateTempFile
  Dim tfolder, tname, tfile
  Const TemporaryFolder = 2
  Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
  tname = fso.GetTempName  
  Set tfile = tfolder.CreateTextFile(tname)
  Set CreateTempFile = tfile
End Function

Set tempfile = CreateTempFile
tempfile.WriteLine "Hello World"
tempfile.Close



_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: App Uninstall/Install - 4/24/2006 11:33:45 PM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
I'm still at a loss guys with this VB scripting thing. All I want to do is call the two lines below silently with a vbscript so that I can push this out via SMS. Is there a website possibly that has examples of such a script that I can just plug in these two lines and be done? It's just that all of this is soo over my head and was supposed to push this out 2 weeks ago. I've looked at a tone of examples and everytime I think I have it plugged in just right I always get errors.

%windir%\IsUninst.exe -a -y -f"C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu"

\\sjmhfs1\packages\wirelessclient\messenger.msi /qn

-Brian

(in reply to mbouchard)
 
 
Post #: 4
 
 RE: App Uninstall/Install - 4/25/2006 1:26:13 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
post what you have tried and the errors that you get.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 5
 
 RE: App Uninstall/Install - 4/25/2006 2:55:43 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
I have tried different variations of the above script in my first post, but it always fails when it get to the %windir% portion.

-Brian

(in reply to ebgreen)
 
 
Post #: 6
 
 RE: App Uninstall/Install - 4/25/2006 3:00:53 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
errReturn = objSoftware.Install(""" & oWsh.ExpandEnvironmentStrings("%windir%") & "\IsUninst.exe -a -y -f"C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu""", , ALL_USERS)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 7
 
 RE: App Uninstall/Install - 4/25/2006 3:08:30 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
Line 2
Char 70
Invalid character.

(in reply to ebgreen)
 
 
Post #: 8
 
 RE: App Uninstall/Install - 4/25/2006 3:28:02 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Double quotes in command lines are always tricky. Run this and make sure the command looks right. Tweak the code if it does not.

strCmd = """ & oWsh.ExpandEnvironmentStrings("%windir%") & "\IsUninst.exe -a -y -f""C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu"""
WScript.Echo strCmd
Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
errReturn = objSoftware.Install(strCmd, , ALL_USERS)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 9
 
 RE: App Uninstall/Install - 4/25/2006 3:34:49 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
I should just be able to double click the vbscript for it to run and NOT use cscript from a command line right?


EDIT:  It fails on the ("%windir%") starting to wonder if I should just try and find a different method to get it uninstalled....

-Brian

< Message edited by Soap -- 4/25/2006 3:36:34 AM >

(in reply to ebgreen)
 
 
Post #: 10
 
 RE: App Uninstall/Install - 4/25/2006 3:38:37 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Please post the actual code that you are running along with the actual error that you get. Also, what OS?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 11
 
 RE: App Uninstall/Install - 4/25/2006 3:45:39 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
I actaully just copied/pasted the code you posted into a new vbscript and ran it from my desktop. (Windows XP) I didnt even attempt to add the installation portion into the script yet.

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: App Uninstall/Install - 4/25/2006 3:46:29 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
So what is the actual error that you get?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 13
 
 RE: App Uninstall/Install - 4/25/2006 3:49:01 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
Line 1
Char 47
Error Invalid character

(in reply to Soap)
 
 
Post #: 14
 
 RE: App Uninstall/Install - 4/25/2006 3:49:06 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Try:

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
strCmd = """" & oWsh.ExpandEnvironmentStrings("%windir%") & "\IsUninst.exe -a -y -f"" ""C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu"""
WScript.Echo strCmd
errReturn = objSoftware.Install(strCmd, , ALL_USERS)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to ebgreen)
 
 
Post #: 15
 
 RE: App Uninstall/Install - 4/25/2006 3:50:57 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
Okay when I tried that I think it worked. I ran it a second time and I got a Windows Script Host dialog box showing the 'string' that I called for the uninstall. Is that normal? Wondering if I should have something in the script that tells it to skip if it doesnt see that file? 

(in reply to ebgreen)
 
 
Post #: 16
 
 RE: App Uninstall/Install - 4/25/2006 4:07:18 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
The dialog box is a result of the WScript.Echo. Just comment it out if you don't need it for debugging.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 17
 
 RE: App Uninstall/Install - 4/25/2006 5:19:02 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
ahh ok, so if I want to call the other line for the install I can basically just plug it in like this line you gave me? Thanks again

-Brian

(in reply to ebgreen)
 
 
Post #: 18
 
 RE: App Uninstall/Install - 4/25/2006 5:20:36 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I think that should work yes.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Soap)
 
 
Post #: 19
 
 RE: App Uninstall/Install - 4/25/2006 5:25:12 AM   
  Soap

 

Posts: 21
Score: 0
Joined: 2/10/2006
Status: offline
Tried this, but no cigar.

Dim oWsh:Set oWsh = CreateObject("WScript.Shell")
strCmd = """" & oWsh.ExpandEnvironmentStrings("%windir%") & "\IsUninst.exe -a -y -f"" ""C:\Program Files\Absoft WirelessOffice Pro\Uninst.isu"""

Set msi = CreateObject("WindowsInstaller.Installer")
' set the UI level to basic
msi.UILevel = 3
' launch the installer
msi.InstallProduct ""\\sjmhfs1\packages\wirelessclient\messenger.msi /qn"", ""
' clean up
Set msi = Nothing

< Message edited by Soap -- 4/25/2006 5:35:38 AM >

(in reply to ebgreen)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> App Uninstall/Install Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts