Following is my script my computer startup script in my GP. I'm not very
good in scripting but I managed to put this script together. Two things are
not working right in this script.

Firstly, I want the unistallation process complete before the login prompt
appears but this does not happen. I am using sleep wscript.sleep this is not
ideal and not working well because some machines need longer time and others
need shorter time, depending on the network connection and speed of PCs. In
a thinking in the lines of putting a function where if the uninstall process
begins the login prompt is hidden/disabled or unavailable is until the whole
proccess is completed and rebooted. Please, help me as I need to have this
working by the end of this week.

Secondly, After unistall process completes I want it to reboot the machine
again but this does not happen as well. This probably because not completing
the uninstall process and the using logon interferring but I'm not sure. Is
anything wrong with my RebootPC() function? how can I fix it?

Thank you everyone for your quick help
' ----------------------------------------------------------------
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set WSHShell=WScript.CreateObject("WScript.Shell")
Set fs=CreateObject("Scripting.FileSystemObject")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
rem check if file exist, if it is jump out
If Not fs.fileExists("c:\UninstallOfficepro.log") Then
'WScript.Echo "officepro removed"
'Else
'Set the registry key path And thi
strKeyPath = _

"Software\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0050048383C9}"
strValueName = "DisplayName"
Return = objReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE,_
strKeyPath,strValueName,strValue)
' If key does exist and display name is Microsoft Office XP
Professional then run uninstall command
If (Return = 0) And (strValue="Microsoft Office XP Professional") And
(Err.Number = 0) Then
rem WScript.Echo "Program is " & strValue & " " & StrKeypath
WshShell.Run _
("%systemroot%\System32\msiexec.exe
/x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
C:\UninstallOfficepro.log")
WScript.Sleep(5000)
'RestartPC()
'WScript.Sleep(5000)
Else
'WScript.Echo _
' "GetExpandedStringValue failed. Error = " & Err.Number
WScript.Quit(0)
End If
End If
WScript.Quit(0)

'
---------------------------------------------------------------------------------
' This function reboots the Pc after uninstalling officepro
Function RestartPC()
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
End Function

Re: Help me again with Script please by Georges

Georges
Mon Jan 23 02:30:46 CST 2006

Hello Eric
In your line WshShell.Run you can add 2 parameters :
- the first one is to indicate the state of the window in wich the run is
executed (1 to set it activated)
- the second one is to tell the script to stop until the end of the run (use
the value true)
So your run should be :
WshShell.Run("%systemroot%\System32\msiexec.exe
/x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
C:\UninstallOfficepro.log",1,true)

Regards
Georges


"Eric Hela" <EricHela@discussions.microsoft.com> a écrit dans le message de
news: 8714A843-C967-4B60-A87E-DFDB05C1211C@microsoft.com...
> Following is my script my computer startup script in my GP. I'm not very
> good in scripting but I managed to put this script together. Two things
> are
> not working right in this script.
>
> Firstly, I want the unistallation process complete before the login prompt
> appears but this does not happen. I am using sleep wscript.sleep this is
> not
> ideal and not working well because some machines need longer time and
> others
> need shorter time, depending on the network connection and speed of PCs.
> In
> a thinking in the lines of putting a function where if the uninstall
> process
> begins the login prompt is hidden/disabled or unavailable is until the
> whole
> proccess is completed and rebooted. Please, help me as I need to have this
> working by the end of this week.
>
> Secondly, After unistall process completes I want it to reboot the machine
> again but this does not happen as well. This probably because not
> completing
> the uninstall process and the using logon interferring but I'm not sure.
> Is
> anything wrong with my RebootPC() function? how can I fix it?
>
> Thank you everyone for your quick help
> ' ----------------------------------------------------------------
> Const HKEY_LOCAL_MACHINE = &H80000002
> strComputer = "."
> Set WSHShell=WScript.CreateObject("WScript.Shell")
> Set fs=CreateObject("Scripting.FileSystemObject")
> Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
> strComputer & "\root\default:StdRegProv")
> rem check if file exist, if it is jump out
> If Not fs.fileExists("c:\UninstallOfficepro.log") Then
> 'WScript.Echo "officepro removed"
> 'Else
> 'Set the registry key path And thi
> strKeyPath = _
>
> "Software\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0050048383C9}"
> strValueName = "DisplayName"
> Return = objReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE,_
> strKeyPath,strValueName,strValue)
> ' If key does exist and display name is Microsoft Office XP
> Professional then run uninstall command
> If (Return = 0) And (strValue="Microsoft Office XP Professional") And
> (Err.Number = 0) Then
> rem WScript.Echo "Program is " & strValue & " " & StrKeypath
> WshShell.Run _
> ("%systemroot%\System32\msiexec.exe
> /x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
> C:\UninstallOfficepro.log")
> WScript.Sleep(5000)
> 'RestartPC()
> 'WScript.Sleep(5000)
> Else
> 'WScript.Echo _
> ' "GetExpandedStringValue failed. Error = " & Err.Number
> WScript.Quit(0)
> End If
> End If
> WScript.Quit(0)
>
> '
> ---------------------------------------------------------------------------------
> ' This function reboots the Pc after uninstalling officepro
> Function RestartPC()
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
> "\root\cimv2")
> Set colOperatingSystems = objWMIService.ExecQuery _
> ("Select * from Win32_OperatingSystem")
> For Each objOperatingSystem in colOperatingSystems
> ObjOperatingSystem.Reboot()
> Next
> End Function



Re: Help me again with Script please by EricHela

EricHela
Mon Jan 23 17:06:02 CST 2006

Thank you very much for this, the uninstall works perfect. Now I wanna
reboot after uninstall but it doesn't work. By the way, this script runs at
machine startup script. When I test manually it works but not in the
startup. Please help again. Following is up updated script.
-------------
onst HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set WSHShell=WScript.CreateObject("WScript.Shell")
Set fs=CreateObject("Scripting.FileSystemObject")
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
strComputer & "\root\default:StdRegProv")
rem check if file exist, if it is jump out
If Not fs.fileExists("c:\UninstallOfficepro.log") Then
'WScript.Echo "officepro removed"
'Else
'Set the registry key path
strKeyPath = _

"Software\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0050048383C9}"
strValueName = "DisplayName"
Return = objReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE,_
strKeyPath,strValueName,strValue)
' If key does exist and display name is Microsoft Office XP
Professional then run uninstall command
If (Return = 0) And (strValue="Microsoft Office XP Professional") And
(Err.Number = 0) Then
rem WScript.Echo "Program is " & strValue & " " & StrKeypath
WshShell.run _
("%systemroot%\System32\msiexec.exe
/x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
C:\UninstallOfficepro.log"), 1, True
WScript.Sleep(10000)
RebootPC
Else
WScript.Quit(0)
End If
Else
End If

WScript.Quit(0)

Function RebootPc()
' This function reboots the Pc after uninstalling officepro
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
"\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next
End function

"Georges MAUREL" wrote:

> Hello Eric
> In your line WshShell.Run you can add 2 parameters :
> - the first one is to indicate the state of the window in wich the run is
> executed (1 to set it activated)
> - the second one is to tell the script to stop until the end of the run (use
> the value true)
> So your run should be :
> WshShell.Run("%systemroot%\System32\msiexec.exe
> /x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
> C:\UninstallOfficepro.log",1,true)
>
> Regards
> Georges
>
>
> "Eric Hela" <EricHela@discussions.microsoft.com> a écrit dans le message de
> news: 8714A843-C967-4B60-A87E-DFDB05C1211C@microsoft.com...
> > Following is my script my computer startup script in my GP. I'm not very
> > good in scripting but I managed to put this script together. Two things
> > are
> > not working right in this script.
> >
> > Firstly, I want the unistallation process complete before the login prompt
> > appears but this does not happen. I am using sleep wscript.sleep this is
> > not
> > ideal and not working well because some machines need longer time and
> > others
> > need shorter time, depending on the network connection and speed of PCs.
> > In
> > a thinking in the lines of putting a function where if the uninstall
> > process
> > begins the login prompt is hidden/disabled or unavailable is until the
> > whole
> > proccess is completed and rebooted. Please, help me as I need to have this
> > working by the end of this week.
> >
> > Secondly, After unistall process completes I want it to reboot the machine
> > again but this does not happen as well. This probably because not
> > completing
> > the uninstall process and the using logon interferring but I'm not sure.
> > Is
> > anything wrong with my RebootPC() function? how can I fix it?
> >
> > Thank you everyone for your quick help
> > ' ----------------------------------------------------------------
> > Const HKEY_LOCAL_MACHINE = &H80000002
> > strComputer = "."
> > Set WSHShell=WScript.CreateObject("WScript.Shell")
> > Set fs=CreateObject("Scripting.FileSystemObject")
> > Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_
> > strComputer & "\root\default:StdRegProv")
> > rem check if file exist, if it is jump out
> > If Not fs.fileExists("c:\UninstallOfficepro.log") Then
> > 'WScript.Echo "officepro removed"
> > 'Else
> > 'Set the registry key path And thi
> > strKeyPath = _
> >
> > "Software\Microsoft\Windows\CurrentVersion\Uninstall\{90110409-6000-11D3-8CFE-0050048383C9}"
> > strValueName = "DisplayName"
> > Return = objReg.GetExpandedStringValue(HKEY_LOCAL_MACHINE,_
> > strKeyPath,strValueName,strValue)
> > ' If key does exist and display name is Microsoft Office XP
> > Professional then run uninstall command
> > If (Return = 0) And (strValue="Microsoft Office XP Professional") And
> > (Err.Number = 0) Then
> > rem WScript.Echo "Program is " & strValue & " " & StrKeypath
> > WshShell.Run _
> > ("%systemroot%\System32\msiexec.exe
> > /x{90110409-6000-11D3-8CFE-0050048383C9} /passive /qb /l*v
> > C:\UninstallOfficepro.log")
> > WScript.Sleep(5000)
> > 'RestartPC()
> > 'WScript.Sleep(5000)
> > Else
> > 'WScript.Echo _
> > ' "GetExpandedStringValue failed. Error = " & Err.Number
> > WScript.Quit(0)
> > End If
> > End If
> > WScript.Quit(0)
> >
> > '
> > ---------------------------------------------------------------------------------
> > ' This function reboots the Pc after uninstalling officepro
> > Function RestartPC()
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> > & "{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer &
> > "\root\cimv2")
> > Set colOperatingSystems = objWMIService.ExecQuery _
> > ("Select * from Win32_OperatingSystem")
> > For Each objOperatingSystem in colOperatingSystems
> > ObjOperatingSystem.Reboot()
> > Next
> > End Function
>
>
>

Re: Help me again with Script please by deckhopper

deckhopper
Tue Jan 24 01:15:10 CST 2006

Shutting down is hard to do thanks to Windows Security Stuff.

I'd just call a 3rd party shutdown program via the command line

objShell.Run("shutdown.exe -r -f", 1, False)

Shutdown programs:
1. file://localhost/%systemroot%/system32/ ("shutdown.exe")
(already on XP, copy to sys32 for Win2k)

2. http://www.grc.com/wizmo/wizmo.htm -- command line options


Re: Help me again with Script please by EricHela

EricHela
Tue Jan 24 05:34:03 CST 2006

Thanks Deckhopper,
You guys are wonderful. Thank you for pointing to wizmo. Wizmo reboot
works terrific. However, I would prefer to use shutdown.exe which is already
in windows XP but it work. It seems like something is stoping the force
reboot.
I tried objShell.Run("shutdown.exe -r -f"), 1, False and
objShell.Run("shutdown.exe -r -f"), 1, True

Has anyone got any further suggestions?

"deckhopper" wrote:

> Shutting down is hard to do thanks to Windows Security Stuff.
>
> I'd just call a 3rd party shutdown program via the command line
>
> objShell.Run("shutdown.exe -r -f", 1, False)
>
> Shutdown programs:
> 1. file://localhost/%systemroot%/system32/ ("shutdown.exe")
> (already on XP, copy to sys32 for Win2k)
>
> 2. http://www.grc.com/wizmo/wizmo.htm -- command line options
>
>

Re: Help me again with Script please by deckhopper

deckhopper
Tue Jan 24 07:01:19 CST 2006

Make sure you are calling shutdown.exe as a user with local admin
rights. Otherwise, it won't shutdown.

Also, open the cmd line, and call "shutdown.exe -r -f" straight from
there. If it works there, then your vbs syntax is incorrect.
I noticed your code says "WshShell.run" whereas mine says
"objShell.Run"

Try this snippet of code (tested/working on XP, Win2k):
' ########
Set objShell = CreateObject("WScript.Shell")
objShell.Run "shutdown.exe -r -f", 1, False
' ########


Re: Help me again with Script please by EricHela

EricHela
Tue Jan 24 09:34:05 CST 2006

deckhopper,

thanks once again.

Both of this scripts, mine and your latest one below works on my test
machine when I run in my script editor. It goes through and reboots the
machine. But it doesn't work when I put it in the Computer startup script in
the computer policy. I'm not too sure about making the script needing to run
using local admin privileges. I thought since the script is in the computer
startup policy it should have that privilege automatically.

Thanks for your help once again

"deckhopper" wrote:

> Make sure you are calling shutdown.exe as a user with local admin
> rights. Otherwise, it won't shutdown.
>
> Also, open the cmd line, and call "shutdown.exe -r -f" straight from
> there. If it works there, then your vbs syntax is incorrect.
> I noticed your code says "WshShell.run" whereas mine says
> "objShell.Run"
>
> Try this snippet of code (tested/working on XP, Win2k):
> ' ########
> Set objShell = CreateObject("WScript.Shell")
> objShell.Run "shutdown.exe -r -f", 1, False
> ' ########
>
>

Re: Help me again with Script please by deckhopper

deckhopper
Wed Jan 25 05:10:24 CST 2006

1. Put the following in the startup script only as a test:

shutdown.exe -r -f

If that works, then privileges are not an issue. If it doesn't
work, then perhaps privileges are at hand.

*Note: To keep it from looping (startup/shutdown...)
open cmd and type --> shutdown -a <-- (abort shutdown)

2. I would also take out "On Error Resume Next" (if you have that in
your script). If there is an error, it will show up.

3. Try the following as well:

gpedit.msc
Local Computer Policy
Windows Settings
Security Settings
Local Policies
User Rights Assignment
Force shutdown from a remote system - (add "Everyone" here)

Then test the uninstall.vbs in the startup script again


Re: Help me again with Script please by eric

eric
Sun Jan 29 22:08:08 CST 2006

Thank you heaps Deckhopper, for continuing response with the bright
suggestions. I will let you know after the test.

rgds
Eric
"deckhopper" <deckhopper@gmail.com> wrote in message
news:1138187424.861726.90870@g14g2000cwa.googlegroups.com...
> 1. Put the following in the startup script only as a test:
>
> shutdown.exe -r -f
>
> If that works, then privileges are not an issue. If it doesn't
> work, then perhaps privileges are at hand.
>
> *Note: To keep it from looping (startup/shutdown...)
> open cmd and type --> shutdown -a <-- (abort shutdown)
>
> 2. I would also take out "On Error Resume Next" (if you have that in
> your script). If there is an error, it will show up.
>
> 3. Try the following as well:
>
> gpedit.msc
> Local Computer Policy
> Windows Settings
> Security Settings
> Local Policies
> User Rights Assignment
> Force shutdown from a remote system - (add "Everyone" here)
>
> Then test the uninstall.vbs in the startup script again
>



Re: Help me again with Script please by eric

eric
Mon Jan 30 18:03:37 CST 2006

Deckhopper,
This is what happened.
Firstly I put this code in my startup script.

strComputer = "."
Set WSHShell=WScript.CreateObject("WScript.Shell")
WshShell.run("%systemroot%\System32\shutdown.exe -r -f")
WScript.Quit(0)

It doesn't work.

I then put this code in startup.bat file

echo helo
pause
c:\windows\system32\shutdown.exe -r -f
pause

The response on the next line after pause says:
" Device not ready "

This could explain why? For some reason while it is doing the startup
script it is not ready to reboot.......

Interesting again. I use wizmo reboot program and it forces a reboot. What
could be a difference?

Thank you once again


"deckhopper" <deckhopper@gmail.com> wrote in message
news:1138187424.861726.90870@g14g2000cwa.googlegroups.com...
> 1. Put the following in the startup script only as a test:
>
> shutdown.exe -r -f
>
> If that works, then privileges are not an issue. If it doesn't
> work, then perhaps privileges are at hand.
>
> *Note: To keep it from looping (startup/shutdown...)
> open cmd and type --> shutdown -a <-- (abort shutdown)
>
> 2. I would also take out "On Error Resume Next" (if you have that in
> your script). If there is an error, it will show up.
>
> 3. Try the following as well:
>
> gpedit.msc
> Local Computer Policy
> Windows Settings
> Security Settings
> Local Policies
> User Rights Assignment
> Force shutdown from a remote system - (add "Everyone" here)
>
> Then test the uninstall.vbs in the startup script again
>



Re: Help me again with Script please by deckhopper

deckhopper
Tue Jan 31 06:51:36 CST 2006

Then it looks like WIZMO is your new best friend! Thanks to the
almighty Steve Gibson! ---> www.grc.com


Re: Help me again with Script please by eric

eric
Tue Jan 31 15:51:46 CST 2006

Yes, seems that is the only way. I will be forced to use this util as it
seems there is no other way.

Thank you very much for your time and help once again. I have learned a lot
in this conversation.

rgds
Eric
"deckhopper" <deckhopper@gmail.com> wrote in message
news:1138711896.809408.265930@g43g2000cwa.googlegroups.com...
> Then it looks like WIZMO is your new best friend! Thanks to the
> almighty Steve Gibson! ---> www.grc.com
>