Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:41:27+00:00 2026-05-23T18:41:27+00:00

I’ve got a problem with some VB scripting – it doesn’t seem like it

  • 0

I’ve got a problem with some VB scripting – it doesn’t seem like it should be terribly difficult to solve, but even after trudging through many a page of Google I have yet to find a solution.

[The problem]

Here is my python file (test.py), simplified to just show the problem:

f = open("testing.txt", 'w')
f.write("oh hai\n")
f.close()

Of course, when run directly from the command line, this generates the file as you’d expect.

However, when run in a simple .vbs script (WARNING: My vbs skills are lacking. This is probably why I am having a problem. So far I haven’t had many issues, apart from hating life from using XP to code when I’m used to using vim)

Set WshShell = WScript.CreateObject("WScript.Shell")
cmd = "C:\Python27\python test.py"
WshShell.Run cmd

no output file is generated! At all! It’s infuriating, as when I input that exact command ("C:\Python27\python test.py") into the run program from the start menu, it works!

[System info]

At work, so they’re on Windows XP. Everything else is pretty standard, or so I’m lead to believe.

EDIT: Changed “C:\Python27\testing.py” to just “testing.py”. This was left over from when I was trying to solve it, and thought maybe it was putting the files somewhere outside of the destination folder.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:41:29+00:00Added an answer on May 23, 2026 at 6:41 pm

    First, your Python script looks suspicious, I doubt the backslashes work in a simple string. At least, in my test, it didn’t work, I just replaced them with forward slashes.

    Next, you can see the error message by prepending cmd with cmd /k, the run window remains on screen. You can see the .py file isn’t found, because it isn’t in the current directory. You have to specify an absolute path to this file, perhaps by getting the current path from the script.

    [EDIT] I finally got a working code (my VBS is a bit rusty…)

    Dim wshShell, fso, loc, cmd
    
    Set fso = CreateObject("Scripting.FileSystemObject")
    loc = fso.GetAbsolutePathName(".")
    WScript.Echo loc
    
    '~ cmd = "%ComSpec% /k C:\Languages\Python\python.exe " + loc + "\test.py"
    cmd = "C:\Languages\Python\python.exe " + loc + "\test.py"
    WScript.Echo cmd
    
    Set wshShell = CreateObject("WScript.Shell")
    wshShell.Run cmd
    

    You can also check the arguments if a path is provided:

    if WScript.Arguments.Count = 0 then
        loc = fso.GetAbsolutePathName(".")
    else
        loc = WScript.Arguments(0)
    end if
    

    Such script is better run with cscript instead of default wscript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.