0

I'm trying to invoke a vbscript through python as follows

import os
import sys 
import pandas as pd
import numpy as np
rancsv = pd.DataFrame(np.random.randn(150, 5))
rancsv.to_csv('randomcsv.csv', sep=',')
os.system(r"C:\Users\v-2mo\Documents\Python Scripts\test.vbs")

However this simply gives an output of 1 in jupyter notebook and does not run the script.

The script when run directly, runs just fine.

What am I doing wrong?

1
  • You need to call it through either wscript.exe (Windows GUI) or cscript.exe (Command line) host applications. Commented Oct 10, 2017 at 8:49

2 Answers 2

0
os.system(r"C:\\Users\\v-2mo\\Documents\\Python Scripts\\test.vbs")

or

os.system(r"C:/Users/v-2mo/Documents/Python Scripts/test.vbs")
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't the r prefix mean that you can write \ instead of \\ in your first snippet?
0

answered well here https://stackoverflow.com/a/19114284/17889328 in short, .vbs opens ok in command prompt because shell associates with program wscriipt or cscript and runs it. run silently your program doesn't get the associationand doesn't know how to open. need specify "wscript filename.vbs" and / or run with shell eg "cmd /c..."

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.