I build a script to remove Windows 10 Apps per Python.
I saved the apps to remove in a String Array and save the complete command in a variable.
Then I run the command, come a Error with: The Remove-AppxPackage command is either misspelled or
could not be found.
And I have coded following code:
win10Apps = ["3d", "camera"]
for app in win10Apps:
psCommand = "Get-AppxPackage " + app + " | Remove-AppxPackage"
pyautogui.press("Enter")
os.system("powershell.exe " + psCommand)
pyautogui.press("Enter")
As JosefZ mentioned in the comments, you have to format your parameter when calling other executable.
The fixed code looks like this:
win10Apps = ["3d", "camera"]
for app in win10Apps:
psCommand = "Get-AppxPackage " + app + " | Remove-AppxPackage"
pyautogui.press("Enter")
os.system('powershell.exe -c "{}"'.format( psCommand))
pyautogui.press("Enter")
Also for special characters you need to escape. Also, here is the documentation for Get-AppxPackage and for Remove-AppxPackage.
Related
I have been on this problem for quite a while now. I have this command line that I want run trough python:
Users\name.lastname\Desktop\TESTER\Latitude 5431\Latitude-5431-46KCM_Win10_1.0_A01.exe /s /e=C:Users\name.lastname\Desktop\TESTER\Latitude 5431
this should run the .exe and then extract the files to the specified folder. I tried this with os.system and it worked but when I run it with
import subprocess
x = '"' + "\\Users\\name.lastname\\Desktop\\TESTER\\Latitude 5431\\Latitude-5431-46KCM_Win10_1.0_A01.exe" + '" ' + "/s /e=C:Users\\name.lastname\\Desktop\\TESTER\\Latitude 5431"
p1 = subprocess.run(x, shell=True)
it only shows me 'tips' like these but no error message and the .exe is not executed.
Pass command line arguments directly to vendor installer.
Turn the return code to success if required
Latitude-5431-46KCM_Win10_1.0_A01.exe /factoryinstall /passthrough D:\Sample.xml C:\log\FI.log
Change from the default log location to C:\my path with spaces\log.txt
Latitude-5431-46KCM_Win10_1.0_A01.exe /l="C:\my path with spaces\log.txt"
Force update to continue, even on "soft" qualification errors
Latitude-5431-46KCM_Win10_1.0_A01.exe /s /f
Try running without shell=True as it makes things more complicated than it helps:
import subprocess
prog = r"C:\Users\name.lastname\Desktop\TESTER\Latitude 5431\Latitude-5431-46KCM_Win10_1.0_A01.exe"
args = ["/s", r"/e=C:\Users\name.lastname\Desktop\TESTER\Latitude 5431"]
subprocess.run([prog]+args)
I'm making a script that runs a command line and then shows the output in flask webpage.
The problem I'm facing is that the output is malformed, it looks like this.
img
here's my what I have wrote so far:
import subprocess as sp
#app.route('/harvester/scan',methods=['GET','POST'])
def harv():
domain=request.values.get('domain')
outputt=sp.getoutput("theharvester" + " " + "-d" + " " + domain + " " + "-l 10 -b all" )
return outputt
Function subprocess.getoutput is a legacy one. Try using subprocess.run instead.
Here is the example:
import subprocess
command = 'printf "1\n2"'
out = subprocess.run(command, capture_output=True).stdout.decode()
I had topic here before but my problem is not solved...
I used an older version of Gnome for a very long time and my script worked very well. I have installed the latest version Gnome (3.36.9) and there is a small problem that does not interfere with the use of the program. I'm talking about an error:
Option ā-eā is deprecated and might be removed in a later version of gnome-terminal. # Use ā-- ā to terminate the options and put the command line to execute after it.
It doesn't stop me from using or running the program, but I wanted to get rid of the bugs in the console.
My older, working initial code looks like this:
# <--- CONFIG ---> #
os.chdir("/home/administrator/program/cartypes")
car1 = "audi"
color1 = "black"
engine = "diesel"
# <--- CONFIG ---> #
p1 = Popen(['gnome-terminal', '--wait', '-e','python3 ./program.py --car ' + car1 + ' --color ' + color1 + ' --engine ' + engine1])
time.sleep(5)
p1.communicate()
p1.wait()
print("End!")
I read a bit and changed "-e" to "--" that is:
p1 = Popen(['gnome-terminal', '--wait', '--','python3', './program.py'])
And theoretically the program starts, but unfortunately it doesn't work anymore when I add argparse to the code and I don't know how to connect working script with arguments send to program.py as that was before in first code with "-e":
p1 = Popen(['gnome-terminal', '--wait', '--','python3', './program.py'])
with:
./program.py --car ' + car1 + ' --color ' + color1 + ' --engine ' + engine1
Thanks! :)
Just get rid of the concatenation and make them separate list elements.
p1 = Popen(['gnome-terminal', '--wait', '--', 'python3', './program.py', '--car', car1, '--color', color1, '--engine', engine1])
Your original code also didn't quote or escape the variables, so you could run into problems if any of them contain quote characters.
I have written basic port scanner for target ip and when I run it through kali vm it says sh: 1: nmap-F192.168.234.135: not found. but when I run nmap -F 192.168.234.135 ... its perfectly working. Can anyone point out the reason behind it. thanks
import os
def get_nmap(options,ip):
command = "nmap" + options + "" + ip
process = os.popen(command)
result = str(process.read())
return result
print(get_nmap('-F','192.168.234.135'))
Better, using the subprocess module:
def get_nmap(options, ip) :
return subprocess.check_output(["nmap", options, ip])
#end get_nmap
You need to add spaces in the command string. Change it to
command = "nmap " + options + " " + ip
I am building a browser game with three.js and I want to load a model from Maya 2013 into my scene. I have exported the model as an obj file.
Now I need to know how to convert it into an JS file for the three.js-loader.
This is my loader so far:
var jsonLoader = new THREE.JSONLoader();
jsonLoader.load( "models/model.js", addModelToScene );
Thanks in advance
If you don't want to use blender, mrdoob(made threejs) has a simple python script to convert obj to json. Just run --this script-- in terminal like so:
python convert_obj_three.py -i infile.obj -o outfile.js
Use Blender.
Blender 3D
Then install this addon:
Three.js exporter
Thats a pretty late reply. I have written a converter to read obj files and convert to ThreeJS supported JSON format:
https://github.com/theMaxscriptGuy/Windows_Programs/tree/master/Obj_To_ThreeJS
Download all the files as zip and run converter.exe...
Note: the python converter script has been updated to a js based tool https://github.com/mrdoob/three.js/tree/dev/utils/converters
Usage:
node obj2three.js model.obj
When exporting 3ds max models to three.js using the [convert_obj_three.py][1] script, a little degree of automation can be achieved with the following command in cmd promt:
cd C:\Python27 &
python convert_obj_three.py -i _obj\chromeBand.obj -o _json\chromeBand.js &
python convert_obj_three.py -i _obj\controlPanelCover.obj -o _json\controlPanelCover.js
I wrote a 3ds max script that will print the phyton script command for multiple models and also a json with the models relative urls and coordinates. The json is useful for placing multiple models at the correct position in scene.
(
local inputPath = "D:\Archive\Work\_Dev\_Convert\Obj\\"
local outputPath = "C:\Server\htdocs\viewer\assets\models\my-project\\"
local jsonPath = "assets/models/my-project/"
local myListEntry = "\n"
for o in selection do
(
myListEntry +=
"\"" + o.name + "\": {\n" +
"\t\"url\": \"" + jsonPath + o.name + ".js\",\n" +
"\t\"position\": {\n" +
"\t\t\"x\": \"" + o.position.x as string + "\",\n" +
"\t\t\"y\": \"" + o.position.z as string + "\",\n" +
"\t\t\"z\": \"" + (o.position.y * -1) as string + "\"\n" +
"\t}\n" +
"},\n"
)
myListEntry += "\n\n\n=== Run this using cmd promt: ===\n"
myListEntry += "cd C:\Python27 &\n"
for o in selection do
(
myListEntry += "python D:\Archive\Work\_Dev\_Convert\convert_obj_three.py -i " +
inputPath + o.name + ".obj -o " +
outputPath + o.name + ".js & \n"
)
myListEntry += "exit \n"
print myListEntry
actionMan.executeAction 0 "40472"
)
Create a new txt file, rename it to coordinates.mcr and drag and drop the file into the 3ds max window. It will automatically open MaxScript Listener window and print the results. Copy paste the python command in cmd. Use the printed json to batch load your models in your project.
Also, scripts can be assigned to buttons in 3dsMax toolbars, for fast access.
The above script could use further tweaking. Not the best solution but at least it speeds up things, hopefuly.
Use Jos Balcaen's script for exporting obj files in batch (3ds Max)
Edit:
After experimenting a bit with the script I have made a setup that allows me to export my models (counting more than 20) in under 1 minute from 3ds max to open browser tab. Of course, you may need to adjust the json output to your liking. Hope you will find this useful.
Create a Python file named conversion.py with the following content: click here to see it.
And then run this command in your Terminal:
python conversion.py -i file.obj -o file.js