Page 1 of 1 1
Topic Options
#114100 - 2004-02-16 07:57 PM encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
Can anyone help troubleshoot my uninstall script? I am running into difficulty uninstalling an application whose path contains spaces. Some uninstall apps provide a dos equivelant path in the uninstall string, but some do not. Unless I can properly encapsulate the following string, this will not run. I have tried variations of the following examples, but to no avail.

SHELL "$ProgStr\unwise32.exe /A $ProgStr\$BProg.log"

SHELL '%comspec% /C Start "$ProgStr\unwise32.exe /A $ProgStr\$BProg.log"

$ProgStr is the path that is read from HKLM\software\microsoft\windows\current version\app path\
$BProg is the program I am uninstalling. In this case ICQ lite.

The variables are getting the correct value, which in this case is D:\program files\icqlite for the path. I have tried every
way I can think of to enclose the path in quotes, but nothing works. Anyone have any thoughts?

Thanks,

Top
#114101 - 2004-02-16 08:13 PM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the FAQ Forum with regard ot proper use of quotes. Also, using SETOPTION('novarsinstrings','on') will make the string building experience easier. You will need to enclose the complete path with double quotes.
Code:

$comdline='"'+$ProgStr+'\unwise32.exe" /A "'+$ProgStr+'\'+$BProg+'.log"'



Edited by sealeopard (2004-02-16 09:44 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
#114102 - 2004-02-16 09:20 PM Re: encapsulate shell string with space in path name
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
I created a UDF called fnGetFileProp() that may be of some use to you. It can retrieve the 8.3 ShortPath name if you supply it with the long path name.
Top
#114103 - 2004-02-16 11:23 PM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
Thanks for the response.
It still does not work. The problem does not lie with the path in the initial program call, but in the path in which the log file location is named after the /A switch. I think I've seen all the proper use of quotes, but nothing seems to work. Any other ideas?

Top
#114104 - 2004-02-16 11:49 PM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Show us your code and the SHELL string that is being generated.
_________________________
There are two types of vessels, submarines and targets.

Top
#114105 - 2004-02-17 12:14 AM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
alrighty.....

$BProg = ICQLite
;$Bat = "%SystemDrive%\unwise.bat"

$SWRegKey = ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$BProg.exe")
$SWProgKey = KeyExist("$SWRegKey")

IF $SWProgKey = 1 ;Banned software is installed on this machine
? "Banned software $BProg has been found on computer @Wksta!"
$ProgStr = ReadValue("$SWRegKey", "Path")
? "Removing banned software $BProg from computer @Wksta....."
$cmdln = '"'+$ProgStr+'\unwise32.exe" /A "'+$ProgStr+'\'+$BProg+'.log"'
? '$cmdln'
SHELL "$cmdln"
ENDIF
Return

Thanks,

Top
#114106 - 2004-02-17 12:32 AM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
And where's the output, e.g. ? $cmdln

Also, I highly recommend to use SETOPTION('NoVarsInStrings','on') in your code!
_________________________
There are two types of vessels, submarines and targets.

Top
#114107 - 2004-02-17 01:19 AM Re: encapsulate shell string with space in path name
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4567
Loc: USA
Not sure you are having the same problem but there was a solution found by doubling up on the quotes:

Shell and quotes


Edited by Al_Po (2004-02-17 01:20 AM)

Top
#114108 - 2004-02-17 03:47 PM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
Oh, sorry sealeopard
the output for $cmdln is:
"D:\Program Files\icqlite\unwise32.exe" /A "D:\Program Files\icqlite\icelite.log"
It seems to be reading OK. It does not have any issues with the first part of the string as the executible is launched, but it errors out saying "cannot find log file. However, if I hardcode in the log file path (not the .exe path) everything works just fine.

Top
#114109 - 2004-02-17 04:02 PM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Are you sure it's "icelite.log" and not "icqlite.log" for the log file name?
_________________________
There are two types of vessels, submarines and targets.

Top
#114110 - 2004-02-17 05:06 PM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
sorry, typo on my part. the variable information is definitely correct, it just does not like D:\Program Files
as the path.

Top
#114111 - 2004-02-17 05:11 PM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Have you tried providing just the filename without path? It really depends on what UNWISE32.EXE wants as parameter.
_________________________
There are two types of vessels, submarines and targets.

Top
#114112 - 2004-02-17 06:51 PM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
Well, I hadn't tried it that way prior to your mentioning it, so I did. Initially it did not work, but I got to thinking about it and was able to run it manually from the command line with no path to the log file since I was in the "working directory". So I modified my code to point to the working directory prior to $cmdln execution and it works like a champ without having to specify the log path. It never crossed my mind to do it that way as all the the uninstall strings you find in the registry specify a log file path. Thanks for all your help.

By the way I've entered the SETOPTION('NoVarsInStrings','on') in my code as you stressed, but can you tell me what that accomlishes? When I look up SETOPTION in the kixtart help, the NoVarsInString option is not even mentioned. Anyway, here is my code that finally works in case anyone else experiences this problem:

SETOPTION('NoVarsInStrings','on')
$BProg = ICQLite
$Bat = "%SystemDrive%\unwise.bat"
$SWRegKey = ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$BProg.exe")
$SWProgKey = KeyExist("$SWRegKey")

IF $SWProgKey = 1 ;Banned software is installed on this machine
? "Banned software $BProg has been found on computer @Wksta!"
$ProgStr = ReadValue("$SWRegKey", "Path")
? "Removing banned software $BProg from computer @Wksta....."
CD "$ProgStr"
@ERROR
$cmdln = '"'+$ProgStr+'\unwise32.exe" /A '+$BProg+'.log'
? '$cmdln'
SHELL "$cmdln"
ENDIF

Return

Top
#114113 - 2004-02-17 07:08 PM Re: encapsulate shell string with space in path name
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
It is not enough to simply add SETOPTION('NoVarsInStrings','on') and not remove vars from strings!

$SWProgKey = KeyExist("$SWRegKey")

is a perfect example of a var in a string. Why would you put quotes around a var anyway?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#114114 - 2004-02-17 07:14 PM Re: encapsulate shell string with space in path name
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Not sure which manual you are reading, but this came straight from the manual that comes with 4.22.

-----

SETOPTION
Action SetOption can be used to configure certain options of the KiXtart script engine.

Syntax SETOPTION("option", "value")

Parameters
Option
Option to set.
Value
Value for the option.

The options and possible values are described in the following table:

ASCII ON, OFF
Default console output is in Unicode. Setting the ASCII option to ON changes the output to ASCII, so you can output extended characters, such as line characters.
CaseSensitivity ON, OFF
By default, all string comparisons are case-insensitive. Setting the CaseSensitivity option to ON configures KiXtart to make string comparisons case-sensitive.
DisableDebugging ON
Disables debugging (effectively disables the DEBUG ON command). Note that debugging can not be re-enabled.
Explicit ON, OFF
When you enable the Explicit option, you must explicitly declare all variables using the Dim, Global, or ReDim statements. If you attempt to use an undeclared variable name, an error occurs.Use the Explicit option to avoid incorrectly typing the name of an existing variable.
HideCursor ON,OFF
Hides or shows the console cursor.
NoVarsInStrings ON,OFF
Disables resolution of variables inside strings. In other words, if this option is enabled, any ‘$’ character in a string will be left as-is.
WrapAtEOL ON,OFF
Enables/disables wrapping of console output at the end of a line. Default is OFF.


Returns SetOption returns the previous state of the option.

Top
#114115 - 2004-02-17 08:03 PM Re: encapsulate shell string with space in path name
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Maybe he's using KiXtart v3.63 and just completely neglected to provide basic troubleshooting info as described in the "ABC's of KiXtart board etiquette and message to new forum users" in the FAQ forum?
_________________________
There are two types of vessels, submarines and targets.

Top
#114116 - 2004-02-17 10:04 PM Re: encapsulate shell string with space in path name
JamieS Offline
Fresh Scripter

Registered: 2004-02-16
Posts: 7
Actually I believe I am running version 3.45, but the help that I use is the 2001 reference guide published by ScriptLogic. I guess I'll do some upgrading.
Yes I did neglect to read the "ABC's of Kixtart board etiquette" specifically written for inexperienced newbie's who provide insufficient information so as to generate unnecessary questions geered to deciphering details while further delaying the resolution of problems.
This lapse has now been corrected as the message to newbie's has been read.

Top
#114117 - 2004-02-17 10:31 PM Re: encapsulate shell string with space in path name
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
so, if you use kix4.xx ref, it should be there.
anyways, if you use version compatible with the setting, your script won't work.
if you use different type of version (that does support it) your script still does not work properly.

so actually, you changed something else there middle of not working and working.
this part seemed to be irrelevant.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 484 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.069 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org