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: .run method in logon script

HTVi
TV Discussion Newsgroups

.run method in logon script
Kai Lippok <REMOVEME_public[ at ]kl-mail.de> 5/15/2007 3:09:19 PM
Hi,

I am trying to use the following script as a per computer logon script:

---
set wshShell = CreateObject("Wscript.shell")

On Error resume next

key = "HKLM\SOFTWARE\UPDATE\INSTALLED"
test = wshshell.regread(key)

If err <> 0 Then

wshShell.run WindowsUpdateAgent30-x86.exe /wuforce /quiet
wshShell.run WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart",0,TRUE)

WshShell.RegWrite "HKLM\SOFTWARE\UPDATE\INSTALLED", "1", "REG_SZ"

ELSE

WScript.Quit()

END IF

WScript.Quit()

---

My problem is that the reg key is written but the two commands are not
excuted. I've tried to use a complete path to these files as well but it
doesn't work. Any idea?

BTW: This script works well when executed from explorer...
Re: .run method in logon script
Tom Lavedas <tglbatch[ at ]cox.net> 5/15/2007 5:30:39 PM
On May 15, 11:09 am, Kai Lippok <REMOVEME_pub...[ at ]kl-mail.de> wrote:
[Quoted Text]
> Hi,
>
> I am trying to use the following script as a per computer logon script:
>
> ---
> set wshShell = CreateObject("Wscript.shell")
>
> On Error resume next
>
> key = "HKLM\SOFTWARE\UPDATE\INSTALLED"
> test = wshshell.regread(key)
>
> If err <> 0 Then
>
> wshShell.run WindowsUpdateAgent30-x86.exe /wuforce /quiet
> wshShell.run WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart",0,TRUE)
>
> WshShell.RegWrite "HKLM\SOFTWARE\UPDATE\INSTALLED", "1", "REG_SZ"
>
> ELSE
>
> WScript.Quit()
>
> END IF
>
> WScript.Quit()
>
> ---
>
> My problem is that the reg key is written but the two commands are not
> excuted. I've tried to use a complete path to these files as well but it
> doesn't work. Any idea?
>
> BTW: This script works well when executed from explorer...

You almost certainly need the full pathspecs for the two executables,
but the real problem is that there are syntax errors in both run
lines. In addition, the On Error statement is not helping you
troubleshoot the problems the way it is instituted.

To be syntactically correct the two run lines should be changed to
be ...

wshShell.run "WindowsUpdateAgent30-x86.exe /wuforce /quiet", 0,
true
wshShell.run "WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart",
0, TRUE

To test for success in running the programs, you should build them
something like this ...

sCmd = "WindowsUpdateAgent30-x86.exe /wuforce /quiet"
nRes = wshShell.run(sCmd, 0, true)
if nRes = 0 then
sCmd = "WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart"
nRes = wshShell.run(sCmd, 0, true)
end if

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Re: .run method in logon script
Kai Lippok <REMOVEME_public[ at ]kl-mail.de> 5/16/2007 7:29:43 AM
Hi,

these syntax errors were just in the posted text because of previous
testings. Anyway, you are right. I've modified the script and it works
fine now - even without the full path to the binaries (they are in the
dir as the script):

---

set wshShell = CreateObject("Wscript.shell")

On Error resume next

key = "HKLM\SOFTWARE\UPDATE\INSTALLED"
test = wshshell.regread(key)

If err <> 0 Then

sCmd = "WindowsUpdateAgent30-x86.exe /wuforce /quiet"
nRes = wshShell.run(sCmd, 0, true)

if nRes = 0 then

sCmd = "WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart"
nRes = wshShell.run(sCmd, 0, true)

WshShell.RegWrite "HKLM\SOFTWARE\UPDATE\INSTALLED", "1", "REG_SZ"

end if

ELSE

WScript.Quit()

END IF

WScript.Quit()

---

Thank you!

Tom Lavedas schrieb:
[Quoted Text]
> On May 15, 11:09 am, Kai Lippok <REMOVEME_pub...[ at ]kl-mail.de> wrote:
>> Hi,
>>
>> I am trying to use the following script as a per computer logon script:
>>
>> ---
>> set wshShell = CreateObject("Wscript.shell")
>>
>> On Error resume next
>>
>> key = "HKLM\SOFTWARE\UPDATE\INSTALLED"
>> test = wshshell.regread(key)
>>
>> If err <> 0 Then
>>
>> wshShell.run WindowsUpdateAgent30-x86.exe /wuforce /quiet
>> wshShell.run WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart",0,TRUE)
>>
>> WshShell.RegWrite "HKLM\SOFTWARE\UPDATE\INSTALLED", "1", "REG_SZ"
>>
>> ELSE
>>
>> WScript.Quit()
>>
>> END IF
>>
>> WScript.Quit()
>>
>> ---
>>
>> My problem is that the reg key is written but the two commands are not
>> excuted. I've tried to use a complete path to these files as well but it
>> doesn't work. Any idea?
>>
>> BTW: This script works well when executed from explorer...
>
> You almost certainly need the full pathspecs for the two executables,
> but the real problem is that there are syntax errors in both run
> lines. In addition, the On Error statement is not helping you
> troubleshoot the problems the way it is instituted.
>
> To be syntactically correct the two run lines should be changed to
> be ...
>
> wshShell.run "WindowsUpdateAgent30-x86.exe /wuforce /quiet", 0,
> true
> wshShell.run "WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart",
> 0, TRUE
>
> To test for success in running the programs, you should build them
> something like this ...
>
> sCmd = "WindowsUpdateAgent30-x86.exe /wuforce /quiet"
> nRes = wshShell.run(sCmd, 0, true)
> if nRes = 0 then
> sCmd = "WindowsXP-KB927891-v3-x86-DEU.exe /quiet /norestart"
> nRes = wshShell.run(sCmd, 0, true)
> end if
>
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/
>

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