I wrote this simple console program (writeTxt.exe
):
#include "stdafx.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char *fileName = "test.txt";
ofstream outStream(fileName, ios::out);
outStream << "This is a very simple test." << endl;
return 0;
}
Then I run it on the console of Windows Server 2008 using runas
command (I logged-in as a different user from User1
):
runas /user:User1 writeTxt.exe
But the program doesn't produce the file test.txt
. If I log-in to the server as User1
and run the program, it works correctly. Do I have to set something for this to run correctly?