#209911 - 2015-02-05 06:20 PM
Read value of shell output?
|
Robdutoit
Hey THIS is FUN
 
Registered: 2012-03-27
Posts: 363
Loc: London, England
|
I have this command in my kixtart startup script
shell 'netsh advfirewall firewall add rule name="WSUS Pub Host" dir=in program="%winDir%\System32\SvcHost.exe" remoteip=localsubnet action=allow'
This adds the firewall rule beautifully. What I did not realise is that it adds a new rule every single time the computer is restarted.
I have determined that I need to run this command to check if rule exists.
netsh advfirewall firewall show rule name="WSUS Pub Host
However, I cannot work out how to do a logic like this: I know the coding is wrong!
if shell 'netsh advfirewall firewall show rule name="Allow WSUS Package Publisher Service Host"' = 1
? "Firewall rule does exist"
else
? "Firewall rule does not exist"
shell 'netsh advfirewall firewall add rule name="WSUS Pub Host" dir=in program="%winDir%\System32\SvcHost.exe" remoteip=localsubnet action=allow'
endif
How do I get a shell to output success or failure in the above example. Thanks dudes!
|
|
Top
|
|
|
|
#209912 - 2015-02-05 06:24 PM
Re: Read value of shell output?
[Re: Robdutoit]
|
Allen
KiX Supporter
   
Registered: 2003-04-19
Posts: 4574
Loc: USA
|
|
|
Top
|
|
|
|
#209921 - 2015-02-06 04:33 PM
Re: Read value of shell output?
[Re: Allen]
|
Robdutoit
Hey THIS is FUN
 
Registered: 2012-03-27
Posts: 363
Loc: London, England
|
I have just checked the article again. I see that you do need the comspec if you are command piping, which is obviously the case here. this is what I was reading up where they advise not to use comspec unless really needed!
comspec and kixtart
|
|
Top
|
|
|
|
#209922 - 2015-02-06 07:51 PM
Re: Read value of shell output?
[Re: Robdutoit]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Yes, great site at one time. Amazing it's still around as I'm not sure the creator of the site is still with us or not.
http://home.online.nl/scripting/
Copyright © 2003 scripting@wanadoo.nl - created at 15 July 2000/last updated on 15 November 2003
|
|
Top
|
|
|
|
#209932 - 2015-02-07 04:10 PM
Re: Read value of shell output?
[Re: Allen]
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#209933 - 2015-02-07 04:16 PM
Re: Read value of shell output?
[Re: Jochen]
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|