Re: runas: need help with those quotes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"jrsmoots" <jrsmoots@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5AF9724E-E77A-452E-B473-9B84F73FB370@xxxxxxxxxxxxxxxx
I'm working on a script for a customer that will allow Install Shield to
run
while the PC is logged in with a restricted user account. My problem is
all
the quotes in the runas command!

When I inspect the properties of the Install Shield shortcut, I see this:

"C:\Program Files\Common Files\InstallShield\UpdateService\ISUSPM.exe"
-custom"C:\Documents and Settings\All Users\Application Data\Ford Motor
Company\IDS\flexids.ini"

You can see that InstallShield is run, with a custom switch. To complicate
matters, both paths have spaces, so they are enclosed in quotes.

Here's the script I have:
===============================================
Option explicit
dim oShell

set oShell= Wscript.CreateObject("WScript.Shell")

'EXE TO RUN
' "C:\Program Files\Common Files\InstallShield\UpdateService\ISUSPM.exe"
-custom"C:\Documents and Settings\All Users\Application Data\Ford Motor
Company\IDS\flexids.ini"

dim strCmd
strCmd="runas /user:Administrator " & "C:\Program Files\Common
Files\InstallShield\UpdateService\ISUSPM.exe" -custom"C:\Documents and
Settings\All Users\Application Data\Motor Company\IDS\flexids.ini"

'This command echos the the strCmd to the screen. It is commented out for
production use
Wscript.Echo strCmd

oShell.Run strCmd

WScript.Sleep 1000

'Replace the string yourpassword~ below with

'the password used on your system. Include tilde

oShell.Sendkeys "password~"

Wscript.Quit

=============================================

I can't seem to figure out the proper way to handle all the quotes on the
runas command. I've tried using chr(34) in different configurations with
no
luck. Those 'internal' quotes are killing me.

Any help would be GREATLY appreciated!

Thanks,

Jeff

Quotes embedded in a quoted string should be doubled. Perhaps you want
similar to below (watch line wrapping, this is 3 lines):

strCmd = "runas /user:Administrator " _
& """C:\Program Files\Common
Files\InstallShield\UpdateService\ISUSPM.exe""" _
& " -custom ""C:\Documents and Settings\All Users\Application Data\Motor
Company\IDS\flexids.ini"""

I broke the string up into 3 concatenated strings. I assume there should be
a space after "-custom", but you didn't have one there. If you echo the
above string at a command prompt the command should look correct.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Get Selected Path From Explorer
    ... Getting a file string from Explorer from VB using the Command line ... In this instance stripping the quotes from the beginning and end of the ... strExplorerPath = Left$- 1) ...
    (microsoft.public.vb.general.discussion)
  • Re: runas: need help with those quotes
    ... matters, both paths have spaces, so they are enclosed in quotes. ... 'This command echos the the strCmd to the screen. ... Quotes embedded in a quoted string should be doubled. ...
    (microsoft.public.scripting.vbscript)
  • Re: XP SP2 command line trouble - update
    ... If the OS is wrapping the path in quotes ... de-quote the strings, which would just need a function you pass any string ... unquote = replace$, "") ... command line itself, on at least this particular XP SP2 ...
    (microsoft.public.vb.general.discussion)
  • Parsing a bash string?
    ... For my application, which is a wrapper over bash, ... I have to be able to parse a command line typed by the user. ... I.e., I need a function that, when given a typical bash command string like ... I have to remove the quotes (notice the last ...
    (comp.unix.shell)
  • TIP #185: Null Handling
    ... nulls, and command modifications for manipulating them. ... Tcl deals with strings, the universal medium for representing data. ... is know and it is an empty string, but if a respondent forgets to give ...
    (comp.lang.tcl)