> When it fails
>
> g_oShell.SendKeys g_sPass & "{ENTER}"
>
> g_sPass Is sent into the cmd prompt to be run as a command.
> Instead of being sent as the password for runas.
>
>
> "Al Dunbar" wrote:
>
> >
> > "Nathon" <Nathon[ at ]discussions.microsoft.com> wrote in message
> > news:B0D87F0B-27B1-4573-9976-74EDC73D7E5C[ at ]microsoft.com...
> > > Ok I think i may have narrowed the cause down a bit, but still not exactly
> > > sure what the cause is, and how to fix it.
> > >
> > > My latest prject is suffering from the same prblem, the difference this
> > > time, is i am unable to use the INI file as a work around, because I need
> > > to
> > > be able to call different INI files as needed.
> > >
> > > g_sCommand = "setup.exe"
> > > g_oShell.Run "runas /user:" & g_sLocalorDomain & "\" & g_sUserName & " " &
> > > g_sCommand
> > >
> > >
> > > runs perfect.
> > >
> > > g_sCommand = "setup.exe /settings mysetup.ini"
> > > g_oShell.Run g_sCommand
> > >
> > > runs and errors insuffient privellages, when run under non-admin account.
> > > run perfectly when run under admin account.
> >
> > Most of the setup programs I am familiar with are intended to install
> > software, something you usually need administrator access to do.
> >
> > What happens when you type this command at a command prompt first under an
> > admin account and then under a non-admin account:
> >
> > setup.exe /settings mysetup.ini
> >
> > > g_sCommand = "setup.exe /settings mysetup.ini"
> > > g_oShell.Run "runas /user:" & g_sLocalorDomain & "\" & g_sUserName & " " &
> > > g_sCommand
> > >
> > > Fails.
> >
> > Well, we know what it does not do (i.e. work), but when it is not working,
> > what is it actually doing?
> >
> > /Al
> >
> > >
> > >
> > >
> > > "Richard Mueller [MVP]" wrote:
> > >
> > >> I ran a test script that assiged the value to the variable g_sCommand,
> > >> then
> > >> used the Wscript.Echo command to display the value of this variable. The
> > >> test script I ran was (watch line wrapping):
> > >>
> > >> g_sCommand = "\\myserver\VPHOME\CLT-INST\WIN32\Setup.exe /s /a /v""/l*v
> > >> log.txt /qn installserver=0 servergroupname=crcncc
> > >> servergroupusername=myusername servergrouppass=mypassword runliveupdate=0
> > >> networktype=1 serverparent=myserver"""
> > >> Wscript.Echo g_sCommand
> > >>
> > >> I copied the first statement directly from your post and added the second
> > >> statement for troubleshooting. When I ran the script at a command prompt
> > >> with the cscript host, this statement displayed the value of g_sCommand
> > >> in
> > >> the console. I frequently use this technique to get commands correct,
> > >> with
> > >> all the spaces, commas, and quotes in the correct places. In this case,
> > >> because the value of g_sCommand is long, I redirected the output to a
> > >> text
> > >> file so I could view it (and copy it in my message). If the VBScript
> > >> program
> > >> is called Example.vbs, I go to a command prompt, navigate to the folder
> > >> where the file Example.vbs is saved, and run the following command:
> > >>
> > >> cscript //nologo Example.vbs > output.txt
> > >>
> > >> This creates the text file output.txt in the same folder with the output
> > >> of
> > >> the Wscript.Echo command. With this test VBScript program I can play with
> > >> the value of g_sCommand until it is correct. Getting the quotes right can
> > >> be
> > >> a challenge until you get used to it.
> > >>
> > >> --
> > >> Richard Mueller
> > >> Microsoft MVP Scripting and ADSI
> > >> Hilltop Lab -
http://www.rlmueller.net> > >> --
> > >>
> > >> "Nathon" <Nathon[ at ]discussions.microsoft.com> wrote in message
> > >> news:44A63669-4FF6-4E89-B266-4B6A1EBD210E[ at ]microsoft.com...
> > >> > Its been a while since i have done any scripting, like 10 years. How
> > >> > would I
> > >> > go about that.
> > >> >
> > >> > "Richard Mueller [MVP]" wrote:
> > >> >
> > >> >> Add a statement to echo the value of g_sCommand to the console. What
> > >> >> you
> > >> >> see
> > >> >> at the console is the command that will run. In this case the doubled
> > >> >> quotes
> > >> >> are properly resolved to quotes, but I think they are in the wrong
> > >> >> place.
> > >> >> From your snippet I get the following (watch line wrapping, this is
> > >> >> one
> > >> >> line):
> > >> >>
> > >> >> \\myserver\VPHOME\CLT-INST\WIN32\Setup.exe /s /a /v"/l*v log.txt /qn
> > >> >> installserver=0 servergroupname=crcncc servergroupusername=myusername
> > >> >> servergrouppass=mypassword runliveupdate=0 networktype=1
> > >> >> serverparent=myserver"
> > >> >>
> > >> >> I don't think the embedded quotes are needed at all.
> > >> >>
> > >> >> --
> > >> >> Richard Mueller
> > >> >> Microsoft MVP Scripting and ADSI
> > >> >> Hilltop Lab -
http://www.rlmueller.net> > >> >> --
> > >> >>
> > >> >> "Nathon" <Nathon[ at ]discussions.microsoft.com> wrote in message
> > >> >> news:AB06249C-666A-4A33-A422-7C3FC7F87EAB[ at ]microsoft.com...
> > >> >> > Embedded quotes are escaped by doubling them...
> > >> >> >>
> > >> >> >> g_sCommand = "happyhour.exe /d:""mmddyy"""
> > >> >> >
> > >> >> > The problen with this is when the g_sCommand is used to run
> > >> >> > happyhour.exe
> > >> >> > it
> > >> >> > exicutes as
> > >> >> >
> > >> >> > happyhour.exe /d:""mmddyy""
> > >> >> > and errors out.
> > >> >> >
> > >> >> > below is my full script
> > >> >> > -----------------------------------------------------------------------------------------------
> > >> >> > ' Explicit variable declaration and standard globals
> > >> >> > Option Explicit
> > >> >> > Dim g_sLocal
> > >> >> > Dim g_sDomain
> > >> >> > Dim g_sLocalorDomain
> > >> >> > Dim g_sUserName
> > >> >> > Dim g_sPass
> > >> >> > Dim g_sCommand
> > >> >> > Dim g_sString
> > >> >> > Dim g_oShell, g_oFSO, g_oNet
> > >> >> >
> > >> >> > ' Set standard globals and create global objects
> > >> >> > Set g_oShell = CreateObject("Wscript.Shell")
> > >> >> > Set g_oFSO = CreateObject("Scripting.FileSystemObject")
> > >> >> > Set g_oNet = CreateObject("WScript.Network")
> > >> >> >
> > >> >> > ' Local computer name retirieval -NS
> > >> >> > g_sLocal = g_oNet.ComputerName
> > >> >> > '
> > >> >> > ' Customize your setting by changing the values of the Variables
> > >> >> > below -NS
> > >> >> > '
> > >> >> > ' Domain variable could be automated, but was not neccessary for my
> > >> >> > purposes. -NS
> > >> >> > '
> > >> >> > g_sDomain = "mydomain"
> > >> >> > g_sUserName = "myusername"
> > >> >> > g_sPass = "mypassword"
> > >> >> > '
> > >> >> > 'g_sCommand syntax should include full path. example:
> > >> >> > \\servername\folder\command or c:\folder\command -NS
> > >> >> > '
> > >> >> > g_sCommand = "\\myserver\VPHOME\CLT-INST\WIN32\Setup.exe /s /a
> > >> >> > /v""/l*v
> > >> >> > log.txt /qn installserver=0 servergroupname=crcncc
> > >> >> > servergroupusername=myusername servergrouppass=mypassword
> > >> >> > runliveupdate=0
> > >> >> > networktype=1 serverparent=myserver"""
> > >> >> > '
> > >> >> > ' Changing this variable from g_sDomain to g_sLocal allows you to
> > >> >> > switch
> > >> >> > between domain user and local user -NS
> > >> >> > ' Ensure you have set the appropiate UserName -NS
> > >> >> > '
> > >> >> > g_sLocalorDomain = g_sDomain
> > >> >> >
> > >> >> > g_oShell.Run "runas /user:" & g_sLocalorDomain & "\" & g_sUserName &
> > >> >> > "
> > >> >> > " &
> > >> >> > g_sCommand
> > >> >> > Wscript.Sleep 500
> > >> >> >
> > >> >> > g_oShell.SendKeys g_sPass & "{ENTER}"
> > >> >> > g_oShell.AppActivate "cmd"
> > >> >> >
> > >> >> > -----------------------------------------------------------------------------------------------
> > >> >> >
> > >> >> > "Michael Harris (MVP)" wrote:
> > >> >> >
> > >> >> >> Nathon wrote:
> > >> >> >> > I have a vbscript I am working on, and am having an issue with a
> > >> >> >> > variable.
> > >> >> >> >
> > >> >> >> > My variable g_sCommand works if as long as it looks like this:
> > >> >> >> >
> > >> >> >> > g_sCommand = "cmd.exe"
> > >> >> >> >
> > >> >> >> > and the script works perfectly.
> > >> >> >> >
> > >> >> >> > But sometimes I need it to contain quotation marks
> > >> >> >> >
> > >> >> >> > g_sCommand = "happyhour.exe /d:"mmddyy""
> > >> >> >>
> > >> >> >>
> > >> >> >> Embedded quotes are escaped by doubling them...
> > >> >> >>
> > >> >> >> g_sCommand = "happyhour.exe /d:""mmddyy"""
> > >> >> >>
> > >> >> >>
> > >> >> >> >
> > >> >> >> > unfortunately when it does the script will error out.
> > >> >> >> >
> > >> >> >> > Any suggestions?
> > >> >> >>
> > >> >> >> --
> > >> >> >> Michael Harris
> > >> >> >> MVP- Admin Frameworks
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >>
> > >> >>
> > >> >>
> > >>
> > >>
> > >>
> >
> >
> >