Solved

VBScript to uninstall app with command line switch

Posted on 2011-09-07
3
693 Views
Last Modified: 2012-05-12
I am trying to build a GPO which will run a vbscript at login on users Windows XP machines with Client Side Extensions installed.

In the script, I seach to see if the uninstall.exe is there and if so, then I try and run the following:

WshShell.Run ("%comspec% /c c:\progra~1\spark\uninstall.exe -q")

I try and run with %comspec% so I can use command line switches.  The vbscript, when run outside of the login script seems to work but if I try and run it via a login script, users get the following and the app will not run:

"CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory"

I am not stuck on using comspec but I am really looking for a way to utilize the login script to run the uninstall.exe with the -q command line option.

Any assistance is appreciated.
0
Comment
Question by:TexasPlowBoy
3 Comments
 
LVL 3

Expert Comment

by:Crower
Comment Utility
you can create a bat in the path where the CMD starts. within the batch file you run all the statements you need. such as changing unit, launch an exe, etc. ..
0
 
LVL 13

Expert Comment

by:khairil
Comment Utility
Hi,

Why not just write it this way?

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("cmd.exe /c c:\progra~1\spark\uninstall.exe -q")

Open in new window


I don't think you need to run full c:\windows\system\cmd.exe /c... for your command.

Comspec will always called CMD.EXE in Windows 2000 above, and access to CMD.EXE basically already declare on PATH variables.

0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
The fact that it defaults to the windows directory shouldn't matter either.  It should still run the uninstall command.

I think to avoid that, you can change the current directory of the script before running the command.

Regards,

Rob.
Set objShell = CreateObject("WScript.Shell")
objShell.CurrentDirectory objShell.ExpandEnvironmentStrings("%WINDIR%") & "\System32"
intReturn = objShell.Run("%comspec% /c c:\progra~1\spark\uninstall.exe -q", 1, True)

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…

771 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

15 Experts available now in Live!

Get 1:1 Help Now