Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: Need assistance with a variable issue

HTVi
TV Discussion Newsgroups

Need assistance with a variable issue
Nathon 6/29/2007 11:02:05 PM
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""

unfortunately when it does the script will error out.

Any suggestions?
Re: Need assistance with a variable issue
"Michael Harris \(MVP\)" <mikhar.at.mvps.dot.org> 6/29/2007 11:15:12 PM
Nathon wrote:
[Quoted Text]
> 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


Re: Need assistance with a variable issue
Nathon 6/29/2007 11:38:01 PM
Embedded quotes are escaped by doubling them...
[Quoted Text]
>
> 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
>
>
>
Re: Need assistance with a variable issue
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 6/30/2007 1:07:33 AM
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...
[Quoted Text]
> 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
>>
>>
>>


Re: Need assistance with a variable issue
Nathon 6/30/2007 6:32:01 PM
Its been a while since i have done any scripting, like 10 years. How would I
go about that.

"Richard Mueller [MVP]" wrote:

[Quoted Text]
> 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
> >>
> >>
> >>
>
>
>
Re: Need assistance with a variable issue
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 6/30/2007 7:40:49 PM
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...
[Quoted Text]
> 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
>> >>
>> >>
>> >>
>>
>>
>>


Re: Need assistance with a variable issue
Nathon 7/2/2007 7:42:01 PM
It was passing the g_sCommand correctly. But for some reason it would not
run. Instead of passing g_sPass to the runas password prompt it kept running
it as a command. When I removed the switches from setup.exe unsder
g_sCommand it runs just fine. I wish I knew why this wasn't working, but
since the value of g_sCommand runs just fine outside the script I am at a
loss.

It did however get this to work. I simply edited the .INI file for
setup.exe so it passes the switches. But it was not the way I wanted to do
it. Not as flexable.



"Richard Mueller [MVP]" wrote:

[Quoted Text]
> 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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: Need assistance with a variable issue
Nathon 7/3/2007 11:22:00 PM
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.

g_sCommand = "setup.exe /settings mysetup.ini"
g_oShell.Run "runas /user:" & g_sLocalorDomain & "\" & g_sUserName & " " &
g_sCommand

Fails.



"Richard Mueller [MVP]" wrote:

[Quoted Text]
> 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
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: Need assistance with a variable issue
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 7/5/2007 4:11:09 AM

"Nathon" <Nathon[ at ]discussions.microsoft.com> wrote in message
news:B0D87F0B-27B1-4573-9976-74EDC73D7E5C[ at ]microsoft.com...
[Quoted Text]
> 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
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Re: Need assistance with a variable issue
Nathon 7/5/2007 5:14:01 PM
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:

[Quoted Text]
>
> "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
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Re: Need assistance with a variable issue
Nathon 7/5/2007 8:12:03 PM
I was able was to work around this by using g_sCommand to call a Batch file
that run the command.

But I still think its sloppy, and there has to be a better way of doing this.

"Nathon" wrote:

[Quoted Text]
> 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
> > >> >> >>
> > >> >> >>
> > >> >> >>
> > >> >>
> > >> >>
> > >> >>
> > >>
> > >>
> > >>
> >
> >
> >
Re: Need assistance with a variable issue
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 7/7/2007 4:30:19 AM
Runas prompts for the password in a way that makes it difficult to automate
for basically the same reason that the command does not include a /password:
switch: security. Personally, I consider it a hint worth taking.

/Al

"Nathon" <Nathon[ at ]discussions.microsoft.com> wrote in message
news:F5495D41-7202-40B1-9E5F-02125AF6E24C[ at ]microsoft.com...
[Quoted Text]
> 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
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen