Posts Tagged ‘Scripting’

Execute an exe from VBS with space in file name

April 18th, 2011

Hi All,

I was having problem on executing an exe file from vbs, the problem was the exe path has space between it. For example “C:\Program Files\test\my app.exe”.

The vbs will returns an error which says file not found for that path. This is happened because after the space, the vbs will treat the entire command after the space as arguments.

To fix it we can use multiple quote like this.

wscript.run """C:\Program Files\test\my app.exe"""

Use 3 quote.

What if we want to use arguments in our command?

wscript.run """C:\Program Files\test\my app.exe"" /command args"

Cheers!

What people search:

How to execute an exe from vbScript

April 18th, 2011

Sometime we will need to execute an exe file from our vbs, so here’s the snippet.

Set wsShell = WScript.CreateObject("WScript.shell")
wsShell.run "C:\windows\system32\calc.exe"

What people search:

Simple Powershell FTP

May 3rd, 2010

With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I’m using System.Net.WebClient to handle the file transfer.

1
2
3
4
5
6
7
8
9
10
11
$ftpuser = "user"
$ftppass = "12345"
$ftpserver = "localhost"
$file = "C:\test.txt"
$filenewname = "test.txt"
 
$webclient = New-Object System.Net.WebClient
$ftp = "ftp://"+$ftpuser+":"+$ftppass+"@"+$ftpserver+"/"+$filenewname
$uri = New-Object System.Uri($ftp)
 
$webclient.UploadFile($uri,$file)

What people search: