Solved

VBScript to uninstall app with command line switch

Posted on 2011-09-07
3
732 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
ID: 36497276
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
ID: 36497870
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
ID: 36499936
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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can VBS count the number of items in an array 8 51
Restore a DC asap 11 35
WMIC Output Formatting 1 43
how to demote a DC microsoft server 2016 13 25
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

685 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