Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
techwiki:dos [2019/04/24 00:34]
ying [system operation]
techwiki:dos [2019/11/22 00:05] (current)
ying [basic operation]
Line 29: Line 29:
 </​code>​ </​code>​
  
-call python file with same name<​code dos>+**call python file with same name**<code dos>
 @echo off @echo off
 call python %~dp0%~n0.py call python %~dp0%~n0.py
 pause pause
 +</​code>​
 +
 +**call custom python to run python file with passing parameter (Basic version)**<​code dos SameNameAsPyFile.bat>​
 +set CustPython=D:​\Pipeline\App_Win\Python27x64\
 +%CustPython%python.exe %~dp0%~n0.py %1
 +pause
 +</​code>​
 +
 +<code python SameNameAsPyFile.py>​
 +import os,sys
 +input_count = len(sys.argv)
 +print('​Inputs Count: {0}'​.format(input_count))
 +if input_count>​1:​
 +    print('​Passing File Path: {0}'​.format(sys.argv[1]))
 +</​code>​
 +
 +**call custom python to run python file with passing parameter (Advanced version)**<​code dos SameNameAsPyFileAdvanced.bat>​
 +:: dont type out cmds in cmd window
 +@echo off
 +set CustPython=R:​\Pipeline\App_Win\Python27x64\
 +
 +:: Check for Python Installation
 +python --version 2>NUL
 +if errorlevel 1 goto NoPython
 +
 +::====== hasPython ======
 +call python.exe %~dp0%~n0.py %1 && goto done
 +goto console
 +
 +::====== noPython ======
 +:NoPython
 +IF EXIST %CustPython% (
 +  echo %CustPython%
 +  call %CustPython%python.exe %~dp0%~n0.py %1 && goto done
 +  goto console
 +) ELSE (
 +  echo Error^: Python not detected  ​
 +)
 +
 +:console
 +pause
 +:done
 +</​code>​
 +
 +<code python SameNameAsPyFileAdvanced.py>​
 +import os,sys
 +input_count = len(sys.argv)
 +print('​Inputs Count: {0}'​.format(input_count))
 +if input_count>​1:​
 +    print('​Passing File Path: {0}'​.format(sys.argv[1]))
 +    sys.exit(0) # 0: success, 1-127: bad error
 +else:
 +    print('​Error:​ No File Passing to Python'​)
 +    sys.exit(1)
 </​code>​ </​code>​
  
Line 185: Line 239:
  
 ===== control panels and admin tools ===== ===== control panels and admin tools =====
 +
 +  * windows component window can be open with cmds like explorer.exe,​control.exe,​rundll32.exe,​ like open network connection window can be
 +    * code (canonical name, GUID, module dll)<​code>​
 +explorer.exe shell:​ConnectionsFolder
 +explorer.exe shell:::​{992CFFA0-F557-101A-88EC-00DD010CCC48}
 +control.exe netconnections
 +ncpa.cpl
 +control ncpa.cpl
 +rundll32.exe shell32.dll,​Control_RunDLL ncpa.cpl
 +
 +control.exe sysdm.cpl,,​3
 +control /name Microsoft.NetworkAndSharingCenter /page Advanced
 +control /name Microsoft.InternetOptions /page 4
 +explorer shell:::​{ED834ED6-4B5A-4bfe-8F11-A626DCB6A921} -Microsoft.Personalization\pageWallpaper
 +
 +# folder option
 +control /name Microsoft.FolderOptions
 +control folders
 +rundll32.exe shell32.dll,​Options_RunDLL 0
 +# folder option - view
 +rundll32.exe shell32.dll,​Options_RunDLL 7
 +</​code>​
 +    * ref: 
 +      * https://​www.lifewire.com/​command-line-commands-for-control-panel-applets-2626060
 +      * https://​docs.microsoft.com/​en-us/​windows/​win32/​shell/​controlpanel-canonical-names
 +      * https://​www.tenforums.com/​tutorials/​86339-list-commands-open-control-panel-items-windows-10-a.html
 +      * https://​coderwall.com/​p/​3awvka/​a-list-of-run-commands-for-windows-7
  
 ^ management panel ^^ ^ management panel ^^