Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - VBScript works on XP but Vista

Reply
 
Old 08-12-2009   #1 (permalink)
Why Tea


 
 

VBScript works on XP but Vista

I wrote a VBScript to launch cURL.exe to login to a
server periodically via task scheduler. I have also
encoded the script to vbe. The script runs well on
XP Pro but not on Vista. I don't get any error messages
and the log file supposedly produced by cURL is
never created. Does anyone know why?

/Why Tea

My System SpecsSystem Spec
Old 08-12-2009   #2 (permalink)
Alex K. Angelopoulos


 
 

Re: VBScript works on XP but Vista

probably permissions. Can you show the source code for the script?

"Why Tea" <ytlim1@xxxxxx> wrote in message
news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
Quote:

> I wrote a VBScript to launch cURL.exe to login to a
> server periodically via task scheduler. I have also
> encoded the script to vbe. The script runs well on
> XP Pro but not on Vista. I don't get any error messages
> and the log file supposedly produced by cURL is
> never created. Does anyone know why?
>
> /Why Tea
My System SpecsSystem Spec
Old 08-12-2009   #3 (permalink)
James Whitlow


 
 

Re: VBScript works on XP but Vista

"Why Tea" <ytlim1@xxxxxx> wrote in message
news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
Quote:

>I wrote a VBScript to launch cURL.exe to login to a
> server periodically via task scheduler. I have also
> encoded the script to vbe. The script runs well on
> XP Pro but not on Vista. I don't get any error messages
> and the log file supposedly produced by cURL is
> never created. Does anyone know why?
If you have error suppression (On Error Resume Next) turned on, comment it
out temporarily on the Vista computer to see if the script is throwing any
errors.


My System SpecsSystem Spec
Old 08-12-2009   #4 (permalink)
Richard Mueller [MVP]


 
 

Re: VBScript works on XP but Vista


"Why Tea" <ytlim1@xxxxxx> wrote in message
news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
Quote:

>I wrote a VBScript to launch cURL.exe to login to a
> server periodically via task scheduler. I have also
> encoded the script to vbe. The script runs well on
> XP Pro but not on Vista. I don't get any error messages
> and the log file supposedly produced by cURL is
> never created. Does anyone know why?
>
> /Why Tea
Anything requiring administrator privileges will fail in Vista, even if you
are logged on as Administrator. This is one major difference between Vista
and XP. You can test this by running the script using "Run as
administrator". I launch the command prompt with elevated privileges, then
run scripts there. I have a shortcut to cmd.exe on my desktop. I right click
the shortcut and select "Run as administrator". Then in the command prompt I
can run scripts that require elevated privileges. You can also right click
any executable, including a *.vbs file, and select "Run as administrator".
If the script runs this way, you know it is permissions.

If this doesn't resolve the problem, we need to see code.

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


My System SpecsSystem Spec
Old 08-12-2009   #5 (permalink)
Why Tea


 
 

Re: VBScript works on XP but Vista

On Aug 13, 6:16*am, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "Why Tea" <ytl...@xxxxxx> wrote in message
>
> news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>
Quote:

> >I wrote a VBScript to launch cURL.exe to login to a
> > server periodically via task scheduler. I have also
> > encoded the script to vbe. The script runs well on
> > XP Pro but not on Vista. I don't get any error messages
> > and the log file supposedly produced by cURL is
> > never created. Does anyone know why?
>
Quote:

> > /Why Tea
>
> Anything requiring administrator privileges will fail in Vista, even if you
> are logged on as Administrator. This is one major difference between Vista
> and XP. You can test this by running the script using "Run as
> administrator". I launch the command prompt with elevated privileges, then
> run scripts there. I have a shortcut to cmd.exe on my desktop. I right click
> the shortcut and select "Run as administrator". Then in the command prompt I
> can run scripts that require elevated privileges. You can also right click
> any executable, including a *.vbs file, and select "Run as administrator"..
> If the script runs this way, you know it is permissions.
>
> If this doesn't resolve the problem, we need to see code.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --
The same script actually works on Vista with UAC turned
off. Is there a way to get it working without turning off UAC?
My System SpecsSystem Spec
Old 08-13-2009   #6 (permalink)
PaulM


 
 

Re: VBScript works on XP but Vista

Try this in the beginning of your code:

If WScript.Arguments.length = 0 Then
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Else

'code here

End If


"Why Tea" <ytlim1@xxxxxx> wrote in message
news:bc69c51f-2b8f-46f4-9f45-16565f81f051@xxxxxx
Quote:

> On Aug 13, 6:16 am, "Richard Mueller [MVP]" <rlmueller-
> nos...@xxxxxx> wrote:
Quote:

>> "Why Tea" <ytl...@xxxxxx> wrote in message
>>
>> news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>>
Quote:

>> >I wrote a VBScript to launch cURL.exe to login to a
>> > server periodically via task scheduler. I have also
>> > encoded the script to vbe. The script runs well on
>> > XP Pro but not on Vista. I don't get any error messages
>> > and the log file supposedly produced by cURL is
>> > never created. Does anyone know why?
>>
Quote:

>> > /Why Tea
>>
>> Anything requiring administrator privileges will fail in Vista, even if
>> you
>> are logged on as Administrator. This is one major difference between
>> Vista
>> and XP. You can test this by running the script using "Run as
>> administrator". I launch the command prompt with elevated privileges,
>> then
>> run scripts there. I have a shortcut to cmd.exe on my desktop. I right
>> click
>> the shortcut and select "Run as administrator". Then in the command
>> prompt I
>> can run scripts that require elevated privileges. You can also right
>> click
>> any executable, including a *.vbs file, and select "Run as
>> administrator".
>> If the script runs this way, you know it is permissions.
>>
>> If this doesn't resolve the problem, we need to see code.
>>
>> --
>> Richard Mueller
>> MVP Directory Services
>> Hilltop Lab -http://www.rlmueller.net
>> --
>
> The same script actually works on Vista with UAC turned
> off. Is there a way to get it working without turning off UAC?
My System SpecsSystem Spec
Old 08-13-2009   #7 (permalink)
Why Tea


 
 

Re: VBScript works on XP but Vista

Thanks Paulm. Does the code only work on
scripts not using command line arguments?
My script does need arguments to run.

This is the actual sequence:

main.vbe -> helper.vbe <userid> <passwd>
(helper.vbe actually launches cURL.exe
and cURL will write a log file)

/Why Tea


On Aug 13, 10:22*pm, "PaulM" <N...@xxxxxx> wrote:
Quote:

> Try this in the beginning of your code:
>
> If WScript.Arguments.length = 0 Then
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", """" & _
> WScript.ScriptFullName & """" &_
> *" RunAsAdministrator", , "runas", 1
> Else
>
> 'code here
>
> End If
>
> "Why Tea" <ytl...@xxxxxx> wrote in message
>
> news:bc69c51f-2b8f-46f4-9f45-16565f81f051@xxxxxx
>
Quote:

> > On Aug 13, 6:16 am, "Richard Mueller [MVP]" <rlmueller-
> > nos...@xxxxxx> wrote:
Quote:

> >> "Why Tea" <ytl...@xxxxxx> wrote in message
>
Quote:
Quote:

> >>news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>
Quote:
Quote:

> >> >I wrote a VBScript to launch cURL.exe to login to a
> >> > server periodically via task scheduler. I have also
> >> > encoded the script to vbe. The script runs well on
> >> > XP Pro but not on Vista. I don't get any error messages
> >> > and the log file supposedly produced by cURL is
> >> > never created. Does anyone know why?
>
Quote:
Quote:

> >> > /Why Tea
>
Quote:
Quote:

> >> Anything requiring administrator privileges will fail in Vista, even if
> >> you
> >> are logged on as Administrator. This is one major difference between
> >> Vista
> >> and XP. You can test this by running the script using "Run as
> >> administrator". I launch the command prompt with elevated privileges,
> >> then
> >> run scripts there. I have a shortcut to cmd.exe on my desktop. I right
> >> click
> >> the shortcut and select "Run as administrator". Then in the command
> >> prompt I
> >> can run scripts that require elevated privileges. You can also right
> >> click
> >> any executable, including a *.vbs file, and select "Run as
> >> administrator".
> >> If the script runs this way, you know it is permissions.
>
Quote:
Quote:

> >> If this doesn't resolve the problem, we need to see code.
>
Quote:
Quote:

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

> > The same script actually works on Vista with UAC turned
> > off. Is there a way to get it working without turning off UAC?
My System SpecsSystem Spec
Old 08-14-2009   #8 (permalink)
Al Dunbar


 
 

Re: VBScript works on XP but Vista


"Why Tea" <ytlim1@xxxxxx> wrote in message
news:0453c87c-e24d-4a02-88f3-018b0cb2b1c8@xxxxxx
Quote:

> Thanks Paulm. Does the code only work on
> scripts not using command line arguments?
It would seem so, but...
Quote:

> My script does need arguments to run.
>
> This is the actual sequence:
>
> main.vbe -> helper.vbe <userid> <passwd>
> (helper.vbe actually launches cURL.exe
> and cURL will write a log file)
change Paul's suggestion to something along these lines to be added to
helper.vbe:
Quote:
Quote:

>> If WScript.Arguments.length < 3 Then
>> Set objShell = CreateObject("Shell.Application")
>> objShell.ShellExecute "wscript.exe", """" & _
In above, pass 3 parameters: the first two supplied to helper.vbe plus a
dummy third parameter. (sorry, too late to come up with actual code for
this - lazy or tired, you be the judge :-)

/Al

Quote:
Quote:

>> WScript.ScriptFullName & """" &_
>> " RunAsAdministrator", , "runas", 1
>> Else
>>
>> 'code here
>>
>> End If
Quote:

> /Why Tea
>
>
> On Aug 13, 10:22 pm, "PaulM" <N...@xxxxxx> wrote:
Quote:

>> Try this in the beginning of your code:
>>
>> If WScript.Arguments.length = 0 Then
>> Set objShell = CreateObject("Shell.Application")
>> objShell.ShellExecute "wscript.exe", """" & _
>> WScript.ScriptFullName & """" &_
>> " RunAsAdministrator", , "runas", 1
>> Else
>>
>> 'code here
>>
>> End If
>>
>> "Why Tea" <ytl...@xxxxxx> wrote in message
>>
>> news:bc69c51f-2b8f-46f4-9f45-16565f81f051@xxxxxx
>>
Quote:

>> > On Aug 13, 6:16 am, "Richard Mueller [MVP]" <rlmueller-
>> > nos...@xxxxxx> wrote:
>> >> "Why Tea" <ytl...@xxxxxx> wrote in message
>>
Quote:

>> >>news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>>
Quote:

>> >> >I wrote a VBScript to launch cURL.exe to login to a
>> >> > server periodically via task scheduler. I have also
>> >> > encoded the script to vbe. The script runs well on
>> >> > XP Pro but not on Vista. I don't get any error messages
>> >> > and the log file supposedly produced by cURL is
>> >> > never created. Does anyone know why?
>>
Quote:

>> >> > /Why Tea
>>
Quote:

>> >> Anything requiring administrator privileges will fail in Vista, even
>> >> if
>> >> you
>> >> are logged on as Administrator. This is one major difference between
>> >> Vista
>> >> and XP. You can test this by running the script using "Run as
>> >> administrator". I launch the command prompt with elevated privileges,
>> >> then
>> >> run scripts there. I have a shortcut to cmd.exe on my desktop. I right
>> >> click
>> >> the shortcut and select "Run as administrator". Then in the command
>> >> prompt I
>> >> can run scripts that require elevated privileges. You can also right
>> >> click
>> >> any executable, including a *.vbs file, and select "Run as
>> >> administrator".
>> >> If the script runs this way, you know it is permissions.
>>
Quote:

>> >> If this doesn't resolve the problem, we need to see code.
>>
Quote:

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

>> > The same script actually works on Vista with UAC turned
>> > off. Is there a way to get it working without turning off UAC?
>


My System SpecsSystem Spec
Old 08-14-2009   #9 (permalink)
acomputerwiz6


 
 

Re: VBScript works on XP but Vista

On Aug 14, 12:44*am, "Al Dunbar" <aland...@xxxxxx> wrote:
Quote:

> "Why Tea" <ytl...@xxxxxx> wrote in message
>
> news:0453c87c-e24d-4a02-88f3-018b0cb2b1c8@xxxxxx
>
Quote:

> > Thanks Paulm. Does the code only work on
> > scripts not using command line arguments?
>
> It would seem so, but...
>
Quote:

> > My script does need arguments to run.
>
Quote:

> > This is the actual sequence:
>
Quote:

> > main.vbe -> helper.vbe <userid> <passwd>
> > (helper.vbe actually launches cURL.exe
> > and cURL will write a log file)
>
> change Paul's suggestion to something along these lines to be added to
> helper.vbe:
>
Quote:
Quote:

> >> If WScript.Arguments.length < 3 Then
> >> Set objShell = CreateObject("Shell.Application")
> >> objShell.ShellExecute "wscript.exe", """" & _
>
> In above, pass 3 parameters: the first two supplied to helper.vbe plus a
> dummy third parameter. (sorry, too late to come up with actual code for
> this - lazy or tired, you be the judge :-)
>
> /Al
>
Quote:
Quote:

> >> WScript.ScriptFullName & """" &_
> >> *" RunAsAdministrator", , "runas", 1
> >> Else
>
Quote:
Quote:

> >> 'code here
>
Quote:
Quote:

> >> End If
> > /Why Tea
>
Quote:

> > On Aug 13, 10:22 pm, "PaulM" <N...@xxxxxx> wrote:
Quote:

> >> Try this in the beginning of your code:
>
Quote:
Quote:

> >> If WScript.Arguments.length = 0 Then
> >> Set objShell = CreateObject("Shell.Application")
> >> objShell.ShellExecute "wscript.exe", """" & _
> >> WScript.ScriptFullName & """" &_
> >> *" RunAsAdministrator", , "runas", 1
> >> Else
>
Quote:
Quote:

> >> 'code here
>
Quote:
Quote:

> >> End If
>
Quote:
Quote:

> >> "Why Tea" <ytl...@xxxxxx> wrote in message
>
Quote:
Quote:

> >>news:bc69c51f-2b8f-46f4-9f45-16565f81f051@xxxxxx
>
Quote:
Quote:

> >> > On Aug 13, 6:16 am, "Richard Mueller [MVP]" <rlmueller-
> >> > nos...@xxxxxx> wrote:
> >> >> "Why Tea" <ytl...@xxxxxx> wrote in message
>
Quote:
Quote:

> >> >>news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>
Quote:
Quote:

> >> >> >I wrote a VBScript to launch cURL.exe to login to a
> >> >> > server periodically via task scheduler. I have also
> >> >> > encoded the script to vbe. The script runs well on
> >> >> > XP Pro but not on Vista. I don't get any error messages
> >> >> > and the log file supposedly produced by cURL is
> >> >> > never created. Does anyone know why?
>
Quote:
Quote:

> >> >> > /Why Tea
>
Quote:
Quote:

> >> >> Anything requiring administrator privileges will fail in Vista, even
> >> >> if
> >> >> you
> >> >> are logged on as Administrator. This is one major difference between
> >> >> Vista
> >> >> and XP. You can test this by running the script using "Run as
> >> >> administrator". I launch the command prompt with elevated privileges,
> >> >> then
> >> >> run scripts there. I have a shortcut to cmd.exe on my desktop. I right
> >> >> click
> >> >> the shortcut and select "Run as administrator". Then in the command
> >> >> prompt I
> >> >> can run scripts that require elevated privileges. You can also right
> >> >> click
> >> >> any executable, including a *.vbs file, and select "Run as
> >> >> administrator".
> >> >> If the script runs this way, you know it is permissions.
>
Quote:
Quote:

> >> >> If this doesn't resolve the problem, we need to see code.
>
Quote:
Quote:

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

> >> > The same script actually works on Vista with UAC turned
> >> > off. Is there a way to get it working without turning off UAC?


Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", "" & Chr(34) & _
WScript.ScriptFullName & Chr(34), "", "runas", 1

This will prompt for the UAC permission to run. Notice the extra
double quotes, before the runas, this is necessary as it is a bug in
the runas.

My System SpecsSystem Spec
Old 08-16-2009   #10 (permalink)
Why Tea


 
 

Re: VBScript works on XP but Vista

On Aug 13, 10:22*pm, "PaulM" <N...@xxxxxx> wrote:
Quote:

> Try this in the beginning of your code:
>
> If WScript.Arguments.length = 0 Then
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", """" & _
> WScript.ScriptFullName & """" &_
> *" RunAsAdministrator", , "runas", 1
> Else
>
> 'code here
>
> End If
>
> "Why Tea" <ytl...@xxxxxx> wrote in message
>
> news:bc69c51f-2b8f-46f4-9f45-16565f81f051@xxxxxx
>
Quote:

> > On Aug 13, 6:16 am, "Richard Mueller [MVP]" <rlmueller-
> > nos...@xxxxxx> wrote:
Quote:

> >> "Why Tea" <ytl...@xxxxxx> wrote in message
>
Quote:
Quote:

> >>news:d61137f1-b657-4566-b568-0087db616390@xxxxxx
>
Quote:
Quote:

> >> >I wrote a VBScript to launch cURL.exe to login to a
> >> > server periodically via task scheduler. I have also
> >> > encoded the script to vbe. The script runs well on
> >> > XP Pro but not on Vista. I don't get any error messages
> >> > and the log file supposedly produced by cURL is
> >> > never created. Does anyone know why?
>
Quote:
Quote:

> >> > /Why Tea
>
Quote:
Quote:

> >> Anything requiring administrator privileges will fail in Vista, even if
> >> you
> >> are logged on as Administrator. This is one major difference between
> >> Vista
> >> and XP. You can test this by running the script using "Run as
> >> administrator". I launch the command prompt with elevated privileges,
> >> then
> >> run scripts there. I have a shortcut to cmd.exe on my desktop. I right
> >> click
> >> the shortcut and select "Run as administrator". Then in the command
> >> prompt I
> >> can run scripts that require elevated privileges. You can also right
> >> click
> >> any executable, including a *.vbs file, and select "Run as
> >> administrator".
> >> If the script runs this way, you know it is permissions.
>
Quote:
Quote:

> >> If this doesn't resolve the problem, we need to see code.
>
Quote:
Quote:

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

> > The same script actually works on Vista with UAC turned
> > off. Is there a way to get it working without turning off UAC?
Finally got the scripts to run according to your
suggestion. Thanks. One more question, when
the same script is run by the Task Scheduler,
Vista always pops up and asks for permission.
Is there a way around it?

/Why Tea
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: VBscript works normally on Windows XP/Win2003 but not on Win Vista -> "Invalid class" error VB Script
How to do No hang up VBScript (nohup for VBScript) VB Script
How to read Works 4 .wps files in Vista [Works 9?] Vista General
Works 8.5 in Vista: "Microsoft Works has stopped working" Vista General
Vista and VBScript Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46