PDA

View Full Version : Office Activating



Pages : 1 2 3 [4]

DocAElstein
11-15-2019, 10:32 PM
Post for later use

DocAElstein
11-15-2019, 10:32 PM
Post for later use

DocAElstein
11-15-2019, 10:32 PM
Post for later use

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-15-2019, 10:34 PM
Post in support of these Threads

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11597&viewfull=1#post11597
https://www.askvg.com/how-to-add-network-connections-shortcut-in-desktop-context-menu-under-windows-vista-and-7/#comment-2751367



This is very helpful. Thankyou. Continually navigating the "hidden" Vista Network Connections was annoying

Another option is a Desktop shortcut:
Right click on a space on the desktop , then New -->Shortcut , enter something like one of these
C:\Windows\explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
explorer.exe ::{7007ACC7-3202-11D1-AAD2-00805FC1270E}
C:\Windows\System32\ncpa.cpl
ncpa.cpl

Alan




[FONT=Arial] [color="#3E0000"]
_2b) Make a desktop icon or , add "[size=2] Network Connections " shortcut in Desktop context menu, for quick access of the Network Connections console.
You will likely frequently want to access this when, for example, first getting VPN up and running.
Because it is annoying to find in Vista , you will save yourself some time and frustration if you make a desktop icon link so as to get quickly at it.
To do this in Vista
_2b)(i) desktop Shortcut. Using Desktop Right Click [size=2] --- New

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
11-21-2019, 01:46 AM
In support of this Thread:

http://www.excelfox.com/forum/showthread.php/2384-VPN-Forum-access-and-IP-addresse-Tests?p=11656&viewfull=1#post11656


Later...

vnbvv

DocAElstein
02-08-2022, 09:32 PM
I hit a problem later
I hit a problem later…. The full main file actually looked like this in a text editor:
https://i.postimg.cc/4mzznGXy/Actual-Main-File.jpg (https://postimg.cc/4mzznGXy)
and it got me an 9 line array, where I was expecting one of 2102
https://i.postimg.cc/hfFLSvWN/arr-Rws-M-Bollox.jpg (https://postimg.cc/hfFLSvWN)

I don’t know how that came about since the four lines file was made and saved in the same ISE environment in which the Main file was and was saved in. But it looks like unfortunately there may be a few, 9 , vbCr & vbLfs.
So, I took a look at a shortened vision of that file, as saved in a text editor, trying to capture some of the problem areas.
This is what I looked at
https://i.postimg.cc/G8VkThB8/Actual-Main-File-Problem-Areas.jpg (https://postimg.cc/G8VkThB8)

Here is the results:


"Function BlochIPhosts " & Chr(123) & "param" & "(" & Chr(91) & "int" & Chr(93) & "$" & "Testie" & ")" & vbCr & vbLf & " " & "$" & "Check " & "=" & " " & "$" & "Testie" & vbCr & vbLf & "Write" & "-" & "Host " & """" & "Adding telemetry domains to hosts file" & """" & " " & "#" & " Write" & "-" & "Output " & """" & "Adding telemetry domains to hosts file" & """" & vbCr & vbLf & "$" & "hosts" & "_" & "file " & "=" & " " & """" & "$" & "env" & ":" & "systemroot" & "\" & "System32" & "\" & "drivers" & "\" & "etc" & "\" & "hosts" & """"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms" & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms " & "#" & " For ps1 in PowerShell running code lines in PowerShell with Admin rights of the following form are what you need to set this off Set" & "-" & "ExecutionPolicy Unrestricted cd " & "'" & "G" & ":" & "\" & "Temp Opt" & "\" & "GitHub" & "\" & "win10script" & "-" & "master" & "\" & "My ps1 file Folder" & "'" & " " & "." & "\" & "win10debloat6Dec" & "-" & "31Dec" & "." & "ps1 " & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'" & vbLf
& "$" & "wshell " & "=" & " New" & "-" & "Object " & "-" & "ComObject Wscript" & "." & "Shell" & vbLf & "$" & "Button " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxButton" & Chr(93) & ":" & ":" & "YesNoCancel" & vbLf & "$" & "ErrorIco " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxImage" & Chr(93) & ":" & ":" & "Error" & vbLf & "If " & "(" & "!" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsPrincipal" & Chr(93) & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsIdentity" & Chr(93) & ":" & ":" & "GetCurrent" & "(" & ")" & ")" & "." & "IsInRole" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsBuiltInRolpl" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldcontrolpanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c control" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldsystempanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c sysdm" & "." & "cpl" & vbLf & Chr(125
) & ")" & vbLf & "#" & " " & "$" & "oldpower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "restorepower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "NFS" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "#" & " " & "$" & "Virtualization" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "$" & "windowsupdatefix" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " Write" & "-" & "Host " & """" & "1" & "." & " Stopping Windows Update Services" & "." & "." & "." & """" & " " & vbLf & " Stop" & "-" & "Service "
& "-" & "Name BITS " & vbLf & " " & " "

From that above output we can see 11, so that’s 10 lines rather than 9. This inconsistency by 1 is somewhat worrying.
I looked at the array produced from that shortened text file, and it is as before, 9
One possibility is that some length restriction is long some of the line feed pairs, or a line slipped in at my making of the shortened file

For the masochistic pleasure I tried the full main file in the first simple macro. To my surprise, it worked, after a few hours, the result came out.
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/12zw9id42xrwc7qy70ul87bg0wfpb4uh
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/771q1gzpycle7ccveu235j256n4l4xyb
It returned 8, making 9 lines.

So that discrepancy is perhaps sorted.
My initial conclusions may have based on slightly careless manipulations that brought some invisible characters in.

One possibility is that the original main coding came from GitHub: This for example talks about the line feed issue at GitHub
http://vcloud-lab.com/entries/devops/resolved-git-warning-lf-will-be-replaced-by-crlf-in-file#at_pco=smlwn-1.0&at_si=624547148f04cd41&at_ab=per-2&at_pos=0&at_tot=1

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page53#post12804
A similar requirement to the last post, but for purposes of comparing a change in script by having the two versions side by side
I will do the whole thing again, just to see if I still experience similar effects on a different day.

I am interested in what seems to be a change by Chris Titus to his recent “WPF” windows utility
This change was somehow in between others, ( (ii) inbetween (i) and (iii) ), so may have slipped past most people.
I am taking my data from this red and green stuff , middle in Commit thing,
Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
or maybe not… This is what I have
The previous XML from god knows where and when, ( the red stuff from that last link )
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
The “new” green stuff from that last link
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



_ (iii) This is now from the next change the next change called up XML thing


The big mystery seems to be for now where and what that red stuff comes from or is.
It seems that the full script from 10 May, the full script from just before the last change (ii) on 17May, and the stand alone XLM in change (iii) all have the same XML stuff


I think I will leave it for now… It’s all a total mess. It looks like he changed something he was never using to update it to what he was using.


….. later








Share ‘ChrisWPFTuesday10May2022.ps1’ https://app.box.com/s/end0t4spyl119iiixw9va922hdft4icx


Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
Share ‘ChrisWPF17May2022(ii).ps1’ https://app.box.com/s/yrzoikeg9coggyt99ofin18f2cxkf849
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



The new thng thing (iii) , https://github.com/ChrisTitusTech/winutil/commit/7d4727b51be22ecfbff953357789e4d5d2923b63
https://i.postimg.cc/fR8Hhcv1/Git-Hub17-May-Update-XML.jpg
https://i.postimg.cc/90y83sxB/The-new-thing-iii.jpg
https://i.postimg.cc/vHd27HB2/The-new-thng-thing-iii.jpg
https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/MainWindow.xaml
Share ‘MainWindow_xami - StandAloneXML17May.txt’ https://app.box.com/s/lrf37fuhegad3jfgjltzlmckmw33lpj2
Share ‘MainWindow.xaml’ https://app.box.com/s/3b6v4zmgb6njamh6khyqe44zpk7cmaak

Share ‘ChrisWPF17May2022.ps1’ https://app.box.com/s/lrzeyx55hjksedzrr649snrxfmfyvtkm
Share ‘ChrisWPF17May2022(iii).ps1’ https://app.box.com/s/7u4lxbwrgubxgf37tduzx0e22s49alvf

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use
:mad:

DocAElstein
02-08-2022, 09:32 PM
Link to this post #73 #Post19687
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube/page8#Post19687
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube/page8#Post19687
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube?p=19687&viewfull=1#post19687
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube?p=19687&viewfull=1#post19687
https://bit.ly/3Xy3ZEF https://bit.ly/3I4YEz7




February 2023...... Frankenstein YouTube Zimmer taking shape... https://postimg.cc/gallery/QFt2XdX

Temporary Bench https://i.postimg.cc/PJtH2LV4/CIMG5716.jpg ... collecting all the computers and such together
Scaffolding Bars ... Picked out and cleaned the newest / shiniest of all my Scaffolding bars ... to hang things from .... and swing around like an ape to keep fit...

Burning open fire .. in the corner of the Dungeon room … maybe I will leave it like that, messy and raw, sit there Naked with my bask to the fire and make a real gruesome look



https://i.postimg.cc/4xJsDSmv/CIMG5710.jpg
4811https://i.postimg.cc/pp1w8kQy/CIMG5710.jpg (https://postimg.cc/pp1w8kQy)https://i.postimg.cc/4xJsDSmv/CIMG5710.jpg (https://postimg.cc/pp1w8kQy)


https://i.postimg.cc/KYkVwPrr/CIMG5711.jpg
4812https://i.postimg.cc/XZWQyyPp/CIMG5711.jpg (https://postimg.cc/XZWQyyPp)

https://i.postimg.cc/yYsMxSss/CIMG5712.jpg
4813https://i.postimg.cc/K4pqsj1H/CIMG5712.jpg (https://postimg.cc/K4pqsj1H)

https://i.postimg.cc/P5q0zsC7/CIMG5713.jpg
4814https://i.postimg.cc/RNjP4YQ1/CIMG5713.jpg (https://postimg.cc/RNjP4YQ1)

4815 https://i.postimg.cc/YCyZdngC/CIMG5715.jpg
https://i.postimg.cc/YvYd9xb5/CIMG5715.jpg
(https://postimg.cc/YvYd9xb5)https://i.postimg.cc/PJtH2LV4/CIMG5716.jpg (https://postimg.cc/R6b200B6)

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use...... This is post #75 #post19689
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube?p=19689&viewfull=1#post19689
https://excelfox.com/forum/showthread.php/2840-Notes-tests-Scrapping-YouTube?p=19689&viewfull=1#post19689



white Snow stuff is a very special thing that comes down from the sky here and makes everything very Pretty. It also makes the ground nice and soft to go jogging on. I like it a lot.
For one year I did find a nice old disused railway line and in winter when it snows it is very Beautiful and I look forward every evening to my Jog. It is like my own private jogging train line.
https://i.postimg.cc/cHMDFZrr/Soft-Snow-to-Jog-On.jpg
https://i.postimg.cc/7YBRvxXz/Auf-meine-Jog-Weg-Taucht-das-Schnee-zu-letzter.jpg
https://i.postimg.cc/pTtGQyVw/Beautiful-Jogging.jpg
https://i.postimg.cc/JhXYBj83/Old-Disused-Railway.jpg
https://i.postimg.cc/T3FHwCzY/Pretty-Snow.jpg
_.________________

https://postimg.cc/gallery/vBm1X8g

https://i.postimg.cc/cHMDFZrr/Soft-Snow-to-Jog-On.jpg (https://postimages.org/)

https://i.postimg.cc/JhXYBj83/Old-Disused-Railway.jpg (https://postimages.org/)

https://i.postimg.cc/7YBRvxXz/Auf-meine-Jog-Weg-Taucht-das-Schnee-zu-letzter.jpg (https://postimg.cc/rKrjx2By)

https://i.postimg.cc/T3FHwCzY/Pretty-Snow.jpg (https://postimages.org/)





https://i.postimg.cc/pTtGQyVw/Beautiful-Jogging.jpg (https://postimages.org/)

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

Eine Sonntag arbenteuer


07.11.2021, 18:38



Also, wir laufen, und da wo ich sonnst im dunkel jog, kann man im Herbst tags grade noch was da drüben sehen … evtl. eine alte abstell gleise???

https://i.postimg.cc/fWBK2nYY/1-Was-Rechts-Evtl.jpg

Aber wir Lauf zu erste weiter..

Es ist ja interessant was man auf dem weg für abfall seiht-

https://i.postimg.cc/ncNWHj0H/2-Interesant-Abfall.jpg

Eine Voll milch , Bergator..

https://i.postimg.cc/J7DcRTgk/3-Ein-Berghator-Voll-Milch.jpg





Also was passiertet wenn der richtigen Weg geht rechts, und eine alte kleine weg geht links… Die meiste Leute Endscheidung die normaller weg

https://i.postimg.cc/KYpB2LDf/4-Weg-geht-rechts.jpg



Ich und Pooh , geh aber links entlang

https://i.postimg.cc/wMwdfqp1/5-wir-gehen-aber-links.jpg



Bald kommt das weg zu ende…

https://i.postimg.cc/wxfX55dV/6-Weg-endet.jpg



Aber da drüben ist was – eine Groß Kompost berg… ( in der Feld hinter war jemand für eine paar tagen gejagt bei eine Wolf in dunkel )

https://i.postimg.cc/kg8WdkR1/7-eiune-gross-posty-berg-da-druben.jpg



Links unter im Bild seiht man aber was…

https://i.postimg.cc/vHxVWphY/8-da-links-ist-was.jpg



Ein Loch - Da hat jemand im Dunkel auch hingefallen als er weg ran von die Wolf

https://i.postimg.cc/W4NzfKGJ/9-eine-gross-loch-aber-was-ist-da-links-unter.jpg

Beim aufstehen damals habe ich eine gleise end entdeckt. ( das sieht man gerade noch in das letzte Bild, links unten )



Ws ist die Ende eine alte gleise, und jemand sitz da…

https://i.postimg.cc/7Zmm55NG/11-ein-gleise-end.jpg



Ach so, Tigger passt auf das keine Zug zu weit fahrt, Die arme sitz da in seiner orange regen Jacke , Geschütz von wetter

https://i.postimg.cc/cJLkhRJB/12-da-wacht-jemand-auf.jpg



In die andere Richtung ist interessant

https://i.postimg.cc/cHK9ydwK/13-inder-ander-richtung.jpg



Sieht wie eine alte Bahnhof

https://i.postimg.cc/g2kKbYPY/14-eine-klein-alte-bahnhof.jpg



Aber da ist was auf dem gleise

https://i.postimg.cc/j5VN2TBn/19-was-ist-das.jpg



Eine naughty Pumkin sitz auf dem Gleise – wahrscheinlich weil er war langweiliges so lange auf eine Zug zu warten.

https://i.postimg.cc/pTDjn7tG/21-Ein-naught-pumpkin.jpg

Aber , Bahnhof Station meister sagt ihm er soll zurück auf Bahnsteig



Und beide warte auf Zug ordentlich

https://i.postimg.cc/05nMR75w/22-ordentlisch-warten-auf-zug.jpg



Mir ist aber aufgefallen das keine Zug kommt…

https://i.postimg.cc/VkdbF58b/23-kommt-aber-keine-Muss-schauern.jpg

Ich schau also weiter

Auch so …

https://i.postimg.cc/rwBzCJjv/24-Auch-so-alles-zug-nach-plauern-nur.jpg

alle Zug geht rechts nach Plauern, weil weicher geht rechts/ geraderaus. Also, ruf ich der Station Meister Pooh

Er macht sich auf die arbeite

https://i.postimg.cc/d3NV7mDN/25-Pooh-sets-weichern.jpg



Und jetzt wurde alle Zug umgeleitet zu unserer Bahnhof

https://i.postimg.cc/SxMxs94V/26-zug-geht-jetzt-zu-Pooh-bahnhof.jpg

( Aber echt – es ist Wahnsinn – das weicher ist voll ge- öled und gefettet – es funktioniert – da kann jede Kind oder verruchte die Zug um leiten – gibt’s keine schalte, Kamera, schloss, oder sonnst es zu verhindern.)

Ist aber echt dumm oder..

Keine Angst, Pooh hast wieder zurück

https://i.postimg.cc/MHHW8Mt7/27-Weicher-weider-zuruck.jpg



Ich schau weiter, da ist eine blick das mir von Hitchin erinnert wo ich bei eine Brücke unter gegangen war von meine Jogg weg

https://i.postimg.cc/jdzsYb4k/28-Hitchin-blick.jpg



Aber ich geh weiter

https://i.postimg.cc/Z5thwMkF/29-es-geht-weiter.jpg



Und weiter

https://i.postimg.cc/zDHzpWbN/31-Und-weiter.jpg



Wer arbeitet dort vorher..

https://i.postimg.cc/qBKr2TSM/32-wer-arbeitet-dort.jpg



Auch so, immer viele zu tun fürs Station meister Pooh, er muss Ester weg sägen von seine gleise

https://i.postimg.cc/tJQLBswR/33-ach-so-Pooh-s-ged-ester-weg-von-seine-gleise.jpg



Er hat ja, sehr viele zu tun, aber heute habe ihm viel Gehilfen und neben bei mehrere Brenn Holz lager platz gemacht

https://i.postimg.cc/MTRLfWTC/34-Pooh-hat-veil-zu-tun-Ich-schau-allein-weiter.jpg



Mann konnte denken die gleis hört auf

https://i.postimg.cc/Y00mySWV/35-End-Ich-denk-nicht.jpg



Aber es geht noch weiter,

https://i.postimg.cc/LsVY9Pkw/36-weiter.jpg



Dann geht rechts zu interessant schön Holz teile

https://i.postimg.cc/BnHPzkjq/37-rechts-zu-gross-Bau-Holz-lager-platz.jpg



Gerade und links, geht so wie eine blick zu Dachau….

https://i.postimg.cc/26wK70QG/38-links-und-gerade-aus-zu-Daschau.jpg



Aber bei Tages licht geh ich nicht weiter, ich gen links

https://i.postimg.cc/WbD5dNHX/39-bei-tagres-licjt-geh-ich-nicht-weiter.jpg



Ich mach eine letzter Bild von meine neue schön gefundener bretter und Balkon Holz Vorrat…

https://i.postimg.cc/MTPYGN0C/41-letzter-Photo-von-meine-neue-gelargeter-holz-bretter.jpg



Ich denk, da Links oben konnte was ….

https://i.postimg.cc/hhFTzBX5/42-links-uben-ist-was-denk-ich.jpg



Beispielsweise links eine Zug

https://i.postimg.cc/JzNcXGcc/43-beispiels-weise-links-zug.jpg



Mir ist aber rechts was mehr interessant, … konnte eine alte weg…

https://i.postimg.cc/qvsS7BNW/44-rects-konnte-eine-weg.jpg



Hatte recht, noch neben die Bahn strecke, eine alte weg

https://i.postimg.cc/fWd6Pvww/45-alte-gleise-weg-evt.jpg





Der Gleise ist weg, aber trotzdem eine schön Boingy Boingy jogg weg..

https://i.postimg.cc/MXk3WgqW/46-ja-gleise-weg-aber-schon-boingy-jog-weg.jpg



irgendwann ist aber die schnell wachsender weise Rind baumle zu dick gewachsen

https://i.postimg.cc/y8nqPY7c/47-die-schnell-w-chsender-weise-rind-baumla-speer-weg-weiter.jpg



Aber echts daneben ist eine schön weise

https://i.postimg.cc/0yKmGrYH/48-Aber-rechst-ist-schon-weise.jpg





Ich denke sogar ist es rasen gemährt

https://i.postimg.cc/NGRzDf4F/49-sogar-gem-ht-weise.jpg





Weise du wo ich jetzt da bin?

https://i.postimg.cc/6Q1Dkj2Q/51-weise-du-wo.jpg



Noch nicht weise? – jetzt aber

https://i.postimg.cc/8P9fCD2d/52-noch-nicht-kennt-sich.jpg



Jetzt sollst Du wissen. Die tour ist fast fertig. Rechts unter ist Vissmann.

https://i.postimg.cc/RFgNxz1H/53-jetzt-sollst-wissen.jpg

Links über der Bahn Übergang geht’s zu studentenberg – ich komm also raus von meine jogg weg an die andere seit von vor das normaller weg geht zu Feilitzch.



Das wars

Gesichte Ende…

:)

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
This is post https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491



So I will make a function, just for convenience even though I am not so keen on those things
It will take in
_(i) The two file names , the main one, and then the one to be inserted,
_(ii) the line at which to insert, and optional the number of lines to insert, ( if no number is given, I assume all lines want to be inserted from the second file )
_ an optional name for the output file, ( if none is given I will add something like the date to the name of the original main file, and call it that)

_(iii) Based on the results from the last post, I probably will need to keep my eye on the line feed issue. For now the way to proceed could be to first replace all vbCr & vbLf with vbLf, to get them hopefully all to the same , and then after replace all vbLf with vbCr & vbLf
_ (iv) I assume all files are in the same folder

The techniques used to bring the files into 1 dimensional array of rows are tried and trusted, used many times before. I have the main file in a master array , arrRwsM() , and the file to be merged into it is in the array, arrRws()
At the point of the code development, where these arrays were made, I checked the contents, and there was perfect agreement between the rows in the ps1 files, and the elements of the arrays.

So what is new is to combine, merge, the files as required
A simple loop will do, that tacks on the extra coding from the left in the master code array.
We don’t need to add many spaces, since usually there is already many since the commented lines are over to the right. This is a simple coding bit to do that,
______ arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1)
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual “getting end row from start row and count of rows” issue - its always (the start row) + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr

Its extremely easy now to remake the modified text file by joining the modified array elements by a line separator,
____ TotalFile = Join(arrRwsM(), vbCr & vbLf)
( For now I will stay with the vbCr & vbLf , as my personal preference )

' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
Sub testieIt() ' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
Call MergeScriptFiles("Temp7BeforeIPhostsInsert.ps1", "blockIPhostsRawAll250.ps1", 201, , "Temp8.ps1")
End Sub
' ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String
Public Function MergeScriptFiles(ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String)
Rem 1 main file
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtM ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the Main text file
Dim arrRwsM() As String: Let arrRwsM() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 2 file to insert
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtInst ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the file to insert
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 3 tack on lines from file to merge
If Rws = 0 Then Let Rws = UBound(arrRws()) + 1 ' This will cause all lines to be merged if no number of lines given
Dim LnNbr As Long
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual getting end row from start row and count of rows issue - its always the start row + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr ' LnNbr - StRw takes us from 0 to 1 less than our maximumn row number - that is exactly the 0 to (1 less than our maximumn row number)
' 3b That seems to have done it, now we just need to remake the merged text file,
' Make text file, alll we need to do is make the single long string including the line breaks that
Let TotalFile = Join(arrRwsM(), vbCr & vbLf)
Rem 4 Output file
Dim FileNum2 As Long: Let FileNum2 = FreeFile(0) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName2 As String
If FlNmeOut = "" Then Let FlNmeOut = Left(TxtM, InStrRev(TxtM, ".") - 1) & "Merge" & Format(Now(), "dd,mmmyyyy") & ".ps1"
Let PathAndFileName2 = ThisWorkbook.Path & "\" & FlNmeOut ' ' CHANGE TO SUIT ' Will be made if not there
Open PathAndFileName2 For Output As #FileNum2
Print #FileNum2, TotalFile ' write out entire text file
Close #FileNum2
End Function



That above coding has got me my Temp8.ps1 which is Temp7.ps1 with the merged IP hosts block function, along with a few other things done at the end of march, including a first look at a pretty coloured GUI












' Temp7BeforeIPhostsInsert https://app.box.com/s/fttlmwny6y4s5ub1q66kvqbrw2ppxdwz
https://i.postimg.cc/T2K3rjbC/hosts-Before-2022-04.jpg

' blockIPhostsRawAll250 https://app.box.com/s/7019x59uvvxt7osvb0tojr0z4g7bfdgk


https://i.postimg.cc/pV3Xk9Yx/hosts-After-2022-04.jpg
' Temp8.ps1 https://app.box.com/s/9b9li86s7dyysr7exdle30pckgp7vscz

DocAElstein
02-08-2022, 09:32 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page53#post12804
A similar requirement to the last post, but for purposes of comparing a change in script by having the two versions side by side
I will do the whole thing again, just to see if I still experience similar effects on a different day.

I am interested in what seems to be a change by Chris Titus to his recent “WPF” windows utility
This change was somehow in between others, ( (ii) inbetween (i) and (iii) ), so may have slipped past most people.
I am taking my data from this red and green stuff , middle in Commit thing,
Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
or maybe not… This is what I have
The previous XML from god knows where and when, ( the red stuff from that last link )
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
The “new” green stuff from that last link
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



_ (iii) This is now from the next change the next change called up XML thing


The big mystery seems to be for now where and what that red stuff comes from or is.
It seems that the full script from 10 May, the full script from just before the last change (ii) on 17May, and the stand alone XLM in change (iii) all have the same XML stuff


I think I will leave it for now… It’s all a total mess. It looks like he changed something he was never using to update it to what he was using.


….. later








Share ‘ChrisWPFTuesday10May2022.ps1’ https://app.box.com/s/end0t4spyl119iiixw9va922hdft4icx


Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
Share ‘ChrisWPF17May2022(ii).ps1’ https://app.box.com/s/yrzoikeg9coggyt99ofin18f2cxkf849
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



The new thng thing (iii) , https://github.com/ChrisTitusTech/winutil/commit/7d4727b51be22ecfbff953357789e4d5d2923b63
https://i.postimg.cc/fR8Hhcv1/Git-Hub17-May-Update-XML.jpg
https://i.postimg.cc/90y83sxB/The-new-thing-iii.jpg
https://i.postimg.cc/vHd27HB2/The-new-thng-thing-iii.jpg
https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/MainWindow.xaml
Share ‘MainWindow_xami - StandAloneXML17May.txt’ https://app.box.com/s/lrf37fuhegad3jfgjltzlmckmw33lpj2
Share ‘MainWindow.xaml’ https://app.box.com/s/3b6v4zmgb6njamh6khyqe44zpk7cmaak

Share ‘ChrisWPF17May2022.ps1’ https://app.box.com/s/lrzeyx55hjksedzrr649snrxfmfyvtkm
Share ‘ChrisWPF17May2022(iii).ps1’ https://app.box.com/s/7u4lxbwrgubxgf37tduzx0e22s49alvf

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
I hit a problem later
I hit a problem later…. The full main file actually looked like this in a text editor:
https://i.postimg.cc/4mzznGXy/Actual-Main-File.jpg (https://postimg.cc/4mzznGXy)
and it got me an 9 line array, where I was expecting one of 2102
https://i.postimg.cc/hfFLSvWN/arr-Rws-M-Bollox.jpg (https://postimg.cc/hfFLSvWN)

I don’t know how that came about since the four lines file was made and saved in the same ISE environment in which the Main file was and was saved in. But it looks like unfortunately there may be a few, 9 , vbCr & vbLfs.
So, I took a look at a shortened vision of that file, as saved in a text editor, trying to capture some of the problem areas.
This is what I looked at
https://i.postimg.cc/G8VkThB8/Actual-Main-File-Problem-Areas.jpg (https://postimg.cc/G8VkThB8)

Here is the results:


"Function BlochIPhosts " & Chr(123) & "param" & "(" & Chr(91) & "int" & Chr(93) & "$" & "Testie" & ")" & vbCr & vbLf & " " & "$" & "Check " & "=" & " " & "$" & "Testie" & vbCr & vbLf & "Write" & "-" & "Host " & """" & "Adding telemetry domains to hosts file" & """" & " " & "#" & " Write" & "-" & "Output " & """" & "Adding telemetry domains to hosts file" & """" & vbCr & vbLf & "$" & "hosts" & "_" & "file " & "=" & " " & """" & "$" & "env" & ":" & "systemroot" & "\" & "System32" & "\" & "drivers" & "\" & "etc" & "\" & "hosts" & """"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms" & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms " & "#" & " For ps1 in PowerShell running code lines in PowerShell with Admin rights of the following form are what you need to set this off Set" & "-" & "ExecutionPolicy Unrestricted cd " & "'" & "G" & ":" & "\" & "Temp Opt" & "\" & "GitHub" & "\" & "win10script" & "-" & "master" & "\" & "My ps1 file Folder" & "'" & " " & "." & "\" & "win10debloat6Dec" & "-" & "31Dec" & "." & "ps1 " & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'" & vbLf
& "$" & "wshell " & "=" & " New" & "-" & "Object " & "-" & "ComObject Wscript" & "." & "Shell" & vbLf & "$" & "Button " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxButton" & Chr(93) & ":" & ":" & "YesNoCancel" & vbLf & "$" & "ErrorIco " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxImage" & Chr(93) & ":" & ":" & "Error" & vbLf & "If " & "(" & "!" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsPrincipal" & Chr(93) & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsIdentity" & Chr(93) & ":" & ":" & "GetCurrent" & "(" & ")" & ")" & "." & "IsInRole" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsBuiltInRolpl" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldcontrolpanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c control" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldsystempanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c sysdm" & "." & "cpl" & vbLf & Chr(125
) & ")" & vbLf & "#" & " " & "$" & "oldpower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "restorepower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "NFS" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "#" & " " & "$" & "Virtualization" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "$" & "windowsupdatefix" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " Write" & "-" & "Host " & """" & "1" & "." & " Stopping Windows Update Services" & "." & "." & "." & """" & " " & vbLf & " Stop" & "-" & "Service "
& "-" & "Name BITS " & vbLf & " " & " "

From that above output we can see 11, so that’s 10 lines rather than 9. This inconsistency by 1 is somewhat worrying.
I looked at the array produced from that shortened text file, and it is as before, 9
One possibility is that some length restriction is long some of the line feed pairs, or a line slipped in at my making of the shortened file

For the masochistic pleasure I tried the full main file in the first simple macro. To my surprise, it worked, after a few hours, the result came out.
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/12zw9id42xrwc7qy70ul87bg0wfpb4uh
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/771q1gzpycle7ccveu235j256n4l4xyb
It returned 8, making 9 lines.

So that discrepancy is perhaps sorted.
My initial conclusions may have based on slightly careless manipulations that brought some invisible characters in.

One possibility is that the original main coding came from GitHub: This for example talks about the line feed issue at GitHub
http://vcloud-lab.com/entries/devops/resolved-git-warning-lf-will-be-replaced-by-crlf-in-file#at_pco=smlwn-1.0&at_si=624547148f04cd41&at_ab=per-2&at_pos=0&at_tot=1

DocAElstein
02-08-2022, 09:32 PM
This is post https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491



So I will make a function, just for convenience even though I am not so keen on those things
It will take in
_(i) The two file names , the main one, and then the one to be inserted,
_(ii) the line at which to insert, and optional the number of lines to insert, ( if no number is given, I assume all lines want to be inserted from the second file )
_ an optional name for the output file, ( if none is given I will add something like the date to the name of the original main file, and call it that)

_(iii) Based on the results from the last post, I probably will need to keep my eye on the line feed issue. For now the way to proceed could be to first replace all vbCr & vbLf with vbLf, to get them hopefully all to the same , and then after replace all vbLf with vbCr & vbLf
_ (iv) I assume all files are in the same folder

The techniques used to bring the files into 1 dimensional array of rows are tried and trusted, used many times before. I have the main file in a master array , arrRwsM() , and the file to be merged into it is in the array, arrRws()
At the point of the code development, where these arrays were made, I checked the contents, and there was perfect agreement between the rows in the ps1 files, and the elements of the arrays.

So what is new is to combine, merge, the files as required
A simple loop will do, that tacks on the extra coding from the left in the master code array.
We don’t need to add many spaces, since usually there is already many since the commented lines are over to the right. This is a simple coding bit to do that,
______ arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1)
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual “getting end row from start row and count of rows” issue - its always (the start row) + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr

Its extremely easy now to remake the modified text file by joining the modified array elements by a line separator,
____ TotalFile = Join(arrRwsM(), vbCr & vbLf)
( For now I will stay with the vbCr & vbLf , as my personal preference )

' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
Sub testieIt() ' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
Call MergeScriptFiles("Temp7BeforeIPhostsInsert.ps1", "blockIPhostsRawAll250.ps1", 201, , "Temp8.ps1")
End Sub
' ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String
Public Function MergeScriptFiles(ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String)
Rem 1 main file
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtM ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the Main text file
Dim arrRwsM() As String: Let arrRwsM() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 2 file to insert
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtInst ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the file to insert
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 3 tack on lines from file to merge
If Rws = 0 Then Let Rws = UBound(arrRws()) + 1 ' This will cause all lines to be merged if no number of lines given
Dim LnNbr As Long
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual getting end row from start row and count of rows issue - its always the start row + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr ' LnNbr - StRw takes us from 0 to 1 less than our maximumn row number - that is exactly the 0 to (1 less than our maximumn row number)
' 3b That seems to have done it, now we just need to remake the merged text file,
' Make text file, alll we need to do is make the single long string including the line breaks that
Let TotalFile = Join(arrRwsM(), vbCr & vbLf)
Rem 4 Output file
Dim FileNum2 As Long: Let FileNum2 = FreeFile(0) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName2 As String
If FlNmeOut = "" Then Let FlNmeOut = Left(TxtM, InStrRev(TxtM, ".") - 1) & "Merge" & Format(Now(), "dd,mmmyyyy") & ".ps1"
Let PathAndFileName2 = ThisWorkbook.Path & "\" & FlNmeOut ' ' CHANGE TO SUIT ' Will be made if not there
Open PathAndFileName2 For Output As #FileNum2
Print #FileNum2, TotalFile ' write out entire text file
Close #FileNum2
End Function



That above coding has got me my Temp8.ps1 which is Temp7.ps1 with the merged IP hosts block function, along with a few other things done at the end of march, including a first look at a pretty coloured GUI












' Temp7BeforeIPhostsInsert https://app.box.com/s/fttlmwny6y4s5ub1q66kvqbrw2ppxdwz
https://i.postimg.cc/T2K3rjbC/hosts-Before-2022-04.jpg

' blockIPhostsRawAll250 https://app.box.com/s/7019x59uvvxt7osvb0tojr0z4g7bfdgk


https://i.postimg.cc/pV3Xk9Yx/hosts-After-2022-04.jpg
' Temp8.ps1 https://app.box.com/s/9b9li86s7dyysr7exdle30pckgp7vscz

DocAElstein
02-08-2022, 09:32 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page53#post12804
A similar requirement to the last post, but for purposes of comparing a change in script by having the two versions side by side
I will do the whole thing again, just to see if I still experience similar effects on a different day.

I am interested in what seems to be a change by Chris Titus to his recent “WPF” windows utility
This change was somehow in between others, ( (ii) inbetween (i) and (iii) ), so may have slipped past most people.
I am taking my data from this red and green stuff , middle in Commit thing,
Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
or maybe not… This is what I have
The previous XML from god knows where and when, ( the red stuff from that last link )
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
The “new” green stuff from that last link
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



_ (iii) This is now from the next change the next change called up XML thing


The big mystery seems to be for now where and what that red stuff comes from or is.
It seems that the full script from 10 May, the full script from just before the last change (ii) on 17May, and the stand alone XLM in change (iii) all have the same XML stuff


I think I will leave it for now… It’s all a total mess. It looks like he changed something he was never using to update it to what he was using.


….. later








Share ‘ChrisWPFTuesday10May2022.ps1’ https://app.box.com/s/end0t4spyl119iiixw9va922hdft4icx


Mistery Red and Green stuff https://github.com/ChrisTitusTech/winutil/commit/a4019d74ec3fca44208eb3b621d6f8ac9bee5a64
Share ‘ChrisWPF17May2022(ii).ps1’ https://app.box.com/s/yrzoikeg9coggyt99ofin18f2cxkf849
Share ‘May10-17XML.txt’ https://app.box.com/s/ykynprd9a3ra4w7kcif4h5ziubwktw2t
Share ‘May17XML.txt’ https://app.box.com/s/gsqjpfmmqwpadmu8wchjrlfrqxwrrg6e



The new thng thing (iii) , https://github.com/ChrisTitusTech/winutil/commit/7d4727b51be22ecfbff953357789e4d5d2923b63
https://i.postimg.cc/fR8Hhcv1/Git-Hub17-May-Update-XML.jpg
https://i.postimg.cc/90y83sxB/The-new-thing-iii.jpg
https://i.postimg.cc/vHd27HB2/The-new-thng-thing-iii.jpg
https://raw.githubusercontent.com/ChrisTitusTech/winutil/main/MainWindow.xaml
Share ‘MainWindow_xami - StandAloneXML17May.txt’ https://app.box.com/s/lrf37fuhegad3jfgjltzlmckmw33lpj2
Share ‘MainWindow.xaml’ https://app.box.com/s/3b6v4zmgb6njamh6khyqe44zpk7cmaak

Share ‘ChrisWPF17May2022.ps1’ https://app.box.com/s/lrzeyx55hjksedzrr649snrxfmfyvtkm
Share ‘ChrisWPF17May2022(iii).ps1’ https://app.box.com/s/7u4lxbwrgubxgf37tduzx0e22s49alvf

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-08-2022, 09:32 PM
Insert some lines without losing what’s there / Retain Comments / Shift what’s there to the right
A fairly simple problem
A common requirement for me is that I want to put some raw code lines into an existing script or VBA code, but I don’t want to change the line numbers referring to where they do in the existing code file.
This might occur if I want to replace some coding, but would like to keep the existing coding for future reference, possibly commented out to the right
What I might do typically for just a few lines is to manually put a comment at the start left of lines to be replaced, and then shift those now comments a few spaces to the right, then start typing the replacement lines from the left, which then pushed those comments to the left
Pictorially this is what I mean for the simple case of wanting to replace just one line

Sub Original()
Dim Msg As String
Let Msg = "Hello"
MsgBox Prompt:="Hello shit World"
End Sub
Sub ModifiedByInsertingNewCodeLine()
Dim Msg As String
Let Msg = "Hello"
Debug.Print "Hello shit World" ' MsgBox Prompt:="Hello shit World"
End Sub
That’s easy for a few lines, but for a lot of lines it’s a tedious pain in the arse

.ps1 PowerShell text like code lines
Currently have some large .ps1 PowerShell files that I am inserting a lot of lines in and want to do it in the way I am talking about
In this post I will check out the format of the files first, in case there are any unusual “invisible” characters in them, since I have seen that in some PowerShell related text files ( https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15357&viewfull=1#post15357 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page3#post15357 )
Here is a File of 250 code line, that I want to put in,
Share ‘blockIPhostsRawAll250.ps1’ https://app.box.com/s/7019x59uvvxt7osvb0tojr0z4g7bfdgk ,
and here is just the first 4 lines for testing here,
Share ‘blockIPhosts4Lines.ps1’ https://app.box.com/s/37pjl9jfk9wue413xewgcjg1cdwk9dwb .
Here is a File I want to put that in from about line 200,
Share ‘Temp7BeforeIPhostsInsert.ps1’ https://app.box.com/s/fttlmwny6y4s5ub1q66kvqbrw2ppxdwz
, and here is just the first 4 lines of that for testing here,
Share ‘Temp7BeforeIPhostsInsertFirst4Lines.ps1’ https://app.box.com/s/bimxv550fpkoqndt8rz421s9vmcsorif .

Simple macro …_
'Here is a File of 250 code line, that I want to put in,
'Share ‘blockIPhostsRawAll250.ps1’ https://app.box.com/s/7019x59uvvxt7osvb0tojr0z4g7bfdgk ,
'and here is just the first 4 lines for testing here,
'Share ‘blockIPhosts4Lines.ps1’ https://app.box.com/s/37pjl9jfk9wue413xewgcjg1cdwk9dwb .
'Here is a File I want to put that in from about line 200,
'Share ‘Temp7BeforeIPhostsInsert.ps1’ https://app.box.com/s/fttlmwny6y4s5ub1q66kvqbrw2ppxdwz
', and here is just the first 4 lines of that for testing here,
'Share ‘Temp7BeforeIPhostsInsertFirst4Lines.ps1’ https://app.box.com/s/bimxv550fpkoqndt8rz421s9vmcsorif .
'
'
Sub LookInFirstBitOfTemp4andIPhosts() ' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16366&viewfull=1#post16366
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test4lines.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
'Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare)
Close #FileNum
Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)
End Sub


Here is a view in the text editor of those first 4 lines, followed by what my WtchaGot_Unic_NotMuchIfYaChoppedItOff( function gives me
https://i.postimg.cc/n9kqsv63/First4-Lines-Of2ps1-Files.jpg (https://postimg.cc/n9kqsv63)

Function BlochIPhosts {param([int]$Testie)
$Check = $Testie
Write-Host "Adding telemetry domains to hosts file" # Write-Output "Adding telemetry domains to hosts file"
$hosts_file = "$env:systemroot\System32\drivers\etc\hosts"


"Function BlochIPhosts " & Chr(123) & "param" & "(" & Chr(91) & "int" & Chr(93) & "$" & "Testie" & ")" & vbCr & vbLf & " " & "$" & "Check " & "=" & " " & "$" & "Testie" & vbCr & vbLf & "Write" & "-" & "Host " & """" & "Adding telemetry domains to hosts file" & """" & " " & "#" & " Write" & "-" & "Output " & """" & "Adding telemetry domains to hosts file" & """" & vbCr & vbLf & "$" & "hosts" & "_" & "file " & "=" & " " & """" & "$" & "env" & ":" & "systemroot" & "\" & "System32" & "\" & "drivers" & "\" & "etc" & "\" & "hosts" & """"



Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles() #
Remove-Variable * -ErrorAction SilentlyContinue # is needed or else a removed variable is still there when fucking about with variables. by default variables are persistant.
$ErrorActionPreference = 'SilentlyContinue'


"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms" & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'"
Here is a screenshot of the two files in Notepad text editor
https://i.postimg.cc/n9kqsv63/First4-Lines-Of2ps1-Files.jpg (https://postimg.cc/n9kqsv63)

So, no major problems or surprises, ( or so I thought – see next post )
It looks like a different line separator is used sometimes. But we have seen this before.
I have a slight personal tendency to prefer the two character line separator, vbCr & vbLf , and also the first file was the main one in which the other will be inserted, so I will do a simple conversion to the file to be inserted to replace all vbLf with vbCr & vbLf


One small interesting note. I don’t have a last trailing line feed character or characters. That is not so usual, at least I have not experienced it yet so far in playing around with .csv and other text files

DocAElstein
02-08-2022, 09:32 PM
I hit a problem later
I hit a problem later…. The full main file actually looked like this in a text editor:
https://i.postimg.cc/4mzznGXy/Actual-Main-File.jpg (https://postimg.cc/4mzznGXy)
and it got me an 9 line array, where I was expecting one of 2102
https://i.postimg.cc/hfFLSvWN/arr-Rws-M-Bollox.jpg (https://postimg.cc/hfFLSvWN)

I don’t know how that came about since the four lines file was made and saved in the same ISE environment in which the Main file was and was saved in. But it looks like unfortunately there may be a few, 9 , vbCr & vbLfs.
So, I took a look at a shortened vision of that file, as saved in a text editor, trying to capture some of the problem areas.
This is what I looked at
https://i.postimg.cc/G8VkThB8/Actual-Main-File-Problem-Areas.jpg (https://postimg.cc/G8VkThB8)

Here is the results:


"Function BlochIPhosts " & Chr(123) & "param" & "(" & Chr(91) & "int" & Chr(93) & "$" & "Testie" & ")" & vbCr & vbLf & " " & "$" & "Check " & "=" & " " & "$" & "Testie" & vbCr & vbLf & "Write" & "-" & "Host " & """" & "Adding telemetry domains to hosts file" & """" & " " & "#" & " Write" & "-" & "Output " & """" & "Adding telemetry domains to hosts file" & """" & vbCr & vbLf & "$" & "hosts" & "_" & "file " & "=" & " " & """" & "$" & "env" & ":" & "systemroot" & "\" & "System32" & "\" & "drivers" & "\" & "etc" & "\" & "hosts" & """"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms" & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'"

"Add" & "-" & "Type " & "-" & "AssemblyName System" & "." & "Windows" & "." & "Forms " & "#" & " For ps1 in PowerShell running code lines in PowerShell with Admin rights of the following form are what you need to set this off Set" & "-" & "ExecutionPolicy Unrestricted cd " & "'" & "G" & ":" & "\" & "Temp Opt" & "\" & "GitHub" & "\" & "win10script" & "-" & "master" & "\" & "My ps1 file Folder" & "'" & " " & "." & "\" & "win10debloat6Dec" & "-" & "31Dec" & "." & "ps1 " & vbLf & Chr(91) & "System" & "." & "Windows" & "." & "Forms" & "." & "Application" & Chr(93) & ":" & ":" & "EnableVisualStyles" & "(" & ")" & " " & "#" & vbLf & "Remove" & "-" & "Variable " & Chr(42) & " " & "-" & "ErrorAction SilentlyContinue " & "#" & " is needed or else a removed variable is still there when fucking about with variables" & "." & " by default variables are persistant" & "." & vbLf & "$" & "ErrorActionPreference " & "=" & " " & "'" & "SilentlyContinue" & "'" & vbLf
& "$" & "wshell " & "=" & " New" & "-" & "Object " & "-" & "ComObject Wscript" & "." & "Shell" & vbLf & "$" & "Button " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxButton" & Chr(93) & ":" & ":" & "YesNoCancel" & vbLf & "$" & "ErrorIco " & "=" & " " & Chr(91) & "System" & "." & "Windows" & "." & "MessageBoxImage" & Chr(93) & ":" & ":" & "Error" & vbLf & "If " & "(" & "!" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsPrincipal" & Chr(93) & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsIdentity" & Chr(93) & ":" & ":" & "GetCurrent" & "(" & ")" & ")" & "." & "IsInRole" & "(" & Chr(91) & "Security" & "." & "Principal" & "." & "WindowsBuiltInRolpl" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldcontrolpanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c control" & vbLf & Chr(125) & ")" & vbLf & "$" & "oldsystempanel" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " cmd " & "/" & "c sysdm" & "." & "cpl" & vbLf & Chr(125
) & ")" & vbLf & "#" & " " & "$" & "oldpower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "restorepower" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & vbCr & vbLf & "#" & " " & Chr(125) & ")" & vbLf & "#" & " " & "$" & "NFS" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "#" & " " & "$" & "Virtualization" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & vbLf & "#" & " " & Chr(125) & ")" & vbLf & vbLf & "$" & "windowsupdatefix" & "." & "Add" & "_" & "Click" & "(" & Chr(123) & vbLf & " Write" & "-" & "Host " & """" & "1" & "." & " Stopping Windows Update Services" & "." & "." & "." & """" & " " & vbLf & " Stop" & "-" & "Service "
& "-" & "Name BITS " & vbLf & " " & " "

From that above output we can see 11, so that’s 10 lines rather than 9. This inconsistency by 1 is somewhat worrying.
I looked at the array produced from that shortened text file, and it is as before, 9
One possibility is that some length restriction is long some of the line feed pairs, or a line slipped in at my making of the shortened file

For the masochistic pleasure I tried the full main file in the first simple macro. To my surprise, it worked, after a few hours, the result came out.
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/12zw9id42xrwc7qy70ul87bg0wfpb4uh
Temp7BeforeIPhostsInsertFirst4Lines_ps1WtchaGot https://app.box.com/s/771q1gzpycle7ccveu235j256n4l4xyb
It returned 8, making 9 lines.

So that discrepancy is perhaps sorted.
My initial conclusions may have based on slightly careless manipulations that brought some invisible characters in.

One possibility is that the original main coding came from GitHub: This for example talks about the line feed issue at GitHub
http://vcloud-lab.com/entries/devops/resolved-git-warning-lf-will-be-replaced-by-crlf-in-file#at_pco=smlwn-1.0&at_si=624547148f04cd41&at_ab=per-2&at_pos=0&at_tot=1

DocAElstein
02-08-2022, 09:32 PM
This is post https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491



So I will make a function, just for convenience even though I am not so keen on those things
It will take in
_(i) The two file names , the main one, and then the one to be inserted,
_(ii) the line at which to insert, and optional the number of lines to insert, ( if no number is given, I assume all lines want to be inserted from the second file )
_ an optional name for the output file, ( if none is given I will add something like the date to the name of the original main file, and call it that)

_(iii) Based on the results from the last post, I probably will need to keep my eye on the line feed issue. For now the way to proceed could be to first replace all vbCr & vbLf with vbLf, to get them hopefully all to the same , and then after replace all vbLf with vbCr & vbLf
_ (iv) I assume all files are in the same folder

The techniques used to bring the files into 1 dimensional array of rows are tried and trusted, used many times before. I have the main file in a master array , arrRwsM() , and the file to be merged into it is in the array, arrRws()
At the point of the code development, where these arrays were made, I checked the contents, and there was perfect agreement between the rows in the ps1 files, and the elements of the arrays.

So what is new is to combine, merge, the files as required
A simple loop will do, that tacks on the extra coding from the left in the master code array.
We don’t need to add many spaces, since usually there is already many since the commented lines are over to the right. This is a simple coding bit to do that,
______ arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1)
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual “getting end row from start row and count of rows” issue - its always (the start row) + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr

Its extremely easy now to remake the modified text file by joining the modified array elements by a line separator,
____ TotalFile = Join(arrRwsM(), vbCr & vbLf)
( For now I will stay with the vbCr & vbLf , as my personal preference )

' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA/page8#post16491
Sub testieIt() ' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=16491&viewfull=1#post16491
Call MergeScriptFiles("Temp7BeforeIPhostsInsert.ps1", "blockIPhostsRawAll250.ps1", 201, , "Temp8.ps1")
End Sub
' ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String
Public Function MergeScriptFiles(ByVal TxtM As String, ByVal TxtInst As String, ByVal StRw As Long, Optional ByVal Rws As Long, Optional ByVal FlNmeOut As String)
Rem 1 main file
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtM ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the Main text file
Dim arrRwsM() As String: Let arrRwsM() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 2 file to insert
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & TxtInst ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile
Close #FileNum 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, vbCr & vbLf, vbLf, 1, -1, vbBinaryCompare)
Let TotalFile = Replace(TotalFile, vbLf, vbCr & vbLf, 1, -1, vbBinaryCompare)
' make a 1 D array of the file to insert
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

Rem 3 tack on lines from file to merge
If Rws = 0 Then Let Rws = UBound(arrRws()) + 1 ' This will cause all lines to be merged if no number of lines given
Dim LnNbr As Long
For LnNbr = StRw To Rws + StRw - 1 ' This - 1 is the usual getting end row from start row and count of rows issue - its always the start row + ( Rows count - 1 )
Let arrRwsM(LnNbr - 1) = arrRws(LnNbr - StRw) & arrRwsM(LnNbr - 1) ' The - 1 here is because the one dimensional arrays start at 0, so the lines we are intersted in are 1 element back from where we might have expected them
Next LnNbr ' LnNbr - StRw takes us from 0 to 1 less than our maximumn row number - that is exactly the 0 to (1 less than our maximumn row number)
' 3b That seems to have done it, now we just need to remake the merged text file,
' Make text file, alll we need to do is make the single long string including the line breaks that
Let TotalFile = Join(arrRwsM(), vbCr & vbLf)
Rem 4 Output file
Dim FileNum2 As Long: Let FileNum2 = FreeFile(0) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName2 As String
If FlNmeOut = "" Then Let FlNmeOut = Left(TxtM, InStrRev(TxtM, ".") - 1) & "Merge" & Format(Now(), "dd,mmmyyyy") & ".ps1"
Let PathAndFileName2 = ThisWorkbook.Path & "\" & FlNmeOut ' ' CHANGE TO SUIT ' Will be made if not there
Open PathAndFileName2 For Output As #FileNum2
Print #FileNum2, TotalFile ' write out entire text file
Close #FileNum2
End Function



That above coding has got me my Temp8.ps1 which is Temp7.ps1 with the merged IP hosts block function, along with a few other things done at the end of march, including a first look at a pretty coloured GUI












' Temp7BeforeIPhostsInsert https://app.box.com/s/fttlmwny6y4s5ub1q66kvqbrw2ppxdwz
https://i.postimg.cc/T2K3rjbC/hosts-Before-2022-04.jpg

' blockIPhostsRawAll250 https://app.box.com/s/7019x59uvvxt7osvb0tojr0z4g7bfdgk


https://i.postimg.cc/pV3Xk9Yx/hosts-After-2022-04.jpg
' Temp8.ps1 https://app.box.com/s/9b9li86s7dyysr7exdle30pckgp7vscz

DocAElstein
02-08-2022, 09:32 PM
Another post for later use

DocAElstein
02-09-2022, 03:08 PM
Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath\ 'C:\Users\acer\Desktop\test.txt' -Width 1000

Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath\ 'C:\Users\acer\Desktop\test.txt' -Width 1000


Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath\ 'C:\Users\acer\Desktop\test.txt' -Width 1000


Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath\ 'C:\Users\acer\Desktop\test.txt' -Width 1000

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 07:58 PM
In support of these forum posts
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
https://eileenslounge.com/viewtopic.php?f=18&t=37740
https://eileenslounge.com/viewtopic.php?f=18&t=37712
https://eileenslounge.com/viewtopic.php?f=18&t=37707


'Version : 5.1.19041.1320
'InstanceId : e165cf30-9ddd-49ed-96c7-59cca98516ee
'UI: System.Management.Automation.Internal.Host.Interna lHostUserInterface
'CurrentCulture: DE -DE
'CurrentUICulture: DE -DE
'PrivateData: Microsoft.PowerShell.Host.ISE.ISEOptions
'DebuggerEnabled : True
'IsRunspacePushed : False
'Runspace: System.Management.Automation.Runspaces.LocalRunspa ce
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707
Sub Services() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 1000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, -1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, -1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub


Edit Some issues…
I messed up with a few things.
_ the display name could be long and go up to the startuptype in the text file, which messed up the manipulation of a line of data from the text file a bit. For now I fiddled that by adding some spaces before the words used for the startuptype. A better solution will probably wait until I fully understand the PowerShell code line
_ There seems to be some strange effects with something somewhere working too slow, too fast or not giving accurate information about if a text file is present. For now that is fiddled with some Waits , Dirs and a Kill. That will do for now, but that need to be looked at again when I understand better wots going on

The next code version is in the next post
https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16369&viewfull=1#post16369

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
















$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0

Write-Host "Removing Start Menu Tiles"

Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'

$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@

$layoutFile="C:\Windows\StartMenuLayout.xml"

#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}

#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII

$regAliases = @("HKLM", "HKCU")

#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}

#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5

#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0

Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})

DocAElstein
02-09-2022, 11:45 PM
jADHKJASHDKJahdjkAHD

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1UFQySI4QjTTV0O5xnLnLfx5iJh_qDzct/view?usp=drive_web" target="_blank" rel="noopener" aria-label="5.50 8.18 Clean Up Windows 10 _ 3 Steps For A Faster Computer-mWHiP9K8fQ0_16 10 2019.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">5.50 8.18 Clean Up Windows 10 _ 3 Steps For A ...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/11mjTzHbcdY1EwVaV0-AIAmYgC2DCsp7X/view?usp=drive_web" target="_blank" rel="noopener" aria-label="7.56 8 (Ransome) How to Make Windows 10 Secure-pGcerfVqYyU_31 01 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">7.56 8 (Ransome) How to Make Windows 10 Secur...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1b_akgpleMvL4lD4qXYffzUEXh8WhUyZ7/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20 06 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1O63RdRCQS2OvWa50F56m6KyryVsBImIK/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.94 Creating New Windows 10 Debloat Scripts fo..."><img src="https://drive-thirdparty.googleusercontent.com/16/type/video/x-ms-wmv" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.94 Creating New Windows 10 Debloat Scripts fo...</span></a></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">
<div class="gmail_chip gmail_drive_chip">
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;"><a href="https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<br /></span></p>
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgzW4-G9Rh2o5ljabrV4AaABAg</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

DocAElstein
02-09-2022, 11:45 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12782
Security tweaks

# Will like XP or Win7 Disable Windows Defender Disable Defender Updates Set UAC to Never Prompt Disable Meltdown Flag Disable Windows Malware Scan
$securitylow.Add_Click({
Write-Host "Lowering UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
Write-Host "Disabling Windows Defender..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -ErrorAction SilentlyContinue
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -ErrorAction SilentlyContinue
}
Write-Host "Disabling Windows Defender Cloud..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
Write-Host "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue
Write-Host "Disabling Malicious Software Removal Tool offering..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
$wshell.Popup("Operation Completed",0,"Done",0x0)
})


# Enable Windows Malware Scan Enable Meltdown Flag Disable Windows Defender Set UAC to Always Prompt Disable Defender Updates
$securityhigh.Add_Click({
Write-Host "Raising UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
Write-Host "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "Enabling Windows Defender..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
Write-Host "Enabling Windows Defender Cloud..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
Write-Host "Disabling Windows Script Host..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0
Write-Host "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0
Write-Host "Enabling Malicious Software Removal Tool offering..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
$wshell.Popup("Operation Completed",0,"Done",0x0)
})

DocAElstein
02-09-2022, 11:45 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
















$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0

Write-Host "Removing Start Menu Tiles"

Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'

$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@

$layoutFile="C:\Windows\StartMenuLayout.xml"

#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}

#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII

$regAliases = @("HKLM", "HKCU")

#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}

#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5

#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0

Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})

DocAElstein
02-09-2022, 11:45 PM
jADHKJASHDKJahdjkAHD

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1UFQySI4QjTTV0O5xnLnLfx5iJh_qDzct/view?usp=drive_web" target="_blank" rel="noopener" aria-label="5.50 8.18 Clean Up Windows 10 _ 3 Steps For A Faster Computer-mWHiP9K8fQ0_16 10 2019.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">5.50 8.18 Clean Up Windows 10 _ 3 Steps For A ...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/11mjTzHbcdY1EwVaV0-AIAmYgC2DCsp7X/view?usp=drive_web" target="_blank" rel="noopener" aria-label="7.56 8 (Ransome) How to Make Windows 10 Secure-pGcerfVqYyU_31 01 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">7.56 8 (Ransome) How to Make Windows 10 Secur...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1b_akgpleMvL4lD4qXYffzUEXh8WhUyZ7/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20 06 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1O63RdRCQS2OvWa50F56m6KyryVsBImIK/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.94 Creating New Windows 10 Debloat Scripts fo..."><img src="https://drive-thirdparty.googleusercontent.com/16/type/video/x-ms-wmv" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.94 Creating New Windows 10 Debloat Scripts fo...</span></a></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>

DocAElstein
02-09-2022, 11:45 PM
khskjhkshhhfhfhfslhafhalfh

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">
<div class="gmail_chip gmail_drive_chip">
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;"><a href="https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<br /></span></p>
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgzW4-G9Rh2o5ljabrV4AaABAg</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

DocAElstein
02-09-2022, 11:45 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12782
Security tweaks

# Will like XP or Win7 Disable Windows Defender Disable Defender Updates Set UAC to Never Prompt Disable Meltdown Flag Disable Windows Malware Scan
$securitylow.Add_Click({
Write-Host "Lowering UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
Write-Host "Disabling Windows Defender..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -ErrorAction SilentlyContinue
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -ErrorAction SilentlyContinue
}
Write-Host "Disabling Windows Defender Cloud..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
Write-Host "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue
Write-Host "Disabling Malicious Software Removal Tool offering..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
$wshell.Popup("Operation Completed",0,"Done",0x0)
})


# Enable Windows Malware Scan Enable Meltdown Flag Disable Windows Defender Set UAC to Always Prompt Disable Defender Updates
$securityhigh.Add_Click({
Write-Host "Raising UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
Write-Host "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "Enabling Windows Defender..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
Write-Host "Enabling Windows Defender Cloud..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
Write-Host "Disabling Windows Script Host..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0
Write-Host "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0
Write-Host "Enabling Malicious Software Removal Tool offering..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
$wshell.Popup("Operation Completed",0,"Done",0x0)
})

DocAElstein
02-09-2022, 11:45 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
















$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0

Write-Host "Removing Start Menu Tiles"

Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'

$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@

$layoutFile="C:\Windows\StartMenuLayout.xml"

#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}

#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII

$regAliases = @("HKLM", "HKCU")

#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}

#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5

#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0

Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})

DocAElstein
02-09-2022, 11:45 PM
jADHKJASHDKJahdjkAHD

DocAElstein
02-09-2022, 11:45 PM
khskjhkshhhfhfhfslhafhalfh

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">
<div class="gmail_chip gmail_drive_chip">
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;"><a href="https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<br /></span></p>
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgzW4-G9Rh2o5ljabrV4AaABAg</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

DocAElstein
02-09-2022, 11:45 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12782
Security tweaks

# Will like XP or Win7 Disable Windows Defender Disable Defender Updates Set UAC to Never Prompt Disable Meltdown Flag Disable Windows Malware Scan
$securitylow.Add_Click({
Write-Host "Lowering UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
Write-Host "Disabling Windows Defender..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -ErrorAction SilentlyContinue
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -ErrorAction SilentlyContinue
}
Write-Host "Disabling Windows Defender Cloud..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
Write-Host "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue
Write-Host "Disabling Malicious Software Removal Tool offering..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
$wshell.Popup("Operation Completed",0,"Done",0x0)
})


# Enable Windows Malware Scan Enable Meltdown Flag Disable Windows Defender Set UAC to Always Prompt Disable Defender Updates
$securityhigh.Add_Click({
Write-Host "Raising UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
Write-Host "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "Enabling Windows Defender..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
Write-Host "Enabling Windows Defender Cloud..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
Write-Host "Disabling Windows Script Host..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0
Write-Host "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0
Write-Host "Enabling Malicious Software Removal Tool offering..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
$wshell.Popup("Operation Completed",0,"Done",0x0)
})

DocAElstein
02-09-2022, 11:45 PM
In support of this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12783
The ps1 file, and also below the $WindowsSearch.Add_Click(
Share ‘ChrisSearchTweaks18-19July.ps1 https://app.box.com/s/cbs7go8i2tdxw4wguthgxcviecaxjn6b
iex ((New-Object System.Net.WebClient).DownloadString(' https://raw.githubusercontent.com/ChrisTitusTech/win10script/71609526b132f5cd7e3b9167779af60051a80912/win10debloat.ps1'))
















$windowssearch.Add_Click({
Write-Host "Disabling Bing Search in Start Menu..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "BingSearchEnabled" -Type DWord -Value 0
<#
Write-Host "Disabling Cortana"
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Se arch" -Name "CortanaConsent" -Type DWord -Value 0
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
}
#>
Write-Host "Hiding Search Box / Button..."
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Se arch" -Name "SearchboxTaskbarMode" -Type DWord -Value 0

Write-Host "Removing Start Menu Tiles"

Set-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -Value '<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <LayoutOptions StartTileGroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:StartLayout GroupCellWidth="6" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </StartLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </DefaultLayoutOverride>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:UWA AppUserModelID="Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdg e" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' <taskbar:DesktopApp DesktopApplicationLinkPath="%APPDATA%\Microsoft\Windows\Start Menu\Programs\System Tools\File Explorer.lnk" />'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </taskbar:TaskbarPinList>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </defaultlayout:TaskbarLayout>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value ' </CustomTaskbarLayoutCollection>'
Add-Content -Path 'C:\Users\Default\AppData\Local\Microsoft\Windows\ Shell\DefaultLayouts.xml' -value '</LayoutModificationTemplate>'

$START_MENU_LAYOUT = @"
<LayoutModificationTemplate xmlns:defaultlayout="http://schemas.microsoft.com/Start/2014/FullDefaultLayout" xmlns:start="http://schemas.microsoft.com/Start/2014/StartLayout" Version="1" xmlns:taskbar="http://schemas.microsoft.com/Start/2014/TaskbarLayout" xmlns="http://schemas.microsoft.com/Start/2014/LayoutModification">
<LayoutOptions StartTileGroupCellWidth="6" />
<DefaultLayoutOverride>
<StartLayoutCollection>
<defaultlayout:StartLayout GroupCellWidth="6" />
</StartLayoutCollection>
</DefaultLayoutOverride>
</LayoutModificationTemplate>
"@

$layoutFile="C:\Windows\StartMenuLayout.xml"

#Delete layout file if it already exists
If(Test-Path $layoutFile)
{
Remove-Item $layoutFile
}

#Creates the blank layout file
$START_MENU_LAYOUT | Out-File $layoutFile -Encoding ASCII

$regAliases = @("HKLM", "HKCU")

#Assign the start layout and force it to apply with "LockedStartLayout" at both the machine and user level
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
IF(!(Test-Path -Path $keyPath)) {
New-Item -Path $basePath -Name "Explorer"
}
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 1
Set-ItemProperty -Path $keyPath -Name "StartLayoutFile" -Value $layoutFile
}

#Restart Explorer, open the start menu (necessary to load the new layout), and give it a few seconds to process
Stop-Process -name explorer
Start-Sleep -s 5
$wshell = New-Object -ComObject wscript.shell; $wshell.SendKeys('^{ESCAPE}')
Start-Sleep -s 5

#Enable the ability to pin items again by disabling "LockedStartLayout"
foreach ($regAlias in $regAliases){
$basePath = $regAlias + ":\SOFTWARE\Policies\Microsoft\Windows"
$keyPath = $basePath + "\Explorer"
Set-ItemProperty -Path $keyPath -Name "LockedStartLayout" -Value 0

Write-Host "Search and Start Menu Tweaks Complete"
} # This was missing 12 July 2021
})

DocAElstein
02-09-2022, 11:45 PM
jADHKJASHDKJahdjkAHD

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1UFQySI4QjTTV0O5xnLnLfx5iJh_qDzct/view?usp=drive_web" target="_blank" rel="noopener" aria-label="5.50 8.18 Clean Up Windows 10 _ 3 Steps For A Faster Computer-mWHiP9K8fQ0_16 10 2019.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">5.50 8.18 Clean Up Windows 10 _ 3 Steps For A ...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/11mjTzHbcdY1EwVaV0-AIAmYgC2DCsp7X/view?usp=drive_web" target="_blank" rel="noopener" aria-label="7.56 8 (Ransome) How to Make Windows 10 Secure-pGcerfVqYyU_31 01 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">7.56 8 (Ransome) How to Make Windows 10 Secur...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1b_akgpleMvL4lD4qXYffzUEXh8WhUyZ7/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20 06 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1O63RdRCQS2OvWa50F56m6KyryVsBImIK/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.94 Creating New Windows 10 Debloat Scripts fo..."><img src="https://drive-thirdparty.googleusercontent.com/16/type/video/x-ms-wmv" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.94 Creating New Windows 10 Debloat Scripts fo...</span></a></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>

DocAElstein
02-09-2022, 11:45 PM
khskjhkshhhfhfhfslhafhalfh

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
Macro for this post
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776




'In support of these forum posts
'https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776
'https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
'https://eileenslounge.com/viewtopic.php?f=18&t=37740
'https://eileenslounge.com/viewtopic.php?f=18&t=37712
'https://eileenslounge.com/viewtopic.php?f=18&t=37707


Sub Services2() ' https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12776 https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=15356#post15356
' kill the text file before I make it, because the code might otherwise use a previous one, as it takes a second or so to overwrite the old or make a new one
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> ""
If Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) <> "" Then Kill PathName:="" & ThisWorkbook.Path & Application.PathSeparator & "test.txt"
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents
' Application.Wait (Now + TimeValue("0:00:01")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have???
' PowerShell
Dim PScmdLet As String, cmdLet As String
'Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\acer\Desktop\test.txt' -Width 1000"
Let cmdLet = "Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath '" & ThisWorkbook.Path & Application.PathSeparator & "test.txt' -Width 2000"
Let PScmdLet = "powershell -command " & cmdLet ' https://www.devhut.net/vba-run-powershell-command/
CreateObject("WScript.Shell").Exec (PScmdLet)
' we need to wait a bit until the text file is made
Do While Dir("" & ThisWorkbook.Path & Application.PathSeparator & "test.txt", vbNormal) = ""
Application.Wait (Now + TimeValue("0:00:01"))
Loop
DoEvents: DoEvents ' I chucked this in, but did not really have any reason
Application.Wait (Now + TimeValue("0:00:02")) ' I am not sure why I had to do this. It should not be necerssary, without it the text file is empty - maybe Dir says something is there before it is available to have??? 01 seemed OK - I made it 2
' Get the text file as a long single string
Dim FileNum As Long: Let FileNum = FreeFile(1) ' https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/freefile-function
Dim PathAndFileName As String, TotalFile As String
Let PathAndFileName = ThisWorkbook.Path & Application.PathSeparator & "test.txt" ' CHANGE TO SUIT From vixer zyxw1234 : http://www.eileenslounge.com/viewtopic.php?f=30&t=34629 DF.txt https://app.box.com/s/gw941dh9v8sqhvzin3lo9rfc67fjsbic
Open PathAndFileName For Binary As #FileNum 'Open Route to data. Binary is a fundamental type data input...
Let TotalFile = Space(LOF(FileNum)) '....and wot receives it has to be a string of exactly the right length
Get #FileNum, , TotalFile 'Debug.Print TotalFile
Let TotalFile = Replace(TotalFile, Chr(0), "", 1, -1, vbBinaryCompare) ' There seems to be a lot of Chr(0)s in the string https://i.postimg.cc/t43HCQr9/Rather-a-lot-of-Chr-0-s.jpg
'Let TotalFile = Replace(TotalFile, Chr(255) & Chr(254) & vbCr & vbLf, "", 1, 1, vbBinaryCompare) ' this would tsake the first bit of crap out, (alternatively we can just take out the first line when split later by
Close #FileNum
' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(TotalFile)

' make a 1 D array of the text file lines
Dim arrRws() As String: Let arrRws() = Split(TotalFile, vbCr & vbLf, -1, vbBinaryCompare)

' make array for output
Dim arrOut() As String: ReDim arrOut(1 To UBound(arrRws()) - 2, 1 To 3) ' we are ignoring the first 3 lines. The UBound of the 1 dimensional array is already 1 less then the lines we need because a 1 dimensional array starts at 0
Dim Cnt As Long
For Cnt = 1 To UBound(arrRws()) - 2
If arrRws(Cnt + 2) = "" Then
' This should occur at the last empty rows, so we could consider jumping out of the loop here
Else
' This is a bit of a temporary bodge as the Display name sometimes pushes up to the startuptype which screws up the string manipulation below
Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Manual", " Manual", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Automatic", " Auotomatic", 1, 1, vbBinaryCompare): Let arrRws(Cnt + 2) = Replace(arrRws(Cnt + 2), "Disabled", " Disabled", 1, 1, vbBinaryCompare)
' time to split the line string
Dim Pos1 As Long: Let Pos1 = InStr(1, arrRws(Cnt + 2), " ", vbBinaryCompare)
Dim Nme As String: Let Nme = Left(arrRws(Cnt + 2), Pos1 - 1)
Dim Pos3 As Long: Let Pos3 = Len(arrRws(Cnt + 2)) - InStrRev(arrRws(Cnt + 2), " ", -1, vbBinaryCompare)
Dim StrtTyp As String: Let StrtTyp = Right(arrRws(Cnt + 2), Pos3)
Dim DispNme As String: Let DispNme = Replace(arrRws(Cnt + 2), Nme, "", 1, 1, vbBinaryCompare)
Let DispNme = Replace(DispNme, StrtTyp, "", 1, 1, vbBinaryCompare)
Let DispNme = Trim(DispNme)
' fill the array for output
Let arrOut(Cnt, 1) = Nme: arrOut(Cnt, 2) = DispNme: arrOut(Cnt, 3) = StrtTyp
End If

Next Cnt

' Chuck array into a spreadsheet
Let ThisWorkbook.Worksheets("PowerShell").Range("A2").Resize(UBound(arrOut(), 1), 3).Value = arrOut()
ThisWorkbook.Worksheets("PowerShell").Cells.Columns("A:C").EntireColumn.AutoFit

End Sub

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">
<div class="gmail_chip gmail_drive_chip">
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;"><a href="https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgyqZfLMydnVuNbtqTR4AaABAg. 9ZBy1PrRmM89ZEE6b4w03-</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7<br /></span></p>
<p style="margin: 0px;"><span style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000; text-decoration: none;">https://www.youtube.com/watch?v=5ckOWXGDL34&amp;lc=UgzW4-G9Rh2o5ljabrV4AaABAg</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
</div>

DocAElstein
02-09-2022, 11:45 PM
In support of this post https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12782
Security tweaks

# Will like XP or Win7 Disable Windows Defender Disable Defender Updates Set UAC to Never Prompt Disable Meltdown Flag Disable Windows Malware Scan
$securitylow.Add_Click({
Write-Host "Lowering UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
Write-Host "Disabling Windows Defender..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -ErrorAction SilentlyContinue
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -ErrorAction SilentlyContinue
}
Write-Host "Disabling Windows Defender Cloud..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
Write-Host "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue
Write-Host "Disabling Malicious Software Removal Tool offering..."
If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
$wshell.Popup("Operation Completed",0,"Done",0x0)
})


# Enable Windows Malware Scan Enable Meltdown Flag Disable Windows Defender Set UAC to Always Prompt Disable Defender Updates
$securityhigh.Add_Click({
Write-Host "Raising UAC level..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Po licies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
Write-Host "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Write-Host "Enabling Windows Defender..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
If ([System.Environment]::OSVersion.Version.Build -eq 14393) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
} ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) {
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ru n" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
Write-Host "Enabling Windows Defender Cloud..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
Write-Host "Disabling Windows Script Host..."
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0
Write-Host "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Qu alityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0
Write-Host "Enabling Malicious Software Removal Tool offering..."
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
$wshell.Popup("Operation Completed",0,"Done",0x0)
})

DocAElstein
02-09-2022, 11:45 PM
khskjhkshhhfhfhfslhafhalfh

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
test


https://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)/page52
Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs




Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occured" } ; finally {$excel.Quit() } # this section will be done if an error occurs





Remove-Variable * -ErrorAction SilentlyContinue # This is very helpful when developing and debuging skript in the ISE, because the ISE has a habit of maintaining variables values between script executions, so this is needed, or else a removed variable may still be there - when fucking about with variables, this can get you in a very frustrating mess. In technical terms: By default variables are persistant. https://pscustomobject.github.io/powershell/howto/PowerShell-ISE-Clear-Variables/
# https://eileenslounge.com/viewtopic.php?t=33011&sid=726de7ffbd0c03680b62280fd86753e0
# Path I have used for my text file output 'C:\Users\Admin\Desktop\test.txt' here full line Get-Service|Select-Object name,displayname,starttype|Format-Table -AutoSize|Out-File -FilePath 'C:\Users\Admin\Desktop\test.txt' -Width 2000
# and for Excel example file C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls

try # Most of the main coding is in a try section ================================================== ============================
{[object]$excel = New-Object -ComObject Excel.Application # https://www.youtube.com/watch?v=xc8A7Z0JLB0&t=995s
$excel.Visible = $true
[string]$excelPath = "C:\Users\Admin\Desktop\PowerShellAshishRajFeedback .xls"
$excelWB = $excel.workbooks.Open($excelPath)
# Worksheets info
$excelWS=$excelWB.WorkSheets.item("AshishRajCOM")
$excelWS.Activate() # It seems that in PowerShell script an extra () is needed
$excelWS.Cells.Item(1, 1).Value = "name" ; $excelWS.Cells.Item(1, 2).Value = "displayname" ; $excelWS.Cells.Item(1, 3).Value = "starttype"
# write in service
[int]$rowWS = 2
ForEach($Service in Get-Service) { $excelWS.Cells.Item($rowWS, 1).Value = $Service.Name.ToString() ; $excelWS.Cells.Item($rowWS, 2).Value = $Service.DisplayName.ToString() ; $excelWS.Cells.Item($rowWS, 3).Value = $Service.StartType.ToString()
If($Service.Status -eq "Running") { $excelWS.Cells.Item($rowWS, 1).Range(”A1:C1").Font.ColorIndex = 10 }
elseif($Service.Status -eq "Stopped") { $excelWS.Cells.Item($rowWS, 1).Range("A1:C1").Font.ColorIndex = 3 }
$rowWS++ }
$excelWS.Cells.Columns("A:C").EntireColumn.AutoFit() # Tidy up column widths
# $excelWB.SaveAs($excelPath)
$excelWB.Save() # It seems that in PowerShell script an extra () is needed
$excel.Quit() } # ================================================== ================================================== =========
catch { Write-Host "some error occurred" }
finally { $excel .Quit() } # this section will be done if an error occurs

DocAElstein
02-09-2022, 11:45 PM
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1UFQySI4QjTTV0O5xnLnLfx5iJh_qDzct/view?usp=drive_web" target="_blank" rel="noopener" aria-label="5.50 8.18 Clean Up Windows 10 _ 3 Steps For A Faster Computer-mWHiP9K8fQ0_16 10 2019.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">5.50 8.18 Clean Up Windows 10 _ 3 Steps For A ...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/11mjTzHbcdY1EwVaV0-AIAmYgC2DCsp7X/view?usp=drive_web" target="_blank" rel="noopener" aria-label="7.56 8 (Ransome) How to Make Windows 10 Secure-pGcerfVqYyU_31 01 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">7.56 8 (Ransome) How to Make Windows 10 Secur...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1b_akgpleMvL4lD4qXYffzUEXh8WhUyZ7/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20 06 2020.wmv"><img src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.45 Speed Up Windows 10 in 2020-8E6OT_QcHaU_20...</span></a><img src="res/6c654bc40d912309e7cc090257628b4f/texteditor/void.gif" alt="" data-upload="true" /></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>
<div class="gmail_chip gmail_drive_chip"><a href="https://drive.google.com/file/d/1O63RdRCQS2OvWa50F56m6KyryVsBImIK/view?usp=drive_web" target="_blank" rel="noopener" aria-label="8.94 Creating New Windows 10 Debloat Scripts fo..."><img src="https://drive-thirdparty.googleusercontent.com/16/type/video/x-ms-wmv" alt="" data-upload="true" />&nbsp;<span dir="ltr">8.94 Creating New Windows 10 Debloat Scripts fo...</span></a></div>
<div class="gmail_chip gmail_drive_chip">&nbsp;</div>

DocAElstein
02-14-2022, 02:10 PM
Test Burgandy

Generic color name: Burgundy
Colors that make up #8C001A
RGB: 140, 0, 26 - HSL: 0.97, 1.00, 0.27

PurplePurple
PurplePurple
MaroonMaroon
MaroonMaroon
BurgundyBurgundy
Windows10Windows10
color:#A82D00 $NFS





<div class=WordSection1>

<p class=MsoNormal><span lang=EN-GB style='font-size:9.0pt;line-height:115%;
font-family:"Lucida Console";mso-bidi-font-family:"Lucida Console";color:#A82D00;
mso-ansi-language:EN-GB;mso-fareast-language:DE'>$NFS</span><span lang=EN-GB
style='font-size:9.0pt;line-height:115%;font-family:"Lucida Console";
mso-bidi-font-family:"Lucida Console";mso-ansi-language:EN-GB;mso-fareast-language:
DE'><span style='mso-spacerun:yes'> </span><span
style='color:dimgray'>=</span> <span style='color:blue'>New-Object</span> <span
class=SpellE><span style='color:blueviolet'>system.Windows.Forms.Button</span></span></span><span
lang=EN-US style='mso-ansi-language:EN-US'><o:p></o:p></span></p>

</div>


'Sub Makro9BBBurgundy() ' ' https://excelfox.com/forum/showthread.php/2417-Test-BB-Code-Highlighting-and-Colors?p=16370#post16370
' With Selection
' .Font.Color = 1704076
' .Text = " " & .Text & " "
' .Collapse Direction:=wdCollapseEnd
' End With
'End Sub
Sub Makro9BBBurgundy() ' Ctrl+Shift+B,G ' https://eileenslounge.com/viewtopic.php?f=26&t=37808&p=292620#p292620
Dim Text1 As String
Dim Text2 As String
Text1 = "C[/B]001A""] "
Text2 = " [/color]"
[color=blueviolet]With Selection
.InsertBefore Text:=Text1
.InsertAfter Text:=Text2
ActiveDocument.Range(Selection.Start, Selection.Start + Len(Text1)).Font.Size = 8
ActiveDocument.Range(Selection.End - Len(Text2), Selection.End).Font.Size = 8
.Font.Color = 1704076
.Collapse Direction:=wdCollapseEnd
End With
End Sub

DocAElstein
02-16-2022, 03:19 AM
Hello Atlantis764
Welcome to ExcelFox

I don’t have any experience with UserForms
and
I don’t really understand the full picture of what you are trying to do.

Here is a screenshot of the file you uploaded: https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16365&viewfull=1#post16365

I can see that there is some correlation in the coloured cells, but all I can understand from your explanation is that you want to match Name and Project and Task as you showed in the workbook

The best I can do is that I can get you started on doing that matching:

We can make an array which has as many elements as there are data rows in Database1
Each element will contain a string made up from each row of the
Name & Project & Task

We can do something similar for worksheet Database

Then you can match the strings in the two arrays.

Run this demo macro and I think you will see what I mean



' https://excelfox.com/forum/showthread.php/2783-User-Form-entry-in-a-second-sheet-need-help-with-VBA-code?p=16371&viewfull=1#post16371
Sub MatchNameProjectTask()
Rem 0 Worksheets info
Dim WsD As Worksheet, WsD1 As Worksheet
Set WsD = ThisWorkbook.Worksheets("Database"): Set WsD1 = ThisWorkbook.Worksheets("Database1")
Dim LrD As Long, LrD1 As Long
Let LrD = WsD.Range("A" & WsD.Rows.Count & "").End(xlUp).Row: Let LrD1 = WsD1.Range("A" & WsD1.Rows.Count & "").End(xlUp).Row
Rem 2 make arrays of concatenated words
'Dim v: v = WsD.Evaluate("=D2:D4&E2:E4&F2:F4"): v = WsD.Evaluate("=D2:D" & LrD & "&E2:E" & LrD & "&F2:F" & LrD & "")
Dim arrD() As Variant: Let arrD() = WsD.Evaluate("=D2:D" & LrD & "&E2:E" & LrD & "&F2:F" & LrD & "")
Dim arrD1() As Variant: Let arrD1() = WsD1.Evaluate("=A2:A" & LrD1 & "&B2:B" & LrD1 & "&C2:C" & LrD1 & "")
Rem 3 compare arrays
Dim rwD As Long, rwD1 As Long
For rwD = 2 To LrD
For rwD1 = 2 To LrD1
If arrD(rwD - 1, 1) = arrD1(rwD1 - 1, 1) Then MsgBox prompt:="match for " & arrD(rwD - 1, 1) & " at Database row " & rwD & " Database1 row " & rwD1

Next rwD1
Next rwD
End Sub


Here's the same basic macro done slightly differently

Sub MatchNameProjectTask2()
Rem 0 Worksheets info
Dim WsD As Worksheet, WsD1 As Worksheet
Set WsD = ThisWorkbook.Worksheets("Database"): Set WsD1 = ThisWorkbook.Worksheets("Database1")
Dim LrD As Long, LrD1 As Long
Let LrD = WsD.Range("A" & WsD.Rows.Count & "").End(xlUp).Row: Let LrD1 = WsD1.Range("A" & WsD1.Rows.Count & "").End(xlUp).Row
Rem 2 make arrays of concatenated words
Dim arrD() As String, arrD1() As String
ReDim arrD(2 To LrD): ReDim arrD1(2 To LrD1)
Dim rwD As Long, rwD1 As Long
For rwD = 2 To LrD
Let arrD(rwD) = WsD.Range("D" & rwD & "") & WsD.Range("E" & rwD & "") & WsD.Range("F" & rwD & "")
Next rwD
For rwD1 = 2 To LrD1
Let arrD1(rwD1) = WsD1.Range("A" & rwD1 & "") & WsD1.Range("B" & rwD1 & "") & WsD1.Range("C" & rwD1 & "")
Next rwD1
Rem 3 compare arrays
For rwD = 2 To LrD
For rwD1 = 2 To LrD1
If arrD(rwD) = arrD1(rwD1) Then MsgBox prompt:="match for " & arrD(rwD) & " at Database row " & rwD & " Database1 row " & rwD1
Next rwD1
Next rwD
End Sub

Alan

DocAElstein
02-16-2022, 03:53 AM
Hi Kris
Just one very minor observation: You will need Excel 2010 or higher because I think .ForeColor.Brightness isn't supported in earlier Excel
3832
(I checked in a few versions of 2010 and higher, and all seems OK)

Alan

DocAElstein
02-16-2022, 04:06 PM
Hi Liviu
It’s possibly difficult for me to understand the full picture as I know nothing about UserForms.
I doubt therefore that I will be able to give you exactly the final coding you need, since I don’t understand the workings of UserForms.
Also, if I click that Form button , then I see this, which is impossible for me to see anything in.
https://i.postimg.cc/8cdDypfn/Click-Form-Button.jpg
3833
( If you have an issue / problem specific to something associated with the UserForm then I can’t help further. If for example, there is a simple typo in Task, or you have task rather than Task, then I can’t see that in that UserForm )


The best I can do therefore is give again some ideas that takes the matching further and goes on to match those date values, and then puts the Amount in the appropriate place in database1
(Basically, what I did for you before is going some way to demo to you coding that does that sort of row matching based on the various criteria of matching headings. So that was just matching the rows, which matched effectively "Name" and "Project" and the "Task).


This next macro is basically the same as my last. But instead of the demo message box, it now adds the "Amount" value to be added to Database1 sheet in the corresponding cell

The way I have done this extra section, is to convert the Year and Month from column B and C in Database, (along with an assumed day of the first of the month) to an Excel date serial number *****
I then compare that with the date serial numbers for the top row of Database1.
A match will then tell me which column to put the Amount in


Sub MatchNameProjectTask3()
Rem 0 Worksheets info
Dim WsD As Worksheet, WsD1 As Worksheet
Set WsD = ThisWorkbook.Worksheets("Database"): Set WsD1 = ThisWorkbook.Worksheets("Database1")
Dim LrD As Long, LrD1 As Long
Let LrD = WsD.Range("A" & WsD.Rows.Count & "").End(xlUp).Row: Let LrD1 = WsD1.Range("A" & WsD1.Rows.Count & "").End(xlUp).Row
Rem 2 make arrays of concatenated words
Dim arrD() As String, arrD1() As String
ReDim arrD(2 To LrD): ReDim arrD1(2 To LrD1)
Dim rwD As Long, rwD1 As Long
For rwD = 2 To LrD
Let arrD(rwD) = WsD.Range("D" & rwD & "") & WsD.Range("E" & rwD & "") & WsD.Range("F" & rwD & "")
Next rwD
For rwD1 = 2 To LrD1
Let arrD1(rwD1) = WsD1.Range("A" & rwD1 & "") & WsD1.Range("B" & rwD1 & "") & WsD1.Range("C" & rwD1 & "")
Next rwD1
'2b) Array of date serials from Database1
Dim arrDtSerials() As Variant, LcD1 As Long
Let LcD1 = WsD1.Cells(1, WsD1.Columns.Count).End(xlToLeft).Column
Let arrDtSerials() = WsD1.Range("A1").Resize(1, LcD1).Value2
Rem 3 compare arrays for headings
For rwD = 2 To LrD
For rwD1 = 2 To LrD1
If arrD(rwD) = arrD1(rwD1) Then ' MsgBox prompt:="match for " & arrD(rwD) & " at Database row " & rwD & " Database1 row " & rwD1
'3b We have a heading match , so now match the date
Dim DteSerial As Variant
' Let DteSerial = WsD.Evaluate("=DATEVALUE(""1 " & WsD.Range("C2").Value & " " & WsD.Range("B2").Value & """)")
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1 " & WsD.Range("C" & rwD & "").Value & " " & WsD.Range("B" & rwD & "").Value & """)")
Dim MtchRes As Variant
Let MtchRes = Application.match(DteSerial, arrDtSerials(), 0)
If IsError(MtchRes) Then MsgBox prompt:="No date match": Exit Sub
Let WsD1.Cells(rwD1, MtchRes) = WsD.Range("G" & rwD & "").Value
Else

End If
Next rwD1
Next rwD
End Sub




So this would be the Before, as we had before: https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16377&viewfull=1#post16377

Then, after running that macro, this would be the After https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16378&viewfull=1#post16378


Alan



*****Unfortunately dates in Excel and VBA are a real pain in the arse, since different excel versions and land versions and user setting all give different results, so you may need to tweak some of the coding that gets the date match. There is no known way around these problems. It makes sharing files to different people with dates in them sometimes impossible.
The macro is working in my Excel
Its based on this bit working to give me the correct date serial number from worksheet Database



Sub Dts()
Rem 0 Worksheets info
Dim WsD As Worksheet
Set WsD = ThisWorkbook.Worksheets("Database")
Dim DteSerial As Variant
Let DteSerial = Evaluate("=DATEVALUE(""1-January-2022"")") ' 44562 : Variant/Double
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1-"" & ""January"" & ""-2022"")") ' 44562 : Variant/Double
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1-" & WsD.Range("C2").Value & "-2022"")") ' 44562 : Variant/Double
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1-" & WsD.Range("C2").Value & "-2022"")") ' 44562 : Variant/Double
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1-" & WsD.Range("C2").Value & "-" & WsD.Range("B2").Value & """)") ' 44562 : Variant/Double
Let DteSerial = WsD.Evaluate("=DATEVALUE(""1 " & WsD.Range("C2").Value & " " & WsD.Range("B2").Value & """)") ' 44562 : Variant/Double



End Sub



Ref http://www.eileenslounge.com/viewtopic.php?p=290229#p290229
https://excelfox.com/forum/showthread.php/2772-Some-Date-Notes-and-Tests

DocAElstein
02-16-2022, 10:02 PM
Hi
I can’t help directly as I have little experience with Microsoft Word.
We do not have many Word VBA experts looking in to excelfox

However, I can tell you that the Author of that code, HansV, is quite active posting at Eileen’s Lounge, https://eileenslounge.com/app.php/portal

Here is the link to the Word Sub Forum there:
https://eileenslounge.com/viewforum.php?f=26

You may be able to get help from that forum, if you join and post your question there
If you decide to ask for help there, then I would suggest that you prepare and upload a Word File document example, and explain clearly exactly what you want the coding to do.

( Remember to tell them that you have also posted here:
You must tell them, that you have also posted the same question at excelfox: Give them this link to your post here:
https://excelfox.com/forum/showthread.php/2786-VBA-Copy-Tables-from-Word-to-Excel )



Alan

DocAElstein
02-18-2022, 02:22 PM
Hi
I am not sure what hte problem is with the download for you. Once in a while something wont download on a particular operating system or Browser. We never figured out why yet.
I just put it in a share place for you, perhaps that will work for you
Share ‘Work_file.xlsm’ https://app.box.com/s/v9ifgeicp6nzha0axcha3qcprzgprgob

It's difficult for me to help further beacuse
_1 I can't see anything on the userform - as i showed in the screen shot the text and numbers are too small to see,
_ 2 I still really don't know what should happen.I don't understand what you want, where data comes from etc. etc... - You have given a pefectly good explanation for yourself or anyone else maybe who knows already the sort of thing that you are doing.
But you are talking to a complee stranger that knows VBA quite well but has no idea of your work. (and hasn't done much with userforms either - I do understand the very basics of them). I expect it would take me 10 seconds to sort your problem out , but a day first before I figured out what it is that should happen.
You will always improve your chances of an answer here, or elsewhere, if you give a very detailed walkthrough of what should happen , giving sample data and saying exactly what steps you do, where the data is coming from etc. etc
I feel your pain. You have an annoying problem and want the answer quick. Sometimes you strike lucky, and find someone that has done almost excactly what you are doing and sees at a glance what the problem is.
I hav'nt, so I can't

Alan

DocAElstein
02-18-2022, 05:13 PM
Hi
OK, that’s all a bit clearer for me, thanks.
I probably could have a go… But …

I am still having problems doing anything with your UserForm.
I tried on three different computers, with Excel versions 2007, 2010 and 2013(professional)

So, I press the Form Button

This happens:
Excel 2007 text is too small to do anything with, as before ( that I did before was on another computer which also had Excel 2007 )
https://i.postimg.cc/wtxp8cXt/Click-Form-Button-2007.jpg (https://postimg.cc/wtxp8cXt)


Excel 2010 error
https://i.postimg.cc/w1QpGbm8/Error-opening-form-2010.jpg (https://postimg.cc/w1QpGbm8)

Excel 2013 ( Professional ) error
https://i.postimg.cc/t1rHXZkB/Error-opening-form-2013.jpg (https://postimg.cc/t1rHXZkB)


Translating those error texts in the last two screenshots to English – it says something about not being able to set ColumnWidth property due to type mismatch




If nobody else helps you in the meantime, I will try and take a look again later today when I have more time. I might be able to do something in Excel 2007, but its going to be very difficult for me to try and add data in the UserForm as I can barely see anything.

Its very strange that I get those errors in newer Excel versions. Also the small size I see, could suggest, along with the errors in newer versions, that something is dodgy with your userform


What Excel version are you using?


Perhaps in the meantime you could take a look and see if you can do something with the UserForm. Maybe make something bigger , at least just temporarily. Maybe if you make the Form and / or the text bigger and upload some other files with a modified UserForm size in, then I might have a better chance of seeing something in it.
And/ or see if you can figure out why I can't get the UserForm to come up in some of my Excels.
As I mentined, I do not have much experience with UserForms, but I have made a few. So far, when they work, they work in all my Excel versions. So I think there is at least a chance that something is a bit wonky in your UserForm, something that just by chance allows it work, all be it with very small text, in Excel 2007.
Could be a totally other explanation. I am just geussing due to my lack of a lot of experience with UserForms

I will try and look again today. It might have to wait until tomorrow.
Please if you get it fixed in the meantime, let me know, so I don’t waste my time.

Thanks
Alan

DocAElstein
02-18-2022, 11:49 PM
Hi Liviu

OK, I done it for you. ( It was not really solving a problem in your coding. There was no coding anywhere that made any attempt to put data into worksheet Database1 )
I have basically added / incorporated coding of the form I had in Sub MatchNameProjectTask3() into your macro to do the extra filling of Database1
So your initial explanation in post #1 was a bit misleading.
No matter
Here is the solution(s)


Some minor issues first
_ The userFormtext size is very good now. But the Form size was a bit big and bloated. But I fiddled around a bit (blindly) in the UserForm properties and in Private Sub UserForm_Initialize(). So that’s good enough for me to work with
_ I figured out that strange error as well in the .ColumnWidths : I am mostly using German Excel and my list separator is sometimes taken as ; rather than a ,
I did a quick bodge to get over that, but you might want to put that back to as you had it.

' Quick dodge to get over problem of different seperators in different land Office versions
On Error Resume Next
.LstDatabase.ColumnWidths = "40;50;60;60;60;60;60;30"
.LstDatabase.ColumnWidths = "40,50,60,60,60,60,60,30"
On Error GoTo 0
If iRow > 1 Then
It is usually better to do this sort of thing withput error handling, but I did not know how to easilly determine the seperator used by any Excel. I might be able later to do something along the lines that I did here: https://eileenslounge.com/viewtopic.php?p=290229#p290229 https://eileenslounge.com/viewtopic.php?p=267466#p267466
Possibly someone else passing this Thread knows of a simpler way.? I wpuld be very intersted and grateful of any imput


So on now to the main stuff…

This is approximately the macro you uploaded which need the additions

Dim sh As Worksheet
Dim sh1 As Worksheet
Dim iRow As Long, colno As Integer, iCol As Long, rowno As Integer
Dim iRow1 As Long, colno1 As Integer, iCol1 As Integer, reqdRow As Integer
Set sh = ThisWorkbook.Sheets("Database")
Set sh1 = ThisWorkbook.Sheets("Database1")
iRow = [Counta(Database!A:A)] + 1
iCol = Sheets("Database").Cells(1, Columns.Count).End(xlToLeft).Column - 1
iRow1 = [Counta(Database1!A:A)] + 1
iCol1 = Sheets("Database1").Cells(1, Columns.Count).End(xlToLeft).Column - 1
With sh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = UserFormTest.CmbYear.Value
.Cells(iRow, 3) = UserFormTest.CmbMonth.Value
.Cells(iRow, 4) = UserFormTest.CmbName.Value
.Cells(iRow, 5) = UserFormTest.CmbProject.Value
.Cells(iRow, 6) = UserFormTest.CmbTask.Value
.Cells(iRow, 7) = UserFormTest.TxtAmount.Value
.Cells(iRow, 8) = Application.UserName
End With
Call Reset
MsgBox "Date incarcate cu succes!"
End Sub




This next is that macro with the addition. The additions are based on my last macro Sub MatchNameProjectTask3()


Sub Submit_Data()
Dim Wsh As Worksheet
Dim Wsh1 As Worksheet
Dim iRow As Long, colno As Integer, iCol As Long, rowno As Integer
Dim iRow1 As Long, colno1 As Integer, iCol1 As Integer, reqdRow As Integer
Set Wsh = ThisWorkbook.Sheets("Database"): Wsh.Select
Set Wsh1 = ThisWorkbook.Sheets("Database1")
iRow = [Counta(Database!A:A)] + 1
'Dim LrD As Long: Let LrD = iRow - 1
iCol = Sheets("Database").Cells(1, Columns.Count).End(xlToLeft).Column - 1
iRow1 = [Counta(Database1!A:A)] + 1
iCol1 = Sheets("Database1").Cells(1, Columns.Count).End(xlToLeft).Column - 1
With Wsh
.Cells(iRow, 1) = iRow - 1
.Cells(iRow, 2) = UserFormTest.CmbYear.Value ' Year
.Cells(iRow, 3) = UserFormTest.CmbMonth.Value ' Month
.Cells(iRow, 4) = UserFormTest.CmbName.Value ' Name
.Cells(iRow, 5) = UserFormTest.CmbProject.Value ' Project
.Cells(iRow, 6) = UserFormTest.CmbTask.Value ' Task
.Cells(iRow, 7) = UserFormTest.TxtAmount.Value ' Amount
.Cells(iRow, 8) = Application.UserName ' Submit
End With
' the bit to put Amount on Database1
Rem 2a match Name and Project and Task
With UserFormTest
Dim Kee As String: Let Kee = .CmbName.Value & .CmbProject.Value & .CmbTask.Value
End With
Dim LrD1 As Long: Let LrD1 = Wsh1.Range("A" & Wsh1.Rows.Count & "").End(xlUp).Row
Dim arrD1() As String: ReDim arrD1(2 To LrD1)
Dim rwD1 As Long
For rwD1 = 2 To LrD1
Let arrD1(rwD1) = Wsh1.Range("A" & rwD1 & "") & Wsh1.Range("B" & rwD1 & "") & Wsh1.Range("C" & rwD1 & "")
Next rwD1
'2b) Array of date serials from Database1
Dim arrDtSerials() As Variant, LcD1 As Long
Let LcD1 = Wsh1.Cells(1, Wsh1.Columns.Count).End(xlToLeft).Column
Let arrDtSerials() = Wsh1.Range("A1").Resize(1, LcD1).Value2
Rem 3 compare arrays for headings
For rwD1 = 2 To LrD1
If Kee = arrD1(rwD1) Then ' MsgBox prompt:="match for " & Kee & " at Database1 row " & rwD1
'3b We have a heading match , so now match the date
Dim DteSerial As Variant
' Let DteSerial = WsD.Evaluate("=DATEVALUE(""1 " & WsD.Range("C2").Value & " " & WsD.Range("B2").Value & """)")
' Let DteSerial = Wsh.Evaluate("=DATEVALUE(""1 " & Wsh.Range("C" & rwD & "").Value & " " & WsD.Range("B" & rwD & "").Value & """)")
Let DteSerial = Wsh.Evaluate("=DATEVALUE(""1 " & Wsh.Range("C" & iRow & "").Value & " " & Wsh.Range("B" & iRow & "").Value & """)")
Dim MtchRes As Variant
Let MtchRes = Application.match(DteSerial, arrDtSerials(), 0)
If IsError(MtchRes) Then MsgBox prompt:="No date match": Exit Sub
'Let Wsh1.Cells(rwD1, MtchRes) = WsD.Range("G" & rwD & "").Value
Wsh1.Activate
Let Wsh1.Cells(rwD1, MtchRes) = Wsh.Range("G" & iRow & "").Value
Else

End If
Next rwD1
Call Reset
MsgBox "Date incarcate cu succes!"
End Sub




The uploaded file, Work_file_modifiedBefore.xlsm is approximately your original uploaded (modified ) file.
, and Work_file_modifiedAfter.xlsm, is that same file with the modified macro


If anything is not quite right, then let me know and I will take another look. but you will have to wait a few days

Alan





Files at share site, incase you can’t get them from the upload again:
Share ‘Work_file_modifiedBefore.xlsm’ https://app.box.com/s/szruzgnhmccgwm3v9o8iafz9s29p182a
Share ‘Work_file_modifiedAfter.xlsm’ https://app.box.com/s/wigzth8u6khlwpqmtqj5eb1u6gqpwc2z

DocAElstein
02-19-2022, 03:52 PM
Your welcome, thanks for the feedback
It is always very difficult to explain to someone else in enough detail for them to understand. It is also very difficult if you do not speak the English language.
But a good detailed walkthrough explanation will always make it easier for you to get help.

Alan


( P.S. Another thing that may help you get help in the future:
It is some times courteous to tell the people at mrexcel.com (https://www.mrexcel.com/board/threads/user-form-entry-in-a-second-sheet-need-help-with-vba-code.1196175/#post-5835818) that you have a solution, and tell them where you got it. That would help anyone seeing that Thread in the future at mrexcel.com (https://www.mrexcel.com/board/threads/user-form-entry-in-a-second-sheet-need-help-with-vba-code.1196175/#post-5835818) that is looking for a similar solution.
Being courteous like that may also help you to get help from mrexcel.com in the future.
But that is not too important)

DocAElstein
02-28-2022, 06:49 PM
Hello Amelynn
Welcome to ExcelFox , the thinking man’s Excel forum :)


Who can help me, ....I think, therefore I am , and able to help you.


...... I don't understand how the line ".List
= Application.Index(rng, Evaluate("ROW(1:" & rng.Rows.Count & ")"), Array(1, 3))
" works and I can't stay So....

To Explain

Question: _(i) What is Array(1, 3) ?
Answer_ It is like –
___1 _3
( Sometime we write in excel spreadsheet convention {1, 3} , but this usually means the same thing )

Question: _(ii)a) Evaluate("ROW(1:" & rng.Rows.Count & ")")
Answer:
..... evaluate (…….. used to occupy excel formulas in vba) with row,
Correct! Good! - Because you understand this, it makes the explanation for me much easier.
We are really only interested in understanding what is , =ROW(1:" & rng.Rows.Count & ")" , in excel spreadsheet formula

Question: _(ii)b) What is =ROW(1:" & rng.Rows.Count & ") ? ( in excel spreadsheet )
For your range, rng = B4:D8 , rng.Rows.Count = 5
=ROW(1: " & rng.Rows.Count & " )
=ROW(1: " & 5 & " )
=ROW(1:5)

( Green is Excel Spreadsheet, Blue is VBA in string “ “ in Evaluate( “ “ ) )

The excel spreadsheet Row( ) function is usually like for
Row( A1) = 1
but can also return a “vertical” array of values like
Row( A1:A2) = 1
Row( A1:A2) = 2
Inside VBA Evaluate “ _ “ we find that we are decoupled from spreadsheet absolute values, and so in inside VBA Evaluate “ _ “
Row(A1:A2) = Row( 1:2) = 1
Row(A1:A2) = Row( 1:2) = 2

ROW(1:5)
It is like
1
2
3
4
5
( Sometimes we may write
{1
2
3
4
5}
or sometimes we may write in excel spreadsheet convention , ={1;2;3;4;5} , but usually this means the same thing)
Note: For “vertical” array some excel use ; but some Excel use \ – So sometime you may need ={1\2\3\4\5}



Sometimes if we are lucky, Excel will try to do array calculations and return you an array.
Like

{ 1 2 X { 6 8 = { 1, 6 2, 8
3 4 } 7 9 } 3, 7 4, 9 }

But if you ask it to do = Index ___ , ROW(1:5)_ ,_ Array{1 , 3} it tries to look at columns and rows not specified.
This should not work


= { 1 ? { 1 3
2 ? ? ?
3 ? X ? ?
4 ? ? ?
5 ? } ? ? }

???? So we have a problem ?,
But we can be lucky again, because then Excel will guess to see the following instead, ( actually its more complicated then that, more precisely it is due to Excel VBA Interception and Implicit Intersection (http://www.excelfox.com/forum/showthread.php/2145-Excel-VBA-Interception-and-Implicit-Intersection-and-VLookUp) , but we often say that Excel guesses things, as its often written to get things correct when you miss things out. ( In this particular case it is not clear if the phenomenum occurs by accident or design ) )


= { 1 1 { 1 3
2 2 1 3
3 3 X 1 3
4 4 1 3
5 5 } 1 3 }
( What is actually happening there above in those last two sketches is: -
If Excel is given a single row or a single column, but is being required to look at values of further adjoining rows and columns where no values are given, then the effect of the phenomena of Excel VBA Interception and Implicit Intersection (http://www.excelfox.com/forum/showthread.php/2145-Excel-VBA-Interception-and-Implicit-Intersection-and-VLookUp) is that in certain situation the missing values will effectively be taken as a duplication of the values in the given row or column )

So, Index will try to give us


_______ Index( ( , 1, 1 1, 3
2, 1 2, 3
3, 1 3, 3
4, 1 4, 3
5, 1 5, 3 )


So if your range is, rng = B4:D8
-__=
_B4 _C4 _D4
_B5 _C5 _D5
_B6 _C6 _D6
_B7 _C7 _D7
_B8 _C8 _D8

then Application.Index(rng, Evaluate("=ROW(1:" & rng.Rows.Count & ")"), Array(1, 3))
-__ =Application.Index(rng, Evaluate("=ROW(1:5)"), Array(1, 3))
-__ =Application.Index(rng, Evaluate("={1;2;3;4;5}"), Array(1, 3))
-__ =Application.Index(rng, Evaluate("={1;2;3;4;5}"), Evaluate("={1, 3}"))
-__ =
rng , 1,1 1,3
2,1 2,3
3,1 3,3
4,1 4,3
5,1 5,3
-__=
_B4 _C4 _D4 1,1 1,3
_B5 _C5 _D5 2,1 2,3
_B6 _C6 _D6 3,1 3,3
_B7 _C7 _D7 4,1 4,3
_B8 _C8 _D8 5,1 5,3

= _B4 _D4
_B5 _D5
_B6 _D6
_B7 _D7
_B8 _D8




........use an array to determine the rows as well......
Sure, this is no problem:
One way, for example, for just 1st 3rd and 5th row
Change
Evaluate("={1;2;3;4;5}")
to
Evaluate("={1;3;5}")

-__ =Application.Index(rng, Evaluate("={1;3;5}"), Array(1, 3))
-__ =Application.Index(rng, Evaluate("={1;3;5}"), Evaluate("={1, 3}"))

_B4 _C4 _D4 1,1 1,3
_B5 _C5 _D5 3,1 3,3
_B6 _C6 _D6 5,1 5,3
_B7 _C7 _D7
_B8 _C8 _D8

= _B4 _D4
_B6 _D6
_B8 _D8



Here a demo macro for you
Put some arbitrary values in your range "B4:D8" , then run this macro:

Sub Test()
Dim Rng As Range
Set Rng = Worksheets("Sheet1").Range("B4:D8")
Dim RwsCnt As Long
Let RwsCnt = Rng.Rows.Count ' is = 5

Dim arr_List() As Variant
Let arr_List() = Application.Index(Rng, Evaluate("=ROW(1:" & Rng.Rows.Count & ")"), Array(1, 3))
Let arr_List() = Application.Index(Rng, Evaluate("=ROW(1:" & RwsCnt & ")"), Array(1, 3))
Let arr_List() = Application.Index(Rng, Evaluate("=ROW(1:5)"), Array(1, 3))
Let arr_List() = Application.Index(Rng, Evaluate("={1;2;3;4;5}"), Array(1, 3))
Let arr_List() = Application.Index(Rng, Evaluate("={1;2;3;4;5}"), Evaluate("={1,3}"))

Let Worksheets("Sheet1").Range("A40").Resize(UBound(arr_List(), 1), UBound(arr_List(), 2)).Value = arr_List()

' To only select 1st 3rd and 5th row
Let arr_List() = Application.Index(Rng, Evaluate("={1;3;5}"), Evaluate("={1,3}"))
Let Worksheets("Sheet1").Range("A47").Resize(UBound(arr_List(), 1), UBound(arr_List(), 2)).Value = arr_List()

End Sub



Alan

DocAElstein
03-01-2022, 12:10 AM
URL links to here: This is post: https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping?p=16456&viewfull=1#post16456
https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping?p=16456&viewfull=1#post16456
https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping
https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping
https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping#post1
https://excelfox.com/forum/showthread.php/2789-Item-way-of-thinking-as-alternative-to-conventional-row-column-looping#post1




Item way of thinking as alternative to conventional row column looping

Current conventional way of thinking
This Blog post assumes that you have some basic Excel VBA programming experience, and that you are familiar with this general idea used typically when filling or getting data from cells
__For Rw = 1 To maximumRows
____For Clm = 1 To maximumColumns
_____( Rw, Clm )
____Next Clm
__ Next Rw
This basic process you should make sure you fully understand before reading further.
This Blog post suggest a slightly different way about thinking about that process

Introduction
Excel Spreadsheets can be turned into pretty pictures, computer graphics and games and “dashboards”.
But they are usually not the best at doing those things.
They are best for doing things with 2 dimensional “tables” of data.
They bridge the gap between
_ dead stores of data or long fast streams of string data,
and
_ relatively slow and static living humans interacting with them

I expect we are not a long way from interacting in a 3 dimensional way, but it will settle down, I think, to be useful in a limited way. More than 3 dimensions are difficult for humans to react easily with.
A 2 dimensional desktop is particularly convenient for us.
Smartphones are a trend that I think might go back a bit to being just glorified telephones, walkmans, live cameras and simple computer games.

We are basically talking in this Thread about organising a string of data travelling at the speed of light into a static line or row of the data, then carrying the rest of the data back, feeding in another row or line or “going down”, then doing the same again.

I think for Excel formulas and VBA we should not take the core of the thinking much further than this.
For furthering the study and manipulation of static table data something else , another concept, such as Power Query / Get and Transform (https://excelfox.com/forum/forumdisplay.php/30-ETL-PQ-Tips-and-Tricks) might be more appropriate.

Looping along columns for every row The conventional way
__For Rw = 1 To maximumRows
____For Clm = 1 To maximumColumns
_____( Rw, Clm )
____Next Clm
__ Next Rw
This is what we have got used to, from reading books, to the workings of old printers, to how a screen is filed with data. It is an efficient and logical consequence that a spreadsheet, or a rectangular range in a spreadsheet, is filled and otherwise updated in the same way.
Usually we look at a cell when doing formula calculations, but if we increase the exposed area during a screen update, we can get an efficient, almost simultaneous, calculation across an entire range. This latter is the basis of the workings of the so called array formulas, ( “CSE” stuff ). We will come on to that in the next post

Looping the Items
Many things in VBA, and computers generally, are actually ordered somewhere by something similar to a unique item number , 1 2 3 4 5 6 … etc. ( Note: in some computer conventions the first may start at 0 so we have 0 1 2 3 4 5… etc. )
Conventionally, the Range Item numbers are also so organised, and further follow the generally accepted convention of
Across
_____down
back
Across
_____down
back
………etc.

( Conventionally in computer stream strings we may refer to those
backs as carriage returns, vbCr ,
and
the downs as line feeds, vbLf.
These may be referred to as “invisible characters”, as we do not typically see them, but they must be there in the electronic string stream to indicate the start of a new line or new row )

For example for a 2 row x 3 column range, this is where the item numbers are/ what cells the item number refers to
1 2 3 vbCr & vbLf
4 5 6
Furthermore, for many things that do not have such an item number they may have a consistent order such that we can assume or assign some simple count mechanism to give them an index that we can use in a similar way to the Item number

The crux of my suggestion in this Thread is to think of the basic process shown at the start of this Blog, in a slightly different way.
A couple of reasons I can think of for doing this
_ It may be helpful to think back to the more fundamental single string idea of what computers are, as the table type arrangement is only an interface for us, and is less representative of what is actually going on in a computer
_ In some situations the alternative looping may have some advantages. For example we would not be limited to a rectangular range.

Some simple required maths
What we want to do is this sort of thing as an alternative to the basic process
__For Itm = 1 To maximumItems
___( Row, Column)
__Next Itm
Before looking at the actual solution, lets simply put in words a simple solution idea, and consider again a 2 row, 3 column range
1 2 3
4 5 6
In this case, our maximumRows will be 2 and the maximumColumns will be 3
We have those sequentially numbers, and we want to convert then to row and column indices that would give us that spreadsheet range.

Row Number from Item Number
If we were to divide the actual item number by the maximumColumns , 3 , and take the integer of the result we would almost be there. But that would actually give us
0 0 1
1 1 2
If we were to first subtract 1 from the Item number, then do the same again, divide that modified number by the maximumColumns , 3, and take the integer of the result we would have,
Integer ( ( ItmNumber -1 ) / maximumColumns ) =
0 0 0
1 1 1
So we now see that we only have to add 1 to the final results and we have the row number what we want.
RowNumber = [ Integer ( ( ItmNumber -1 ) / maximumColumns ) ] + 1
1 1 1
2 2 2

Column Number from Item Number
This is slightly more tricky. But not much. I do this second as we need some of the ideas from the previous maths.
An observation:
To get the column number from the item number, the second row needs to be reduce by 1 x maximumColumns , and
if we had a third row the item number would need to be reduced by 2 x maximumColumns … and so on.
Note also, that it also fits this same logic to apply a reduction of 0 x maximumColumns to the first row.
So we are looking for a multiplication factor based on the Item number which gives us that sort of number sequence like 0 0 0 ; 1 1 1 ; 2 2 2 etc. sequence
We can see from one of the stages in the maths from the last section where we determined the row from the item number, that we did actually already have it:
It was at this stage: -
__________________Integer ( ( ItmNumber -1 ) / maximumColumns )
___=___0 0 0
_______1 1 1
and that would have further gone on for more rows to
0 0 0 ; 1 1 1 ; 2 2 2 ; 3 3 3 … etc.

So we can see one formula possibility:
ItemNumber - [ Integer ( ( ItmNumber -1 ) / maximumColumns ) X maximumColumns ]
This would result in our required column Indicies of
1 2 3
1 2 3

_.______

Simple VBA macro examples

Sub ItmNumbersLoopToRng()
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim ItmIndx As Long
Dim maxClms As Long, maxRws As Long: Let maxClms = 3: Let maxRws = 2
For ItmIndx = 1 To 5
Dim Rw As Long, Clm As Long
Let Rw = Int((ItmIndx - 1) / maxClms) + 1
Let Clm = ItmIndx - (Int((ItmIndx - 1) / maxClms) * maxClms)
Let Ws1.Cells.Item(Rw, Clm).Value = " (" & Rw & ", " & Clm & ")"
Next ItmIndx
End Sub

Sub ItmNumbersLoopToRng2()
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim ItmIndx As Long
Dim maxClms As Long, maxRws As Long: Let maxClms = 3: Let maxRws = 2
For ItmIndx = 1 To 5
' Dim Rw As Long, Clm As Long
' Let Rw = Int((ItmIndx - 1) / maxClms) + 1
' Let Clm = ItmIndx - (Int((ItmIndx - 1) / maxClms) * maxClms)
Let Ws1.Cells.Item(Int((ItmIndx - 1) / maxClms) + 1, ItmIndx - (Int((ItmIndx - 1) / maxClms) * maxClms)).Value = " (" & Int((ItmIndx - 1) / maxClms) + 1 & ", " & ItmIndx - (Int((ItmIndx - 1) / maxClms) * maxClms) & ")"
Next ItmIndx
End Sub


__Result:_____
_____ Workbook: OekyDoekyAmelynn.xls ( Using Excel 2007 32 bit )
Row\Col
A
B
C
D

1 (1, 1) (1, 2) (1, 3)


2 (2, 1) (2, 2)


3
Worksheet: Sheet1
_.____

DocAElstein
03-03-2022, 04:36 PM
There is one interesting observation already that may help us understand some of the secret workings of Excel:
Note that we have not needed to use the parameter of maximumRows
Now, Consider a range object of 3 columns x 2 rows anywhere in a spreadsheet
x x x vbCr & vbLf
x x x
Reasonably we would say that has 6 items, and conventionally we have, and we could confirm by experiment, that we have item 6 as shown here, X:
x x x vbCr & vbLf
x x X
What is somewhat surprising perhaps, is that we can go on to reference any further item without causing any errors, and we remain in the maximum columns restriction but seem to have no limit, ( within reason ), in the rows.
For example, referring to item 12, would get us here X:
x x x vbCr & vbLf
x x x vbCr & vbLf
x x x vbCr & vbLf
x x X

This could be by design, or might just be an accident due to some internal calculations having a similar form to those I have suggested and discussed, - those that do not have any consideration of maximum row



I intend adding some further post on this thread later to discuss the ideas and develop them further.

DocAElstein
03-28-2022, 04:13 PM
In support of these issues
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12784 https://www.youtube.com/watch?v=dKM8ZScbic8&t=75s
Winget issues https://github.com/ChrisTitusTech/win10script/commit/f2774eac480a71e710f90763ea770ae56d3b6e85
https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db

06.07.2021 The Best Windows Utility ( second nice shade of grey GUI )

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Github release
Write-Host "winget is not found, installing it right now."

$download = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle"
$output = $PSScriptRoot + "\winget-latest.appxbundle"
Write-Host "Dowloading latest release"
Invoke-WebRequest -Uri $download -OutFile $output

Write-Host "Installing the package"
Add-AppxPackage -Path $output
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}




The Ultimate Windows Utility Upgrade 29 09 2021

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Microsoft Store
Write-Host "winget is not found, installing it right now."

Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).id
Wait-Process -Id $nid

}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}

A commit a bit later by mrhaydendp to simplify a bit https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db?diff=spli t

Write-Host "Checking winget..."

# Check if winget is installed
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
}

DocAElstein
03-28-2022, 04:13 PM
In support of these issues
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12784 https://www.youtube.com/watch?v=dKM8ZScbic8&t=75s
Winget issues https://github.com/ChrisTitusTech/win10script/commit/f2774eac480a71e710f90763ea770ae56d3b6e85
https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db

06.07.2021 The Best Windows Utility ( second nice shade of grey GUI )

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Github release
Write-Host "winget is not found, installing it right now."

$download = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle"
$output = $PSScriptRoot + "\winget-latest.appxbundle"
Write-Host "Dowloading latest release"
Invoke-WebRequest -Uri $download -OutFile $output

Write-Host "Installing the package"
Add-AppxPackage -Path $output
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}




The Ultimate Windows Utility Upgrade 29 09 2021

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Microsoft Store
Write-Host "winget is not found, installing it right now."

Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).id
Wait-Process -Id $nid

}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}

A commit a bit later by mrhaydendp to simplify a bit https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db?diff=spli t

Write-Host "Checking winget..."

# Check if winget is installed
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
}

DocAElstein
03-28-2022, 04:13 PM
In support of these issues
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12784 https://www.youtube.com/watch?v=dKM8ZScbic8&t=75s
Winget issues https://github.com/ChrisTitusTech/win10script/commit/f2774eac480a71e710f90763ea770ae56d3b6e85
https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db

06.07.2021 The Best Windows Utility ( second nice shade of grey GUI )

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Github release
Write-Host "winget is not found, installing it right now."

$download = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle"
$output = $PSScriptRoot + "\winget-latest.appxbundle"
Write-Host "Dowloading latest release"
Invoke-WebRequest -Uri $download -OutFile $output

Write-Host "Installing the package"
Add-AppxPackage -Path $output
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}




The Ultimate Windows Utility Upgrade 29 09 2021

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Microsoft Store
Write-Host "winget is not found, installing it right now."

Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).id
Wait-Process -Id $nid

}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}

A commit a bit later by mrhaydendp to simplify a bit https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db?diff=spli t

Write-Host "Checking winget..."

# Check if winget is installed
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
}

DocAElstein
03-28-2022, 04:13 PM
In support of these issues
https://excelfox.com/forum/showthread.php/2408-Windows-10-and-Office-Excel/page51#post12784 https://www.youtube.com/watch?v=dKM8ZScbic8&t=75s
Winget issues https://github.com/ChrisTitusTech/win10script/commit/f2774eac480a71e710f90763ea770ae56d3b6e85
https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db

06.07.2021 The Best Windows Utility ( second nice shade of grey GUI )

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Github release
Write-Host "winget is not found, installing it right now."

$download = "https://github.com/microsoft/winget-cli/releases/download/v1.0.11692/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbu ndle"
$output = $PSScriptRoot + "\winget-latest.appxbundle"
Write-Host "Dowloading latest release"
Invoke-WebRequest -Uri $download -OutFile $output

Write-Host "Installing the package"
Add-AppxPackage -Path $output
}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}




The Ultimate Windows Utility Upgrade 29 09 2021

Write-Host "Checking winget..."

Try{
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) {throw $er}
Write-Host "winget is already installed."
}
Catch{
# winget is not installed. Install it from the Microsoft Store
Write-Host "winget is not found, installing it right now."

Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).id
Wait-Process -Id $nid

}
Finally {
# Start installing the packages with winget
#Get-Content .\winget.txt | ForEach-Object {
# iex ("winget install -e " + $_)
#}
}

A commit a bit later by mrhaydendp to simplify a bit https://github.com/ChrisTitusTech/win10script/commit/9c0cc78e2a15aed3d42fa1a0b3b236f3ecf290db?diff=spli t

Write-Host "Checking winget..."

# Check if winget is installed
if (Test-Path ~\AppData\Local\Microsoft\WindowsApps\winget.exe){
'Winget Already Installed'
}
else{
# Installing winget from the Microsoft Store
Write-Host "Winget not found, installing it now."
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
$nid = (Get-Process AppInstaller).Id
Wait-Process -Id $nid
Write-Host Winget Installed
}

DocAElstein
04-16-2022, 10:23 PM
Test



17-121-114-118.applebot.apple.com





header1header2A Header Last Column Header


0SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36





header1header2A Header Last Column Header


0SubItemSubItemSubItem<-- This brown thing is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItem<-- This blue thing is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItem<-- This purple thing is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36



[size=0]
header1header2A Header Last Header<-- This bit with the created “column” is part of the main ListView object


0\ 345 SubItemSubItemSubItem<-- This brown thing is a ListViewItem object. It has an Item number of 0,
and an Item identifier/name of 345


1\ 232 SubItemSubItemSubItem<-- This blue thing is a ListViewItem object. It has an Item number of 1,
and an Item identifier/name of 232


2\ 36 SubItemSubItemSubItem<-- This purple thing is a ListViewItem object. It has an Item number of 2
and an Item identifier/name of 36
__
In the above schematic we are showing 4 objects. The last three belong to the first one, ( after they have been ned to it ).
The values in the first column somehow belong to the main ListView object.
SubItems are Added to the ListViewItems

DocAElstein
04-16-2022, 10:23 PM
Test



17-121-114-118.applebot.apple.com





header1header2A Header Last Column Header


0SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36





header1header2A Header Last Column Header


0SubItemSubItemSubItem<-- This brown thing is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItem<-- This blue thing is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItem<-- This purple thing is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36



[size=0]
header1header2A Header Last Header<-- This bit with the created “column” is part of the main ListView object


0\ 345 SubItemSubItemSubItem<-- This brown thing is a ListViewItem object. It has an Item number of 0,
and an Item identifier/name of 345


1\ 232 SubItemSubItemSubItem<-- This blue thing is a ListViewItem object. It has an Item number of 1,
and an Item identifier/name of 232


2\ 36 SubItemSubItemSubItem<-- This purple thing is a ListViewItem object. It has an Item number of 2
and an Item identifier/name of 36
__
In the above schematic we are showing 4 objects. The last three belong to the first one, ( after they have been ned to it ).
The values in the first column somehow belong to the main ListView object.
SubItems are Added to the ListViewItems

DocAElstein
04-16-2022, 10:23 PM
Test



17-121-114-118.applebot.apple.com





header1header2A Header Last Column Header


0SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36





header1header2A Header Last Column Header


0SubItemSubItemSubItem<-- This brown thing is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItem<-- This blue thing is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItem<-- This purple thing is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36



[size=0]
header1header2A Header Last Header<-- This bit with the created “column” is part of the main ListView object


0\ 345 SubItemSubItemSubItem<-- This brown thing is a ListViewItem object. It has an Item number of 0,
and an Item identifier/name of 345


1\ 232 SubItemSubItemSubItem<-- This blue thing is a ListViewItem object. It has an Item number of 1,
and an Item identifier/name of 232


2\ 36 SubItemSubItemSubItem<-- This purple thing is a ListViewItem object. It has an Item number of 2
and an Item identifier/name of 36
__
In the above schematic we are showing 4 objects. The last three belong to the first one, ( after they have been ned to it ).
The values in the first column somehow belong to the main ListView object.
SubItems are Added to the ListViewItems

DocAElstein
04-16-2022, 10:23 PM
Test



17-121-114-118.applebot.apple.com





header1header2A Header Last Column Header


0SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItemSubItem<-- This is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36





header1header2A Header Last Column Header


0SubItemSubItemSubItem<-- This brown thing is a ListView Item. It has an Item number of 0 and an Item idenitfier/name of 345


1SubItemSubItemSubItem<-- This blue thing is a ListView Item. It has an Item number of 1 and an Item idenitfier/name of 232


2SubItemSubItemSubItem<-- This purple thing is a ListView Item. It has an Item number of 2 and an Item idenitfier/name of 36



[size=0]
header1header2A Header Last Header<-- This bit with the created “column” is part of the main ListView object


0\ 345 SubItemSubItemSubItem<-- This brown thing is a ListViewItem object. It has an Item number of 0,
and an Item identifier/name of 345


1\ 232 SubItemSubItemSubItem<-- This blue thing is a ListViewItem object. It has an Item number of 1,
and an Item identifier/name of 232


2\ 36 SubItemSubItemSubItem<-- This purple thing is a ListViewItem object. It has an Item number of 2
and an Item identifier/name of 36
__
In the above schematic we are showing 4 objects. The last three belong to the first one, ( after they have been ned to it ).
The values in the first column somehow belong to the main ListView object.
SubItems are Added to the ListViewItems

DocAElstein
04-19-2022, 01:57 PM
Link tests

https://excelfox.com/forum/forum.php

https://excelfox.com/forum/forum.php

. (https://excelfox.com/forum/forum.php). (https://excelfox.com/forum/forum.php). (https://excelfox.com/forum/forum.php)

[/URL]

[URL="https://excelfox.com/forum/forum.php"]_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)

_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/forum.php)

_ (https://excelfox.com/forum/forum.php)

https://excelfox.com/forum/forum.php

Alan Spam Tests
_ (s://www.youtube.com/watch?v=MmQqkqiCW40&lc=UgxrbzSGPOC5bTDdQfx4AaABAg.9_WjqSJA9ZU9_WjylY2s Ga)
_ (s://www.youtube.com/watch?v=MmQqkqiCW40&lc=UgxrbzSGPOC5bTDdQfx4AaABAg)

Alan Spam Tests
_ (s://www.youtube.com/watch?v=MmQqkqiCW40&lc=UgxrbzSGPOC5bTDdQfx4AaABAg.9_WjqSJA9ZU9_WjylY2s Ga)_ (s://www.youtube.com/watch?v=MmQqkqiCW40&lc=UgxrbzSGPOC5bTDdQfx4AaABAg)







_ (https://excelfox.com/forum/forum.php)_ (https://excelfox.com/forum/showthread.php/2555-more-about-PowerQuery-aka-Get-amp-Transform-(links))

DocAElstein
04-26-2022, 12:19 PM
In support of this Thread https://eileenslounge.com/viewtopic.php?f=30&t=38110
https://eileenslounge.com/viewtopic.php?p=294721#p294721



Vertical to Horizontal,
This https://i.postimg.cc/14t4nPfD/This-Virtical.jpg (https://postimg.cc/14t4nPfD) to this https://i.postimg.cc/ygfdQprJ/That-Horizintal.jpg (https://postimg.cc/ygfdQprJ)


Part 1 The main data Vertical to Horizontal
An idea I have is to build up the single string that we know can be put into the Windows Clipboard, and then pasted out into Excel. ( http://www.eileenslounge.com/viewtopic.php?p=242941#p242941 )
I basically build that up with some Do While Loopy stuff

The Full Story
The usual worksheets defining and data getting information stuff.
( We capture one extra empty row, because, past experience with these sort of Do While Loopy stuff has shown that it can help simplify some conditional comparison things and/ or help prevent arrays doing out of bounds by one row.


Rem 1
The purpose of this is to get that maximum Amounts or Notes count, ( the biggest group ) ( which is 4 in the given example )
But its worth looking at how that works since the basic Do While Loop is then used in the next main ( Rem 2 ) section.
The #### Main Outer Loop keeps us going through all data rows
Within that the ' ---- Inner Loop that takes us through a group
This loop adds the things in the group, and after each loop is finished we check If the count was the biggest group so far.

Rem 2
This is the main meat of the solution.
First, exactly as before we have a #### Main Outer Loop keeps us going through all data rows

Within that Main Outer Loop we now have 2 inner loops.
'2a
The '2a The first inner loop one does something similar to before. It loops for a group. This time within it we build up two strings that we need for a line in the output.
As example, for the first group we are basically trying to build up these two strings, ( Just before we start that loop, we tack onto the string at the start the group name, which is A in the first group example.
This is what we would see, for example in the immediate window, for querying the string content after, in this example, the the loops for that inner loop

? strClipL
A vbTab 10 vbTab 20 vbTab 30

? strClipR
vbTab N1 vbTab N2 vbTab N3
( For the sake of clarity I use a vbTab to indicate the “invisible” vbTab characters, which is actually on those strings )
'2b
The purpose of '2b the second inner loop is to ,( if necessary ), give us effectively extra empty cells, ( achieved by adding a vbTab of the strings.
Using the same example, we would see that the loop is needed to be done once, and at the end of that single loop, our strings are modifies such:

? strClipL
A vbTab 10 vbTab 20 vbTab 30 vbTab

? strClipR
vbTab N1 vbTab N2 vbTab N3 vbTab

'2c
At this point we combine the two strings and add a line separator so that this row data can be added onto by the next row data
So as to be sure what I have and demonstrate it more clearly, I added a line in testing which calls a function of mine , ( https://excelfox.com/forum/showthread.php/2302-quot-What%e2%80%99s-in-a-String-quot-VBA-break-down-Loop-through-character-contents-of-a-string?p=15522&viewfull=1#post15522 ) , which checks that line screen,
Here is the result

"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf
That looks about correct.

Doing a few other tests, suggest to me that I have the final result that I need: https://i.postimg.cc/xcbJDZgM/StrClip.jpg (https://postimg.cc/xcbJDZgM)

? strclip
A 10 20 30 N1 N2 N3 GroupA
B 40 50 60 70 N4 N5 N6 N7 GroupB
C 80 N8 GroupC
D 90 100 N9 N10 GroupD


"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf & "B" & vbTab & "40" & vbTab & "50" & vbTab & "60" & vbTab & "70" & vbTab & "N4" & vbTab & "N5" & vbTab & "N6" & vbTab & "N7" & vbTab & "GroupB" & vbCr & vbLf & "C" & vbTab & "80" & vbTab & vbTab & vbTab & vbTab & "N8" & vbTab & vbTab & vbTab & vbTab & "GroupC" & vbCr & vbLf & "D" & vbTab & "90" & vbTab & "100" & vbTab & vbTab & vbTab & "N9" & vbTab & "N10" & vbTab & vbTab & vbTab & "GroupD" & vbCr & vbLf







' Ref
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31395#p242941
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31489#p243731
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31938#p247681
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&start=20#p246887
https://eileenslounge.com/viewtopic.php?p=294721#p294721
' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
‘ http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/


‘ https://www.myonlinetraininghub.com/excel-clipboard https://support.microsoft.com/en-us/office/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us&fromar=1#bm2b
‘ https://www.thespreadsheetguru.com/blog/2014/2/20/how-to-create-a-personal-macro-file
‘ https://excelribbon.tips.net/T009810_Cant_Empty_the_Clipboard.html
‘ https://www.excelforum.com/excel-programming-vba-macros/1288935-copy-to-clipboard-not-working.html
‘ https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
https://excelribbon.tips.net/T010691_Message_about_a_Problem_with_the_Clipboard .html
https://excel.tips.net/T003111_Cant_Copy_Data_between_Workbooks.html

' VBA to clear the Office Clipboard http://www.eileenslounge.com/viewtopic.php?p=246838&sid=e1b0b87e47d419c09c526558cc634c64#p246838

DocAElstein
04-26-2022, 12:19 PM
In support of this Thread https://eileenslounge.com/viewtopic.php?f=30&t=38110
https://eileenslounge.com/viewtopic.php?p=294721#p294721



Vertical to Horizontal,
This https://i.postimg.cc/14t4nPfD/This-Virtical.jpg (https://postimg.cc/14t4nPfD) to this https://i.postimg.cc/ygfdQprJ/That-Horizintal.jpg (https://postimg.cc/ygfdQprJ)


Part 1 The main data Vertical to Horizontal
An idea I have is to build up the single string that we know can be put into the Windows Clipboard, and then pasted out into Excel. ( http://www.eileenslounge.com/viewtopic.php?p=242941#p242941 )
I basically build that up with some Do While Loopy stuff

The Full Story
The usual worksheets defining and data getting information stuff.
( We capture one extra empty row, because, past experience with these sort of Do While Loopy stuff has shown that it can help simplify some conditional comparison things and/ or help prevent arrays doing out of bounds by one row.


Rem 1
The purpose of this is to get that maximum Amounts or Notes count, ( the biggest group ) ( which is 4 in the given example )
But its worth looking at how that works since the basic Do While Loop is then used in the next main ( Rem 2 ) section.
The #### Main Outer Loop keeps us going through all data rows
Within that the ' ---- Inner Loop that takes us through a group
This loop adds the things in the group, and after each loop is finished we check If the count was the biggest group so far.

Rem 2
This is the main meat of the solution.
First, exactly as before we have a #### Main Outer Loop keeps us going through all data rows

Within that Main Outer Loop we now have 2 inner loops.
'2a
The '2a The first inner loop one does something similar to before. It loops for a group. This time within it we build up two strings that we need for a line in the output.
As example, for the first group we are basically trying to build up these two strings, ( Just before we start that loop, we tack onto the string at the start the group name, which is A in the first group example.
This is what we would see, for example in the immediate window, for querying the string content after, in this example, the the loops for that inner loop

? strClipL
A vbTab 10 vbTab 20 vbTab 30

? strClipR
vbTab N1 vbTab N2 vbTab N3
( For the sake of clarity I use a vbTab to indicate the “invisible” vbTab characters, which is actually on those strings )
'2b
The purpose of '2b the second inner loop is to ,( if necessary ), give us effectively extra empty cells, ( achieved by adding a vbTab of the strings.
Using the same example, we would see that the loop is needed to be done once, and at the end of that single loop, our strings are modifies such:

? strClipL
A vbTab 10 vbTab 20 vbTab 30 vbTab

? strClipR
vbTab N1 vbTab N2 vbTab N3 vbTab

'2c
At this point we combine the two strings and add a line separator so that this row data can be added onto by the next row data
So as to be sure what I have and demonstrate it more clearly, I added a line in testing which calls a function of mine , ( https://excelfox.com/forum/showthread.php/2302-quot-What%e2%80%99s-in-a-String-quot-VBA-break-down-Loop-through-character-contents-of-a-string?p=15522&viewfull=1#post15522 ) , which checks that line screen,
Here is the result

"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf
That looks about correct.

Doing a few other tests, suggest to me that I have the final result that I need: https://i.postimg.cc/xcbJDZgM/StrClip.jpg (https://postimg.cc/xcbJDZgM)

? strclip
A 10 20 30 N1 N2 N3 GroupA
B 40 50 60 70 N4 N5 N6 N7 GroupB
C 80 N8 GroupC
D 90 100 N9 N10 GroupD


"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf & "B" & vbTab & "40" & vbTab & "50" & vbTab & "60" & vbTab & "70" & vbTab & "N4" & vbTab & "N5" & vbTab & "N6" & vbTab & "N7" & vbTab & "GroupB" & vbCr & vbLf & "C" & vbTab & "80" & vbTab & vbTab & vbTab & vbTab & "N8" & vbTab & vbTab & vbTab & vbTab & "GroupC" & vbCr & vbLf & "D" & vbTab & "90" & vbTab & "100" & vbTab & vbTab & vbTab & "N9" & vbTab & "N10" & vbTab & vbTab & vbTab & "GroupD" & vbCr & vbLf







' Ref
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31395#p242941
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31489#p243731
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31938#p247681
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&start=20#p246887
https://eileenslounge.com/viewtopic.php?p=294721#p294721
' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
‘ http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/


‘ https://www.myonlinetraininghub.com/excel-clipboard https://support.microsoft.com/en-us/office/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us&fromar=1#bm2b
‘ https://www.thespreadsheetguru.com/blog/2014/2/20/how-to-create-a-personal-macro-file
‘ https://excelribbon.tips.net/T009810_Cant_Empty_the_Clipboard.html
‘ https://www.excelforum.com/excel-programming-vba-macros/1288935-copy-to-clipboard-not-working.html
‘ https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
https://excelribbon.tips.net/T010691_Message_about_a_Problem_with_the_Clipboard .html
https://excel.tips.net/T003111_Cant_Copy_Data_between_Workbooks.html

' VBA to clear the Office Clipboard http://www.eileenslounge.com/viewtopic.php?p=246838&sid=e1b0b87e47d419c09c526558cc634c64#p246838

DocAElstein
04-26-2022, 12:19 PM
In support of this Thread https://eileenslounge.com/viewtopic.php?f=30&t=38110
https://eileenslounge.com/viewtopic.php?p=294721#p294721



Vertical to Horizontal,
This https://i.postimg.cc/14t4nPfD/This-Virtical.jpg (https://postimg.cc/14t4nPfD) to this https://i.postimg.cc/ygfdQprJ/That-Horizintal.jpg (https://postimg.cc/ygfdQprJ)


Part 1 The main data Vertical to Horizontal
An idea I have is to build up the single string that we know can be put into the Windows Clipboard, and then pasted out into Excel. ( http://www.eileenslounge.com/viewtopic.php?p=242941#p242941 )
I basically build that up with some Do While Loopy stuff

The Full Story
The usual worksheets defining and data getting information stuff.
( We capture one extra empty row, because, past experience with these sort of Do While Loopy stuff has shown that it can help simplify some conditional comparison things and/ or help prevent arrays doing out of bounds by one row.


Rem 1
The purpose of this is to get that maximum Amounts or Notes count, ( the biggest group ) ( which is 4 in the given example )
But its worth looking at how that works since the basic Do While Loop is then used in the next main ( Rem 2 ) section.
The #### Main Outer Loop keeps us going through all data rows
Within that the ' ---- Inner Loop that takes us through a group
This loop adds the things in the group, and after each loop is finished we check If the count was the biggest group so far.

Rem 2
This is the main meat of the solution.
First, exactly as before we have a #### Main Outer Loop keeps us going through all data rows

Within that Main Outer Loop we now have 2 inner loops.
'2a
The '2a The first inner loop one does something similar to before. It loops for a group. This time within it we build up two strings that we need for a line in the output.
As example, for the first group we are basically trying to build up these two strings, ( Just before we start that loop, we tack onto the string at the start the group name, which is A in the first group example.
This is what we would see, for example in the immediate window, for querying the string content after, in this example, the the loops for that inner loop

? strClipL
A vbTab 10 vbTab 20 vbTab 30

? strClipR
vbTab N1 vbTab N2 vbTab N3
( For the sake of clarity I use a vbTab to indicate the “invisible” vbTab characters, which is actually on those strings )
'2b
The purpose of '2b the second inner loop is to ,( if necessary ), give us effectively extra empty cells, ( achieved by adding a vbTab of the strings.
Using the same example, we would see that the loop is needed to be done once, and at the end of that single loop, our strings are modifies such:

? strClipL
A vbTab 10 vbTab 20 vbTab 30 vbTab

? strClipR
vbTab N1 vbTab N2 vbTab N3 vbTab

'2c
At this point we combine the two strings and add a line separator so that this row data can be added onto by the next row data
So as to be sure what I have and demonstrate it more clearly, I added a line in testing which calls a function of mine , ( https://excelfox.com/forum/showthread.php/2302-quot-What%e2%80%99s-in-a-String-quot-VBA-break-down-Loop-through-character-contents-of-a-string?p=15522&viewfull=1#post15522 ) , which checks that line screen,
Here is the result

"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf
That looks about correct.

Doing a few other tests, suggest to me that I have the final result that I need: https://i.postimg.cc/xcbJDZgM/StrClip.jpg (https://postimg.cc/xcbJDZgM)

? strclip
A 10 20 30 N1 N2 N3 GroupA
B 40 50 60 70 N4 N5 N6 N7 GroupB
C 80 N8 GroupC
D 90 100 N9 N10 GroupD


"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf & "B" & vbTab & "40" & vbTab & "50" & vbTab & "60" & vbTab & "70" & vbTab & "N4" & vbTab & "N5" & vbTab & "N6" & vbTab & "N7" & vbTab & "GroupB" & vbCr & vbLf & "C" & vbTab & "80" & vbTab & vbTab & vbTab & vbTab & "N8" & vbTab & vbTab & vbTab & vbTab & "GroupC" & vbCr & vbLf & "D" & vbTab & "90" & vbTab & "100" & vbTab & vbTab & vbTab & "N9" & vbTab & "N10" & vbTab & vbTab & vbTab & "GroupD" & vbCr & vbLf







' Ref
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31395#p242941
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31489#p243731
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31938#p247681
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&start=20#p246887
https://eileenslounge.com/viewtopic.php?p=294721#p294721
' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
‘ http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/


‘ https://www.myonlinetraininghub.com/excel-clipboard https://support.microsoft.com/en-us/office/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us&fromar=1#bm2b
‘ https://www.thespreadsheetguru.com/blog/2014/2/20/how-to-create-a-personal-macro-file
‘ https://excelribbon.tips.net/T009810_Cant_Empty_the_Clipboard.html
‘ https://www.excelforum.com/excel-programming-vba-macros/1288935-copy-to-clipboard-not-working.html
‘ https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
https://excelribbon.tips.net/T010691_Message_about_a_Problem_with_the_Clipboard .html
https://excel.tips.net/T003111_Cant_Copy_Data_between_Workbooks.html

' VBA to clear the Office Clipboard http://www.eileenslounge.com/viewtopic.php?p=246838&sid=e1b0b87e47d419c09c526558cc634c64#p246838

DocAElstein
04-26-2022, 12:19 PM
In support of this Thread https://eileenslounge.com/viewtopic.php?f=30&t=38110
https://eileenslounge.com/viewtopic.php?p=294721#p294721



Vertical to Horizontal,
This https://i.postimg.cc/14t4nPfD/This-Virtical.jpg (https://postimg.cc/14t4nPfD) to this https://i.postimg.cc/ygfdQprJ/That-Horizintal.jpg (https://postimg.cc/ygfdQprJ)


Part 1 The main data Vertical to Horizontal
An idea I have is to build up the single string that we know can be put into the Windows Clipboard, and then pasted out into Excel. ( http://www.eileenslounge.com/viewtopic.php?p=242941#p242941 )
I basically build that up with some Do While Loopy stuff

The Full Story
The usual worksheets defining and data getting information stuff.
( We capture one extra empty row, because, past experience with these sort of Do While Loopy stuff has shown that it can help simplify some conditional comparison things and/ or help prevent arrays doing out of bounds by one row.


Rem 1
The purpose of this is to get that maximum Amounts or Notes count, ( the biggest group ) ( which is 4 in the given example )
But its worth looking at how that works since the basic Do While Loop is then used in the next main ( Rem 2 ) section.
The #### Main Outer Loop keeps us going through all data rows
Within that the ' ---- Inner Loop that takes us through a group
This loop adds the things in the group, and after each loop is finished we check If the count was the biggest group so far.

Rem 2
This is the main meat of the solution.
First, exactly as before we have a #### Main Outer Loop keeps us going through all data rows

Within that Main Outer Loop we now have 2 inner loops.
'2a
The '2a The first inner loop one does something similar to before. It loops for a group. This time within it we build up two strings that we need for a line in the output.
As example, for the first group we are basically trying to build up these two strings, ( Just before we start that loop, we tack onto the string at the start the group name, which is A in the first group example.
This is what we would see, for example in the immediate window, for querying the string content after, in this example, the the loops for that inner loop

? strClipL
A vbTab 10 vbTab 20 vbTab 30

? strClipR
vbTab N1 vbTab N2 vbTab N3
( For the sake of clarity I use a vbTab to indicate the “invisible” vbTab characters, which is actually on those strings )
'2b
The purpose of '2b the second inner loop is to ,( if necessary ), give us effectively extra empty cells, ( achieved by adding a vbTab of the strings.
Using the same example, we would see that the loop is needed to be done once, and at the end of that single loop, our strings are modifies such:

? strClipL
A vbTab 10 vbTab 20 vbTab 30 vbTab

? strClipR
vbTab N1 vbTab N2 vbTab N3 vbTab

'2c
At this point we combine the two strings and add a line separator so that this row data can be added onto by the next row data
So as to be sure what I have and demonstrate it more clearly, I added a line in testing which calls a function of mine , ( https://excelfox.com/forum/showthread.php/2302-quot-What%e2%80%99s-in-a-String-quot-VBA-break-down-Loop-through-character-contents-of-a-string?p=15522&viewfull=1#post15522 ) , which checks that line screen,
Here is the result

"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf
That looks about correct.

Doing a few other tests, suggest to me that I have the final result that I need: https://i.postimg.cc/xcbJDZgM/StrClip.jpg (https://postimg.cc/xcbJDZgM)

? strclip
A 10 20 30 N1 N2 N3 GroupA
B 40 50 60 70 N4 N5 N6 N7 GroupB
C 80 N8 GroupC
D 90 100 N9 N10 GroupD


"A" & vbTab & "10" & vbTab & "20" & vbTab & "30" & vbTab & vbTab & "N1" & vbTab & "N2" & vbTab & "N3" & vbTab & vbTab & "GroupA" & vbCr & vbLf & "B" & vbTab & "40" & vbTab & "50" & vbTab & "60" & vbTab & "70" & vbTab & "N4" & vbTab & "N5" & vbTab & "N6" & vbTab & "N7" & vbTab & "GroupB" & vbCr & vbLf & "C" & vbTab & "80" & vbTab & vbTab & vbTab & vbTab & "N8" & vbTab & vbTab & vbTab & vbTab & "GroupC" & vbCr & vbLf & "D" & vbTab & "90" & vbTab & "100" & vbTab & vbTab & vbTab & "N9" & vbTab & "N10" & vbTab & vbTab & vbTab & "GroupD" & vbCr & vbLf







' Ref
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31395#p242941
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31489#p243731
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31938#p247681
' http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&start=20#p246887
https://eileenslounge.com/viewtopic.php?p=294721#p294721
' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
' https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
' https://stackoverflow.com/questions/31439866/multiple-variable-arguments-to-application-ontime/59812342#59812342
‘ http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/


‘ https://www.myonlinetraininghub.com/excel-clipboard https://support.microsoft.com/en-us/office/copy-and-paste-using-the-office-clipboard-714a72af-1ad4-450f-8708-c2931e73ec8a?ui=en-us&rs=en-us&ad=us&fromar=1#bm2b
‘ https://www.thespreadsheetguru.com/blog/2014/2/20/how-to-create-a-personal-macro-file
‘ https://excelribbon.tips.net/T009810_Cant_Empty_the_Clipboard.html
‘ https://www.excelforum.com/excel-programming-vba-macros/1288935-copy-to-clipboard-not-working.html
‘ https://www.thespreadsheetguru.com/blog/2015/1/13/how-to-use-vba-code-to-copy-text-to-the-clipboard
https://excelribbon.tips.net/T010691_Message_about_a_Problem_with_the_Clipboard .html
https://excel.tips.net/T003111_Cant_Copy_Data_between_Workbooks.html

' VBA to clear the Office Clipboard http://www.eileenslounge.com/viewtopic.php?p=246838&sid=e1b0b87e47d419c09c526558cc634c64#p246838

DocAElstein
04-26-2022, 06:16 PM
Coding so far , for last post, https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529





' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' http://www.eileenslounge.com/viewtopic.php?f=30&t=38110&p=294692#p294692
Sub Stantial()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows

Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")

End Sub

DocAElstein
04-26-2022, 06:16 PM
Coding so far , for last post, https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529





' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' http://www.eileenslounge.com/viewtopic.php?f=30&t=38110&p=294692#p294692
Sub Stantial()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows

Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")

End Sub

DocAElstein
04-26-2022, 06:16 PM
Coding so far , for last post, https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529





' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' http://www.eileenslounge.com/viewtopic.php?f=30&t=38110&p=294692#p294692
Sub Stantial()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows

Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")

End Sub

DocAElstein
04-26-2022, 06:16 PM
Coding so far , for last post, https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529





' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=16529&viewfull=1#post16529
' http://www.eileenslounge.com/viewtopic.php?f=30&t=38110&p=294692#p294692
Sub Stantial()
Rem 0 data
Dim Ws1 As Worksheet: Set Ws1 = ThisWorkbook.Worksheets("Sheet1")
Dim RngPlus1 As Range
Set RngPlus1 = Ws1.Cells.Item(1).CurrentRegion.Resize(Ws1.Cells.I tem(1).CurrentRegion.Rows.Count + 1, Ws1.Cells.Item(1).CurrentRegion.Columns.Count)
Dim vArr() As Variant: Let vArr() = RngPlus1.Value2
Rem 1 determine the biggest group ( that maximum Amounts or Notes count )
Dim Cnt As Long, Cnt2 As Long, Mx As Long: Let Mx = 1: Let Cnt = 1
Do ' ############################# Main Outer Loop keeps us going through all data rows
Do ' ----------------- Inner Loop that takes us through a group
Let Cnt = Cnt + 1 ' Cnt is the main data row number
Let Cnt2 = Cnt2 + 1
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' ---- Inner Loop that takes us through a group
If Cnt2 > Mx Then Let Mx = Cnt2
Let Cnt2 = 0
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows

Rem 2 ' ############################# Main Outer Loop keeps us going through all data rows
Let Cnt = 1
Do
Dim HrCnt As Long: Let HrCnt = 1
Dim strClipR As String, strClipL As String: Let strClipL = strClipL & vArr(Cnt + 1, 1)
Do '2a The first inner loop
Let Cnt = Cnt + 1
Let HrCnt = HrCnt + 1
Let strClipL = strClipL & vbTab & vArr(Cnt, 2)
Let strClipR = strClipR & vbTab & vArr(Cnt, 3)
Loop While vArr(Cnt + 1, 1) = vArr(Cnt, 1) ' The first inner loop
Do While HrCnt < Mx + 1 '2b the second inner loop
Let strClipL = strClipL & vbTab
Let strClipR = strClipR & vbTab
Let HrCnt = HrCnt + 1
Loop ' the second inner loop
'2c Finishing off the strings, and final string for an output line, after the inner loops
Let strClipR = strClipR & vbTab & vArr(Cnt, 4) ' add the group name
Dim strClip As String: Let strClip = strClip & strClipL & strClipR & vbCr & vbLf ' join the strings and add a line seperator to the output row string
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
Let strClipL = "": strClipR = ""
Loop While Cnt < UBound(vArr(), 1) - 1 ' #### Main Outer Loop keeps us going through all data rows
'Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strClip)
'2d paste strClip out via the windows Clipboard
Dim objDataObject As Object: Set objDataObject = GetObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}") ' http://web.archive.org/web/20200124185244/http://excelmatters.com/2013/10/04/late-bound-msforms-dataobject/
objDataObject.SetText Text:=strClip
objDataObject.PutInClipboard
Ws1.Paste Destination:=Ws1.Range("G2")

End Sub