May 25
Today I made a simple console application using Visual C++ 2008 and it was runs well on my development machine. But the problem occurred when I run the application on another machine, the error says “The system cannot execute the specified program“. I was guessing the problem occurred because of missing library or something, after short analysis both machine have the correct and the same library. So what’s going on??
I googled for this error and found this article, it explains how this problem occurred on compiled C++ application. There’s two type of build on VC++ ( Debug and Release), my application was built in debug mode and we can’t re-distribute the application on debug mode. The built program in debug mode only runs on development machine, so in order to distribute my app I should build my application in ‘Release’ mode. Time to switch from ‘Debug’ to ‘Release’ mode,
Open your Visual Studio->(Open Project)->Project->(project name) properties
select the Build Tab, in configuration option choose “Release”.
Rebuild your project, you will find “Release” folder, your released application is in there.
Tagged with: C++ • Error
May 03
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) |
Tagged with: Powershell • Scripting
May 03
It’s pretty easy to sort an output from ls or Get-ChildItem using powershell, you can sort the output by name, length, and date.
Sort By Name
Get-ChildItem C:\ | sort -property Name
Sort By Size
Get-ChildItem C:\ | sort -property Length
Sort By Date Modified
Get-ChildItem C:\ | sort -property LastWriteTime
You also can reorder the sort output with “-descending”
example :
Get-ChildItem C:\ | sort -property LastWriteTime -descending
Tagged with: Powershell