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 - Works in XP but not in Vista

Reply
 
Old 08-14-2008   #1 (permalink)
LT


 
 

Works in XP but not in Vista

The following code works on a XP machine but does not work on vista. The
error message I get is "The parameter is incorrect."

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

Thanks,
LT

My System SpecsSystem Spec
Old 08-14-2008   #2 (permalink)
PaulM


 
 

Re: Works in XP but not in Vista

Try this:

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

--
---------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/home.s2?aiu=paulm
---------------------------------------------------------------------------------

"LT" <LT@xxxxxx> wrote in message
news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
Quote:

> The following code works on a XP machine but does not work on vista. The
> error message I get is "The parameter is incorrect."
>
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName &
> Chr(34) & " Run", , "runas", 1
>
> Thanks,
> LT
My System SpecsSystem Spec
Old 08-15-2008   #3 (permalink)
LT


 
 

Re: Works in XP but not in Vista

Thanks Paul!

I tried your code as well. Did NOT work either. Running on Vista Home
Edition SP1

Thanks,
LT
"PaulM" wrote:
Quote:

> Try this:
>
> If WScript.Arguments.length = 0 Then
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", """" & _
> WScript.ScriptFullName & """" &_
> " RunAsAdministrator", , "runas", 1
> Else
>
> --
> ---------------------------------------------------------------------------------
> www.paulsxp.com
> www.paulsxp.com/forum
> www.supportspace.com/home/home.s2?aiu=paulm
> ---------------------------------------------------------------------------------
>
> "LT" <LT@xxxxxx> wrote in message
> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
Quote:

> > The following code works on a XP machine but does not work on vista. The
> > error message I get is "The parameter is incorrect."
> >
> > Set objShell = CreateObject("Shell.Application")
> > objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName &
> > Chr(34) & " Run", , "runas", 1
> >
> > Thanks,
> > LT
>
>
My System SpecsSystem Spec
Old 08-15-2008   #4 (permalink)
PaulM


 
 

Re: Works in XP but not in Vista

Here is a sample script that will Enable the Control Panel.
Watch for word wrap.


'Enable Control Panel
Option Explicit
Dim WshShell, ObjShell, X, Message

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

Message = "This script will Enable Control Panel." & vbCr & vbCr
Message = Message & "You must LogOff/On for this change to take effect." &
vbCr & vbCr
Message = Message & "Adding information can unintentionally change or delete
values" & vbCr
Message = Message & "and cause components to stop working correctly." & vbCr
Message = Message & "If you do not trust the source of this information, do
not add it to the registry." & vbCr & vbCr
Message = Message & "Are you sure you want to continue?"

X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista Tweaks")
If X = 6 Then

WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
0, "REG_DWORD"

Message = "Control Panel is now ENABLED!" & vbCr & vbCr
Message = Message & "Don't forget to LogOff/On for this change to take
effect." & vbCr & vbCr
Message = Message & "This script was downloaded from www.paulsxp.com."
MsgBox Message,64, "Done!"

End If
End If


--
---------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/home.s2?aiu=paulm
---------------------------------------------------------------------------------

"LT" <LT@xxxxxx> wrote in message
news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
Quote:

> Thanks Paul!
>
> I tried your code as well. Did NOT work either. Running on Vista Home
> Edition SP1
>
> Thanks,
> LT
> "PaulM" wrote:
>
Quote:

>> Try this:
>>
>> If WScript.Arguments.length = 0 Then
>> Set objShell = CreateObject("Shell.Application")
>> objShell.ShellExecute "wscript.exe", """" & _
>> WScript.ScriptFullName & """" &_
>> " RunAsAdministrator", , "runas", 1
>> Else
>>
>> --
>> ---------------------------------------------------------------------------------
>> www.paulsxp.com
>> www.paulsxp.com/forum
>> www.supportspace.com/home/home.s2?aiu=paulm
>> ---------------------------------------------------------------------------------
>>
>> "LT" <LT@xxxxxx> wrote in message
>> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
Quote:

>> > The following code works on a XP machine but does not work on vista.
>> > The
>> > error message I get is "The parameter is incorrect."
>> >
>> > Set objShell = CreateObject("Shell.Application")
>> > objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName &
>> > Chr(34) & " Run", , "runas", 1
>> >
>> > Thanks,
>> > LT
>>
>>
My System SpecsSystem Spec
Old 08-15-2008   #5 (permalink)
LT


 
 

Re: Works in XP but not in Vista

Thanks Paul,
I stil get that "C:\Windows\system32\wscript.exe The parameter is
incorrect." error. I copied and pasted your entire script as the result was
the same error message.

In my script, I m reading and writing a file and alot of other stuff. Whats
strange is everything else works except for the .ShellExecute call. And the
same call to .ShellExecute works on XP sp3. At this point both XP and Vista
have same version of Wscript.
Btw, where can I find the offical syntax for .ShellExecute in vbs (in terms
of passing parameters. I wasn't able to find the docs for the syntax in vbs
either).
Thanks again for your help.
LT

"PaulM" wrote:
Quote:

> Here is a sample script that will Enable the Control Panel.
> Watch for word wrap.
>
>
> 'Enable Control Panel
> Option Explicit
> Dim WshShell, ObjShell, X, Message
>
> Set WshShell = WScript.CreateObject("WScript.Shell")
> If WScript.Arguments.length =0 Then
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", """" & _
> WScript.ScriptFullName & """" & " uac","", "runas", 1
> Else
>
> Message = "This script will Enable Control Panel." & vbCr & vbCr
> Message = Message & "You must LogOff/On for this change to take effect." &
> vbCr & vbCr
> Message = Message & "Adding information can unintentionally change or delete
> values" & vbCr
> Message = Message & "and cause components to stop working correctly." & vbCr
> Message = Message & "If you do not trust the source of this information, do
> not add it to the registry." & vbCr & vbCr
> Message = Message & "Are you sure you want to continue?"
>
> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista Tweaks")
> If X = 6 Then
>
> WshShell.RegWrite
> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
> 0, "REG_DWORD"
>
> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
> Message = Message & "Don't forget to LogOff/On for this change to take
> effect." & vbCr & vbCr
> Message = Message & "This script was downloaded from www.paulsxp.com."
> MsgBox Message,64, "Done!"
>
> End If
> End If
>
>
> --
> ---------------------------------------------------------------------------------
> www.paulsxp.com
> www.paulsxp.com/forum
> www.supportspace.com/home/home.s2?aiu=paulm
> ---------------------------------------------------------------------------------
>
> "LT" <LT@xxxxxx> wrote in message
> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
Quote:

> > Thanks Paul!
> >
> > I tried your code as well. Did NOT work either. Running on Vista Home
> > Edition SP1
> >
> > Thanks,
> > LT
> > "PaulM" wrote:
> >
Quote:

> >> Try this:
> >>
> >> If WScript.Arguments.length = 0 Then
> >> Set objShell = CreateObject("Shell.Application")
> >> objShell.ShellExecute "wscript.exe", """" & _
> >> WScript.ScriptFullName & """" &_
> >> " RunAsAdministrator", , "runas", 1
> >> Else
> >>
> >> --
> >> ---------------------------------------------------------------------------------
> >> www.paulsxp.com
> >> www.paulsxp.com/forum
> >> www.supportspace.com/home/home.s2?aiu=paulm
> >> ---------------------------------------------------------------------------------
> >>
> >> "LT" <LT@xxxxxx> wrote in message
> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
> >> > The following code works on a XP machine but does not work on vista.
> >> > The
> >> > error message I get is "The parameter is incorrect."
> >> >
> >> > Set objShell = CreateObject("Shell.Application")
> >> > objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName &
> >> > Chr(34) & " Run", , "runas", 1
> >> >
> >> > Thanks,
> >> > LT
> >>
> >>
>
My System SpecsSystem Spec
Old 08-15-2008   #6 (permalink)
PaulM


 
 

Re: Works in XP but not in Vista

My Wscript.exe in XP is 5.6.0.8820, Vista is 5.7.0.18068.

This is what I have on ShellExcute:
http://www.taskghost.com/api/shell_execute.htm

I have lots of script for Vista and they all work, no problem.

--
---------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/home.s2?aiu=paulm
---------------------------------------------------------------------------------

"LT" <LT@xxxxxx> wrote in message
news:437D78AC-8D65-42C6-AEF8-EBDA6D33825F@xxxxxx
Quote:

> Thanks Paul,
> I stil get that "C:\Windows\system32\wscript.exe The parameter is
> incorrect." error. I copied and pasted your entire script as the result
> was
> the same error message.
>
> In my script, I m reading and writing a file and alot of other stuff.
> Whats
> strange is everything else works except for the .ShellExecute call. And
> the
> same call to .ShellExecute works on XP sp3. At this point both XP and
> Vista
> have same version of Wscript.
> Btw, where can I find the offical syntax for .ShellExecute in vbs (in
> terms
> of passing parameters. I wasn't able to find the docs for the syntax in
> vbs
> either).
> Thanks again for your help.
> LT
>
> "PaulM" wrote:
>
Quote:

>> Here is a sample script that will Enable the Control Panel.
>> Watch for word wrap.
>>
>>
>> 'Enable Control Panel
>> Option Explicit
>> Dim WshShell, ObjShell, X, Message
>>
>> Set WshShell = WScript.CreateObject("WScript.Shell")
>> If WScript.Arguments.length =0 Then
>> Set objShell = CreateObject("Shell.Application")
>> objShell.ShellExecute "wscript.exe", """" & _
>> WScript.ScriptFullName & """" & " uac","", "runas", 1
>> Else
>>
>> Message = "This script will Enable Control Panel." & vbCr & vbCr
>> Message = Message & "You must LogOff/On for this change to take effect."
>> &
>> vbCr & vbCr
>> Message = Message & "Adding information can unintentionally change or
>> delete
>> values" & vbCr
>> Message = Message & "and cause components to stop working correctly." &
>> vbCr
>> Message = Message & "If you do not trust the source of this information,
>> do
>> not add it to the registry." & vbCr & vbCr
>> Message = Message & "Are you sure you want to continue?"
>>
>> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista
>> Tweaks")
>> If X = 6 Then
>>
>> WshShell.RegWrite
>> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
>> 0, "REG_DWORD"
>>
>> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
>> Message = Message & "Don't forget to LogOff/On for this change to take
>> effect." & vbCr & vbCr
>> Message = Message & "This script was downloaded from www.paulsxp.com."
>> MsgBox Message,64, "Done!"
>>
>> End If
>> End If
>>
>>
>> "LT" <LT@xxxxxx> wrote in message
>> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
Quote:

>> > Thanks Paul!
>> >
>> > I tried your code as well. Did NOT work either. Running on Vista Home
>> > Edition SP1
>> >
>> > Thanks,
>> > LT
>> > "PaulM" wrote:
>> >
>> >> Try this:
>> >>
>> >> If WScript.Arguments.length = 0 Then
>> >> Set objShell = CreateObject("Shell.Application")
>> >> objShell.ShellExecute "wscript.exe", """" & _
>> >> WScript.ScriptFullName & """" &_
>> >> " RunAsAdministrator", , "runas", 1
>> >> Else
>> >>
>> >>
>> >> "LT" <LT@xxxxxx> wrote in message
>> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
>> >> > The following code works on a XP machine but does not work on vista.
>> >> > The
>> >> > error message I get is "The parameter is incorrect."
>> >> >
>> >> > Set objShell = CreateObject("Shell.Application")
>> >> > objShell.ShellExecute "wscript.exe", Chr(34) &
>> >> > WScript.ScriptFullName &
>> >> > Chr(34) & " Run", , "runas", 1
>> >> >
>> >> > Thanks,
>> >> > LT
>> >>
>> >>
>>
My System SpecsSystem Spec
Old 08-15-2008   #7 (permalink)
LT


 
 

Re: Works in XP but not in Vista

My Vista wscript version is exactly same 5.7.0.18068.
XP version is 5.7.0.18066(and the script works on XP).

I logged in under admin and standard users in Vista but that doesn't help.

All I need to accomplish is to create a shortcut on all user desktop. The
shortcut doesn't get created as i think UAC is not elevated. Is there any
other workaround?

Thanks for your help Paul.
LT

"PaulM" wrote:
Quote:

> My Wscript.exe in XP is 5.6.0.8820, Vista is 5.7.0.18068.
>
> This is what I have on ShellExcute:
> http://www.taskghost.com/api/shell_execute.htm
>
> I have lots of script for Vista and they all work, no problem.
>
> --
> ---------------------------------------------------------------------------------
> www.paulsxp.com
> www.paulsxp.com/forum
> www.supportspace.com/home/home.s2?aiu=paulm
> ---------------------------------------------------------------------------------
>
> "LT" <LT@xxxxxx> wrote in message
> news:437D78AC-8D65-42C6-AEF8-EBDA6D33825F@xxxxxx
Quote:

> > Thanks Paul,
> > I stil get that "C:\Windows\system32\wscript.exe The parameter is
> > incorrect." error. I copied and pasted your entire script as the result
> > was
> > the same error message.
> >
> > In my script, I m reading and writing a file and alot of other stuff.
> > Whats
> > strange is everything else works except for the .ShellExecute call. And
> > the
> > same call to .ShellExecute works on XP sp3. At this point both XP and
> > Vista
> > have same version of Wscript.
> > Btw, where can I find the offical syntax for .ShellExecute in vbs (in
> > terms
> > of passing parameters. I wasn't able to find the docs for the syntax in
> > vbs
> > either).
> > Thanks again for your help.
> > LT
> >
> > "PaulM" wrote:
> >
Quote:

> >> Here is a sample script that will Enable the Control Panel.
> >> Watch for word wrap.
> >>
> >>
> >> 'Enable Control Panel
> >> Option Explicit
> >> Dim WshShell, ObjShell, X, Message
> >>
> >> Set WshShell = WScript.CreateObject("WScript.Shell")
> >> If WScript.Arguments.length =0 Then
> >> Set objShell = CreateObject("Shell.Application")
> >> objShell.ShellExecute "wscript.exe", """" & _
> >> WScript.ScriptFullName & """" & " uac","", "runas", 1
> >> Else
> >>
> >> Message = "This script will Enable Control Panel." & vbCr & vbCr
> >> Message = Message & "You must LogOff/On for this change to take effect."
> >> &
> >> vbCr & vbCr
> >> Message = Message & "Adding information can unintentionally change or
> >> delete
> >> values" & vbCr
> >> Message = Message & "and cause components to stop working correctly." &
> >> vbCr
> >> Message = Message & "If you do not trust the source of this information,
> >> do
> >> not add it to the registry." & vbCr & vbCr
> >> Message = Message & "Are you sure you want to continue?"
> >>
> >> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista
> >> Tweaks")
> >> If X = 6 Then
> >>
> >> WshShell.RegWrite
> >> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
> >> 0, "REG_DWORD"
> >>
> >> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
> >> Message = Message & "Don't forget to LogOff/On for this change to take
> >> effect." & vbCr & vbCr
> >> Message = Message & "This script was downloaded from www.paulsxp.com."
> >> MsgBox Message,64, "Done!"
> >>
> >> End If
> >> End If
> >>
> >>
> >> "LT" <LT@xxxxxx> wrote in message
> >> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
> >> > Thanks Paul!
> >> >
> >> > I tried your code as well. Did NOT work either. Running on Vista Home
> >> > Edition SP1
> >> >
> >> > Thanks,
> >> > LT
> >> > "PaulM" wrote:
> >> >
> >> >> Try this:
> >> >>
> >> >> If WScript.Arguments.length = 0 Then
> >> >> Set objShell = CreateObject("Shell.Application")
> >> >> objShell.ShellExecute "wscript.exe", """" & _
> >> >> WScript.ScriptFullName & """" &_
> >> >> " RunAsAdministrator", , "runas", 1
> >> >> Else
> >> >>
> >> >>
> >> >> "LT" <LT@xxxxxx> wrote in message
> >> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
> >> >> > The following code works on a XP machine but does not work on vista.
> >> >> > The
> >> >> > error message I get is "The parameter is incorrect."
> >> >> >
> >> >> > Set objShell = CreateObject("Shell.Application")
> >> >> > objShell.ShellExecute "wscript.exe", Chr(34) &
> >> >> > WScript.ScriptFullName &
> >> >> > Chr(34) & " Run", , "runas", 1
> >> >> >
> >> >> > Thanks,
> >> >> > LT
> >> >>
> >> >>
> >>
>
My System SpecsSystem Spec
Old 08-15-2008   #8 (permalink)
PaulM


 
 

Re: Works in XP but not in Vista

That’s the only way I know of. Can I have a look at your script?

--
---------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/home.s2?aiu=paulm
---------------------------------------------------------------------------------

"LT" <LT@xxxxxx> wrote in message
news:C2E4A40D-EA26-4939-B1C9-2D2018602A20@xxxxxx
Quote:

> My Vista wscript version is exactly same 5.7.0.18068.
> XP version is 5.7.0.18066(and the script works on XP).
>
> I logged in under admin and standard users in Vista but that doesn't help.
>
> All I need to accomplish is to create a shortcut on all user desktop. The
> shortcut doesn't get created as i think UAC is not elevated. Is there any
> other workaround?
>
> Thanks for your help Paul.
> LT
>
> "PaulM" wrote:
>
Quote:

>> My Wscript.exe in XP is 5.6.0.8820, Vista is 5.7.0.18068.
>>
>> This is what I have on ShellExcute:
>> http://www.taskghost.com/api/shell_execute.htm
>>
>> I have lots of script for Vista and they all work, no problem.
>>
>>
>> "LT" <LT@xxxxxx> wrote in message
>> news:437D78AC-8D65-42C6-AEF8-EBDA6D33825F@xxxxxx
Quote:

>> > Thanks Paul,
>> > I stil get that "C:\Windows\system32\wscript.exe The parameter is
>> > incorrect." error. I copied and pasted your entire script as the result
>> > was
>> > the same error message.
>> >
>> > In my script, I m reading and writing a file and alot of other stuff.
>> > Whats
>> > strange is everything else works except for the .ShellExecute call. And
>> > the
>> > same call to .ShellExecute works on XP sp3. At this point both XP and
>> > Vista
>> > have same version of Wscript.
>> > Btw, where can I find the offical syntax for .ShellExecute in vbs (in
>> > terms
>> > of passing parameters. I wasn't able to find the docs for the syntax in
>> > vbs
>> > either).
>> > Thanks again for your help.
>> > LT
>> >
>> > "PaulM" wrote:
>> >
>> >> Here is a sample script that will Enable the Control Panel.
>> >> Watch for word wrap.
>> >>
>> >>
>> >> 'Enable Control Panel
>> >> Option Explicit
>> >> Dim WshShell, ObjShell, X, Message
>> >>
>> >> Set WshShell = WScript.CreateObject("WScript.Shell")
>> >> If WScript.Arguments.length =0 Then
>> >> Set objShell = CreateObject("Shell.Application")
>> >> objShell.ShellExecute "wscript.exe", """" & _
>> >> WScript.ScriptFullName & """" & " uac","", "runas", 1
>> >> Else
>> >>
>> >> Message = "This script will Enable Control Panel." & vbCr & vbCr
>> >> Message = Message & "You must LogOff/On for this change to take
>> >> effect."
>> >> &
>> >> vbCr & vbCr
>> >> Message = Message & "Adding information can unintentionally change or
>> >> delete
>> >> values" & vbCr
>> >> Message = Message & "and cause components to stop working correctly."
>> >> &
>> >> vbCr
>> >> Message = Message & "If you do not trust the source of this
>> >> information,
>> >> do
>> >> not add it to the registry." & vbCr & vbCr
>> >> Message = Message & "Are you sure you want to continue?"
>> >>
>> >> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista
>> >> Tweaks")
>> >> If X = 6 Then
>> >>
>> >> WshShell.RegWrite
>> >> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
>> >> 0, "REG_DWORD"
>> >>
>> >> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
>> >> Message = Message & "Don't forget to LogOff/On for this change to take
>> >> effect." & vbCr & vbCr
>> >> Message = Message & "This script was downloaded from www.paulsxp.com."
>> >> MsgBox Message,64, "Done!"
>> >>
>> >> End If
>> >> End If
>> >>
>> >>
>> >> "LT" <LT@xxxxxx> wrote in message
>> >> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
>> >> > Thanks Paul!
>> >> >
>> >> > I tried your code as well. Did NOT work either. Running on Vista
>> >> > Home
>> >> > Edition SP1
>> >> >
>> >> > Thanks,
>> >> > LT
>> >> > "PaulM" wrote:
>> >> >
>> >> >> Try this:
>> >> >>
>> >> >> If WScript.Arguments.length = 0 Then
>> >> >> Set objShell = CreateObject("Shell.Application")
>> >> >> objShell.ShellExecute "wscript.exe", """" & _
>> >> >> WScript.ScriptFullName & """" &_
>> >> >> " RunAsAdministrator", , "runas", 1
>> >> >> Else
>> >> >>
>> >> >>
>> >> >> "LT" <LT@xxxxxx> wrote in message
>> >> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
>> >> >> > The following code works on a XP machine but does not work on
>> >> >> > vista.
>> >> >> > The
>> >> >> > error message I get is "The parameter is incorrect."
>> >> >> >
>> >> >> > Set objShell = CreateObject("Shell.Application")
>> >> >> > objShell.ShellExecute "wscript.exe", Chr(34) &
>> >> >> > WScript.ScriptFullName &
>> >> >> > Chr(34) & " Run", , "runas", 1
>> >> >> >
>> >> >> > Thanks,
>> >> >> > LT
>> >> >>
>> >> >>
>> >>
>>
My System SpecsSystem Spec
Old 08-18-2008   #9 (permalink)
LT


 
 

Re: Works in XP but not in Vista

This is the script i'm having issues running on vista:

set WshShell = WScript.CreateObject("WScript.Shell")
strAllDesktopVista = WshShell.Environment("Process").Item("PUBLIC") &
"\Desktop"
strAllDesktopXP = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%") &
"\Desktop"
strURL = "http://www.google.com"
strFileName = strAllDesktopVista & "\google.lnk"

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

On Error Resume Next
Set myShortcutAllDesktopVista = WshShell.CreateShortcut(strFileName)
myShortcutAllDesktopVista.TargetPath = strURL
myShortcutAllDesktopVista.Save

strFileName = strAllDesktopXP & "\google.lnk"
Set myShortcutDesktopXP = WshShell.CreateShortcut(strFileName)
myShortcutDesktopXP.TargetPath = strURL
myShortcutDesktopXP.Save
WScript.Quit


Thanks Paul




"PaulM" wrote:
Quote:

> That’s the only way I know of. Can I have a look at your script?
>
> --
> ---------------------------------------------------------------------------------
> www.paulsxp.com
> www.paulsxp.com/forum
> www.supportspace.com/home/home.s2?aiu=paulm
> ---------------------------------------------------------------------------------
>
> "LT" <LT@xxxxxx> wrote in message
> news:C2E4A40D-EA26-4939-B1C9-2D2018602A20@xxxxxx
Quote:

> > My Vista wscript version is exactly same 5.7.0.18068.
> > XP version is 5.7.0.18066(and the script works on XP).
> >
> > I logged in under admin and standard users in Vista but that doesn't help.
> >
> > All I need to accomplish is to create a shortcut on all user desktop. The
> > shortcut doesn't get created as i think UAC is not elevated. Is there any
> > other workaround?
> >
> > Thanks for your help Paul.
> > LT
> >
> > "PaulM" wrote:
> >
Quote:

> >> My Wscript.exe in XP is 5.6.0.8820, Vista is 5.7.0.18068.
> >>
> >> This is what I have on ShellExcute:
> >> http://www.taskghost.com/api/shell_execute.htm
> >>
> >> I have lots of script for Vista and they all work, no problem.
> >>
> >>
> >> "LT" <LT@xxxxxx> wrote in message
> >> news:437D78AC-8D65-42C6-AEF8-EBDA6D33825F@xxxxxx
> >> > Thanks Paul,
> >> > I stil get that "C:\Windows\system32\wscript.exe The parameter is
> >> > incorrect." error. I copied and pasted your entire script as the result
> >> > was
> >> > the same error message.
> >> >
> >> > In my script, I m reading and writing a file and alot of other stuff.
> >> > Whats
> >> > strange is everything else works except for the .ShellExecute call. And
> >> > the
> >> > same call to .ShellExecute works on XP sp3. At this point both XP and
> >> > Vista
> >> > have same version of Wscript.
> >> > Btw, where can I find the offical syntax for .ShellExecute in vbs (in
> >> > terms
> >> > of passing parameters. I wasn't able to find the docs for the syntax in
> >> > vbs
> >> > either).
> >> > Thanks again for your help.
> >> > LT
> >> >
> >> > "PaulM" wrote:
> >> >
> >> >> Here is a sample script that will Enable the Control Panel.
> >> >> Watch for word wrap.
> >> >>
> >> >>
> >> >> 'Enable Control Panel
> >> >> Option Explicit
> >> >> Dim WshShell, ObjShell, X, Message
> >> >>
> >> >> Set WshShell = WScript.CreateObject("WScript.Shell")
> >> >> If WScript.Arguments.length =0 Then
> >> >> Set objShell = CreateObject("Shell.Application")
> >> >> objShell.ShellExecute "wscript.exe", """" & _
> >> >> WScript.ScriptFullName & """" & " uac","", "runas", 1
> >> >> Else
> >> >>
> >> >> Message = "This script will Enable Control Panel." & vbCr & vbCr
> >> >> Message = Message & "You must LogOff/On for this change to take
> >> >> effect."
> >> >> &
> >> >> vbCr & vbCr
> >> >> Message = Message & "Adding information can unintentionally change or
> >> >> delete
> >> >> values" & vbCr
> >> >> Message = Message & "and cause components to stop working correctly."
> >> >> &
> >> >> vbCr
> >> >> Message = Message & "If you do not trust the source of this
> >> >> information,
> >> >> do
> >> >> not add it to the registry." & vbCr & vbCr
> >> >> Message = Message & "Are you sure you want to continue?"
> >> >>
> >> >> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista
> >> >> Tweaks")
> >> >> If X = 6 Then
> >> >>
> >> >> WshShell.RegWrite
> >> >> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
> >> >> 0, "REG_DWORD"
> >> >>
> >> >> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
> >> >> Message = Message & "Don't forget to LogOff/On for this change to take
> >> >> effect." & vbCr & vbCr
> >> >> Message = Message & "This script was downloaded from www.paulsxp.com."
> >> >> MsgBox Message,64, "Done!"
> >> >>
> >> >> End If
> >> >> End If
> >> >>
> >> >>
> >> >> "LT" <LT@xxxxxx> wrote in message
> >> >> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
> >> >> > Thanks Paul!
> >> >> >
> >> >> > I tried your code as well. Did NOT work either. Running on Vista
> >> >> > Home
> >> >> > Edition SP1
> >> >> >
> >> >> > Thanks,
> >> >> > LT
> >> >> > "PaulM" wrote:
> >> >> >
> >> >> >> Try this:
> >> >> >>
> >> >> >> If WScript.Arguments.length = 0 Then
> >> >> >> Set objShell = CreateObject("Shell.Application")
> >> >> >> objShell.ShellExecute "wscript.exe", """" & _
> >> >> >> WScript.ScriptFullName & """" &_
> >> >> >> " RunAsAdministrator", , "runas", 1
> >> >> >> Else
> >> >> >>
> >> >> >>
> >> >> >> "LT" <LT@xxxxxx> wrote in message
> >> >> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
> >> >> >> > The following code works on a XP machine but does not work on
> >> >> >> > vista.
> >> >> >> > The
> >> >> >> > error message I get is "The parameter is incorrect."
> >> >> >> >
> >> >> >> > Set objShell = CreateObject("Shell.Application")
> >> >> >> > objShell.ShellExecute "wscript.exe", Chr(34) &
> >> >> >> > WScript.ScriptFullName &
> >> >> >> > Chr(34) & " Run", , "runas", 1
> >> >> >> >
> >> >> >> > Thanks,
> >> >> >> > LT
> >> >> >>
> >> >> >>
> >> >>
> >>
>
My System SpecsSystem Spec
Old 08-18-2008   #10 (permalink)
PaulM


 
 

Re: Works in XP but not in Vista

Here is your script, all I did was change a couple of lines and it works
great here. It the google short cut on the desktop.


Set WshShell = WScript.CreateObject("WScript.Shell")
strAllDesktopVista = WshShell.Environment("Process").Item("PUBLIC") &
"\Desktop"
strAllDesktopXP = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%") &
"\Desktop"
strURL = "http://www.google.com"
strFileName = strAllDesktopVista & "\google.lnk"

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

On Error Resume Next
Set myShortcutAllDesktopVista = WshShell.CreateShortcut(strFileName)
myShortcutAllDesktopVista.TargetPath = strURL
myShortcutAllDesktopVista.Save

strFileName = strAllDesktopXP & "\google.lnk"
Set myShortcutDesktopXP = WshShell.CreateShortcut(strFileName)
myShortcutDesktopXP.TargetPath = strURL
myShortcutDesktopXP.Save

End If

--
---------------------------------------------------------------------------------
www.paulsxp.com
www.paulsxp.com/forum
www.supportspace.com/home/home.s2?aiu=paulm
---------------------------------------------------------------------------------

"LT" <LT@xxxxxx> wrote in message
news:EF86C4C4-64EF-47DB-A40A-2EB9E1A5A085@xxxxxx
Quote:

> This is the script i'm having issues running on vista:
>
> set WshShell = WScript.CreateObject("WScript.Shell")
> strAllDesktopVista = WshShell.Environment("Process").Item("PUBLIC") &
> "\Desktop"
> strAllDesktopXP = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%") &
> "\Desktop"
> strURL = "http://www.google.com"
> strFileName = strAllDesktopVista & "\google.lnk"
>
> Set objShell = CreateObject("Shell.Application")
> objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName &
> Chr(34) & " Run", , "runas", 1
>
> On Error Resume Next
> Set myShortcutAllDesktopVista = WshShell.CreateShortcut(strFileName)
> myShortcutAllDesktopVista.TargetPath = strURL
> myShortcutAllDesktopVista.Save
>
> strFileName = strAllDesktopXP & "\google.lnk"
> Set myShortcutDesktopXP = WshShell.CreateShortcut(strFileName)
> myShortcutDesktopXP.TargetPath = strURL
> myShortcutDesktopXP.Save
> WScript.Quit
>
>
> Thanks Paul
>
>
>
>
> "PaulM" wrote:
>
Quote:

>> That’s the only way I know of. Can I have a look at your script?
>>
>> --
>> ---------------------------------------------------------------------------------
>> www.paulsxp.com
>> www.paulsxp.com/forum
>> www.supportspace.com/home/home.s2?aiu=paulm
>> ---------------------------------------------------------------------------------
>>
>> "LT" <LT@xxxxxx> wrote in message
>> news:C2E4A40D-EA26-4939-B1C9-2D2018602A20@xxxxxx
Quote:

>> > My Vista wscript version is exactly same 5.7.0.18068.
>> > XP version is 5.7.0.18066(and the script works on XP).
>> >
>> > I logged in under admin and standard users in Vista but that doesn't
>> > help.
>> >
>> > All I need to accomplish is to create a shortcut on all user desktop.
>> > The
>> > shortcut doesn't get created as i think UAC is not elevated. Is there
>> > any
>> > other workaround?
>> >
>> > Thanks for your help Paul.
>> > LT
>> >
>> > "PaulM" wrote:
>> >
>> >> My Wscript.exe in XP is 5.6.0.8820, Vista is 5.7.0.18068.
>> >>
>> >> This is what I have on ShellExcute:
>> >> http://www.taskghost.com/api/shell_execute.htm
>> >>
>> >> I have lots of script for Vista and they all work, no problem.
>> >>
>> >>
>> >> "LT" <LT@xxxxxx> wrote in message
>> >> news:437D78AC-8D65-42C6-AEF8-EBDA6D33825F@xxxxxx
>> >> > Thanks Paul,
>> >> > I stil get that "C:\Windows\system32\wscript.exe The parameter is
>> >> > incorrect." error. I copied and pasted your entire script as the
>> >> > result
>> >> > was
>> >> > the same error message.
>> >> >
>> >> > In my script, I m reading and writing a file and alot of other
>> >> > stuff.
>> >> > Whats
>> >> > strange is everything else works except for the .ShellExecute call.
>> >> > And
>> >> > the
>> >> > same call to .ShellExecute works on XP sp3. At this point both XP
>> >> > and
>> >> > Vista
>> >> > have same version of Wscript.
>> >> > Btw, where can I find the offical syntax for .ShellExecute in vbs
>> >> > (in
>> >> > terms
>> >> > of passing parameters. I wasn't able to find the docs for the syntax
>> >> > in
>> >> > vbs
>> >> > either).
>> >> > Thanks again for your help.
>> >> > LT
>> >> >
>> >> > "PaulM" wrote:
>> >> >
>> >> >> Here is a sample script that will Enable the Control Panel.
>> >> >> Watch for word wrap.
>> >> >>
>> >> >>
>> >> >> 'Enable Control Panel
>> >> >> Option Explicit
>> >> >> Dim WshShell, ObjShell, X, Message
>> >> >>
>> >> >> Set WshShell = WScript.CreateObject("WScript.Shell")
>> >> >> If WScript.Arguments.length =0 Then
>> >> >> Set objShell = CreateObject("Shell.Application")
>> >> >> objShell.ShellExecute "wscript.exe", """" & _
>> >> >> WScript.ScriptFullName & """" & " uac","", "runas", 1
>> >> >> Else
>> >> >>
>> >> >> Message = "This script will Enable Control Panel." & vbCr & vbCr
>> >> >> Message = Message & "You must LogOff/On for this change to take
>> >> >> effect."
>> >> >> &
>> >> >> vbCr & vbCr
>> >> >> Message = Message & "Adding information can unintentionally change
>> >> >> or
>> >> >> delete
>> >> >> values" & vbCr
>> >> >> Message = Message & "and cause components to stop working
>> >> >> correctly."
>> >> >> &
>> >> >> vbCr
>> >> >> Message = Message & "If you do not trust the source of this
>> >> >> information,
>> >> >> do
>> >> >> not add it to the registry." & vbCr & vbCr
>> >> >> Message = Message & "Are you sure you want to continue?"
>> >> >>
>> >> >> X = MsgBox(Message, vbYesNo + vbExclamation, "Paul's XP and Vista
>> >> >> Tweaks")
>> >> >> If X = 6 Then
>> >> >>
>> >> >> WshShell.RegWrite
>> >> >> "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoControlPanel",
>> >> >> 0, "REG_DWORD"
>> >> >>
>> >> >> Message = "Control Panel is now ENABLED!" & vbCr & vbCr
>> >> >> Message = Message & "Don't forget to LogOff/On for this change to
>> >> >> take
>> >> >> effect." & vbCr & vbCr
>> >> >> Message = Message & "This script was downloaded from
>> >> >> www.paulsxp.com."
>> >> >> MsgBox Message,64, "Done!"
>> >> >>
>> >> >> End If
>> >> >> End If
>> >> >>
>> >> >>
>> >> >> "LT" <LT@xxxxxx> wrote in message
>> >> >> news:ABEB3EA3-6E80-475E-9680-06067CB0383D@xxxxxx
>> >> >> > Thanks Paul!
>> >> >> >
>> >> >> > I tried your code as well. Did NOT work either. Running on Vista
>> >> >> > Home
>> >> >> > Edition SP1
>> >> >> >
>> >> >> > Thanks,
>> >> >> > LT
>> >> >> > "PaulM" wrote:
>> >> >> >
>> >> >> >> Try this:
>> >> >> >>
>> >> >> >> If WScript.Arguments.length = 0 Then
>> >> >> >> Set objShell = CreateObject("Shell.Application")
>> >> >> >> objShell.ShellExecute "wscript.exe", """" & _
>> >> >> >> WScript.ScriptFullName & """" &_
>> >> >> >> " RunAsAdministrator", , "runas", 1
>> >> >> >> Else
>> >> >> >>
>> >> >> >>
>> >> >> >> "LT" <LT@xxxxxx> wrote in message
>> >> >> >> news:8865B042-6AC5-4672-83F7-60310E837F19@xxxxxx
>> >> >> >> > The following code works on a XP machine but does not work on
>> >> >> >> > vista.
>> >> >> >> > The
>> >> >> >> > error message I get is "The parameter is incorrect."
>> >> >> >> >
>> >> >> >> > Set objShell = CreateObject("Shell.Application")
>> >> >> >> > objShell.ShellExecute "wscript.exe", Chr(34) &
>> >> >> >> > WScript.ScriptFullName &
>> >> >> >> > Chr(34) & " Run", , "runas", 1
>> >> >> >> >
>> >> >> >> > Thanks,
>> >> >> >> > LT
>> >> >> >>
>> >> >> >>
>> >> >>
>> >>
>>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Vista works for me Vista General
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 works ? Vista General
Vista - what works best? Vista music pictures video


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