#114100 - 2004-02-16 07:57 PM
encapsulate shell string with space in path name
|
JamieS
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
|
|
|
|
#114102 - 2004-02-16 09:20 PM
Re: encapsulate shell string with space in path name
|
Chris S.
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
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
|
|
|
|
#114105 - 2004-02-17 12:14 AM
Re: encapsulate shell string with space in path name
|
JamieS
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
|
|
|
|
#114107 - 2004-02-17 01:19 AM
Re: encapsulate shell string with space in path name
|
Allen
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
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
|
|
|
|
#114110 - 2004-02-17 05:06 PM
Re: encapsulate shell string with space in path name
|
JamieS
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
|
|
|
|
#114112 - 2004-02-17 06:51 PM
Re: encapsulate shell string with space in path name
|
JamieS
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
|
|
|
|
#114114 - 2004-02-17 07:14 PM
Re: encapsulate shell string with space in path name
|
ShaneEP
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
|
|
|
|
#114116 - 2004-02-17 10:04 PM
Re: encapsulate shell string with space in path name
|
JamieS
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
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 484 anonymous users online.
|
|
|