|
|
If I were you, I'd use PsExec[^] to execute the commands.
|
|
|
|
|
can psexec work for machines not in domain.
|
|
|
|
|
Do you think of a tool similar to Java's Web Start used by e.g. Continuous Integration tools like Hudson and Jenkins?
Well, I do not know of such a component in the .Net world...
|
|
|
|
|
can i execute command in a windows box remotely over internet and get its output provided i have full details of credential required to connect to the remote machine. Through PSexec i am able excute command in remote machine in the LAN /intranet and get output in my local machine in a text file but will it be possible to get the same details if the remote machine is connected in Internet.
|
|
|
|
|
Assuming you have the credentials and legal approval then the pc must be directly connected to the internet, meaning it must have an ip directly on the internet, or have port forwarding enabled on the router it sits behind.
Normally you are not going to find pc's directly attached to the internet. Best practice is a firewall in between, which means you need to manually set up port forwarding at the pc's location.
|
|
|
|
|
Lets start with the basics first.
To execute a 'command' on a remote machine then the remote machine MUST have a server application running which will execute those commands. (Note that starting an application is also considered executing a command so you cannot expect to remotely start the application.)
And that server application MUST be remotely accessible.
That is an absolute. There is no other possibility.
There are many applications that can do this - including writing your own.
The FIRST step to implementing a solution is to determine what that server application will be. Because that will determine what the client application can do and what it can't do.
|
|
|
|
|
Hi I am just starting out using c# and I have followed a tutorial i think but i am getting errors
------------------------------------------------
namespace SkiTrip
{
Class Student
{
private string name;
private decimal totalPaid;
private bool canTravel;
//Here write the properties
public void setName (string newName)
{
name = newName;
}
public string getName ()
{
return name;
}
}
--------------------------------------------
Error 1 A namespace cannot directly contain members such as fields or methods
Error 2 x 4 Expected class, delegate, enum, interface, or struct
--------------------------------------------
help really appreciated
mark
|
|
|
|
|
c# is case-sensitive, so
Class is not the same as class . C# uses lower-case names for keywords, so the capitalized "Class" is not valid, you have to start it with "class".
You are also missing a } in the code you provided, it should be (in full):
namespace SkiTrip
{
class Student
{
private string name;
private decimal totalPaid;
private bool canTravel;
public void setName (string newName)
{
name = newName;
}
public string getName ()
{
return name;
}
}
}
|
|
|
|
|
Many thanks, I have been trying to sort this for hours, hopefully I wont make any more typo's
Mark
|
|
|
|
|
Use an Integrated Development Environment (IDE), the Express versions of Visual Studio are free!
|
|
|
|
|
Also do not use methods such as setName and getName , use the integrated C# set and get to access properties as described in this tutorial[^]. If you want to read a really good introduction to C# try .NET Book Zero[^].
Veni, vidi, abiit domum
|
|
|
|
|
I am looking for a working in C# that can convert English text to Arabic text before the text is passed to printer.
|
|
|
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
{
DirectoryInfo di = new DirectoryInfo(path);
foreach (var movie in di.GetFiles())
{
foreach (var extension in extensionsForMovies)
{
if (movie.Extension.ToUpper() == extension)
{
List1.Add(movie.Name);
}
}
}
DateTime dt = DateTime.UtcNow;
string day = dt.Day.ToString(); if (dt.Day < 10) day = 0 + dt.Day.ToString();
string month = dt.Month.ToString(); if (dt.Month < 10) month = 0 + dt.Month.ToString();
string date = dt.Year.ToString() + month + day;
index = new FileInfo(" index" + List1.Count + " [" + date + "].pls");
label1.Text = List1.Count + " files/" + nrMovies() + " saved";
}
List<string> List1 = new List<string>();
List<string> List2 = new List<string>();
List<string> List3 = new List<string>();
private void button1Create_Click(object sender, EventArgs e)
{
bool isPLSfile = false;
DirectoryInfo di = new DirectoryInfo(path);
foreach (var movie in di.GetFiles())
{
if (movie.Extension.ToUpper() == ".PLS")
{
List2.Clear(); List3.Clear();
StreamReader sr074 = new StreamReader(movie.FullName);
while (!sr074.EndOfStream)
{
List2.Add(sr074.ReadLine() + "\r\n");
}
sr074.Close();
List2.RemoveAt(0);
List2.RemoveAt(0);
isPLSfile = true;
}
}
if (isPLSfile == false) { button0Default.PerformClick(); goto End; }
string llinelist1_ = "", llinelist2_ = "";
again:
for (int i = 0; i < List2.Count; i++)
{
for (int j = 0; j < List1.Count; j++)
{
llinelist1_ = List1[j];
llinelist2_ = List2[i];
if (llinelist2_.Contains(llinelist1_))
{
List3.Add(List1[j]);
List1.RemoveAt(j);
List2.RemoveAt(i);
goto again;
}
}
}
foreach (var List1_Line in List1)
{
List3.Insert(0, List1_Line);
}
List2.Clear();
foreach (var line in List3)
{
List2.Add(line);
}
FileInfo fi = new FileInfo(index.FullName);
fi.Delete();
StreamWriter sw = new StreamWriter(index.Name, false, Encoding.Unicode);
sw.Write("[playlist]\r\nNumberOfEntries=" + List3.Count + "\r\n");
string s4563 = "";
for (int i = 1; i < List2.Count + 1; i++)
{
s4563 = "File" + i + "=" + path + "\\" + List2[i - 1] + "\r\n";
"sw.Write(s4563);
}
sw.Close();
//--------------------------------------------------
//start software
label1.Text = List3.Count + " files/" + nrMovies() + " saved";
Process.Start(path + "
End:
List2.Clear(); List3.Clear();
}
Thanks
|
|
|
|
|
So where are you facing the problem?
|
|
|
|
|
I am thinking on my code as a structure - i want my code to make it more practical, usable, coder friendly, with good structure and architecture. Maybe this is the problem. The actual code is working fine- but when i have to change something, i must spend days to debug the sh*t out.
Thanks Abhinav.
|
|
|
|
|
Being frank here: that code is rather poor.
I'm not too surprised that if you change something, the rest of it starts to fall over - you don't seem to have any consistent structure or to use any good practices.
Don't call things "list1" and "list2" - name them after what they do, just as you do in the comments.
If you only want files which match an extension, then only retrieve file which match the extension:
string[] files = Directory.GetFiles(path, "*.PLS");
If you want all lines from a file, then just read them:
string[] lines = File.ReadAllLines(path);
You can then convert this to a list with the ToList method if you need a list.
And so on - try modularising this code so that you have a method doing one task, then call it from your click handler - that way, you can test the method in isolation and be sure it works.
I'm not at all sure what your code is doing at the moment, so I'm not that surprised that you have problems maintaining it - it looks like you have hacked and slashed it a bit to get it working, then hacked it again to fix that bug, then...all without sitting down and working out what you are trying to achieve and doing a design of some form which meets that aim first.
The only instant messaging I do involves my middle finger.
English doesn't borrow from other languages.
English follows other languages down dark alleys, knocks them over and goes through their pockets for loose grammar.
|
|
|
|
|
_Q12_ wrote: I work at this code from a month now, and still is full of bugs. Where? Your description in the comments section states what you want your application to do but gives no useful details of what the problems are.
Veni, vidi, abiit domum
|
|
|
|
|
First, improve your readability of variables:
List<string> List1 = new List<string>();
List<string> List2 = new List<string>();
List<string> List3 = new List<string>();
List<string> moviesList = new List<string>();
List<string> savesList = new List<string>();
List<string> tempList = new List<string>();
Also, there are FORs that you could change to foreach.
Please, drop the GOTO. Although it has its uses, the same can be achieved with loop controls and it can avoid confusion.
There are no secrets to success. It is the result of preparation, hard work, and learning from failure. Colin Powell
|
|
|
|
|
Okay, I see many areas that can be improved. Here are a few enhancements that you might want to consider as they should make your life easier (and I'm not talking just about renaming your lists).
First of all, you are mixing a lot of concerns in your code. That's a fancy way of saying that your class is trying to do too much. You should simplify and specialise so that you create classes that are responsible only for their own functionality. That makes testing and fixing a lot easier.
You are relying on goto statements - I'm not going to go into a religious gotos are evil argument here as they sometimes do have their place, but in your case they are obscuring the logic.
You can simplify your GetFiles when you are retrieving multiple extensions using a simple LINQ trick:
IEnumerable<string> files = extensionsForMovies.SelectMany(filter =>
Directory.GetFiles(currentFolder, filter, SearchOption.TopDirectoryOnly));
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Cv;
using CxCore;
using OtherLibs;
namespace sampleWebcam
{
public partial class Form1 : Form
{
private CvCapture VideoCapture;
private IplImage frame;
private IplImage imgMain;
public Form1()
{
InitializeComponent();
}
private void btnVideo_Click(object sender, EventArgs e)
{
double vidWidth, vidHeight;
if (btnVideo.Text.Equals("Start Video"))
{
VideoCapture = highgui.CvCreateCameraCapture(0);
if (VideoCapture.ptr == IntPtr.Zero)
{
MessageBox.Show("badtrip ah!!!");
return;
}
btnVideo.Text = "Stop Video";
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT, 320);
highgui.CvQueryFrame(ref VideoCapture);
vidWidth = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH);
vidHeight = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT);
picBoxMain.Width = (int)vidWidth;
picBoxMain.Height = (int)vidHeight;
timerGrab.Interval = 42;
timerGrab.Enabled = true;
}
else
{
btnVideo.Text = "Start Video";
timerGrab.Enabled = false;
if (VideoCapture.ptr == IntPtr.Zero)
{
highgui.CvReleaseCapture(ref VideoCapture);
VideoCapture.ptr = IntPtr.Zero;
}
}
}
private void timerGrab_Tick(object sender, EventArgs e)
{
frame = highgui.CvQueryFrame(ref VideoCapture);
if (frame.ptr == IntPtr.Zero)
{
timerGrab.Stop();
MessageBox.Show("Wrong");
return;
}
imgMain = cxcore.CvCreateImage(cxcore.CvGetSize(ref frame), 8, 3);
cxcore.CvCopy(ref frame, ref imgMain);
cxcore.CvFlip(ref imgMain, 0);
picBoxMain.Image = highgui.ToBitmap(imgMain, false);
cxcore.CvReleaseImage(ref imgMain);
}
}
}
i have this code. but when i run this. the screen when running is always black. it does not view any picture but always black screen.
i need your help masters. i dont know what to do. (
|
|
|
|
|
Don't repost the same question just to bump it up. What you should do is step through the code in the debugger and determine where it is not giving the results you expect.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
There are a number of threads on StackOverFlow in which people disagree about the possibility of truly sorting a "standard" .NET Generic Dictionary: i.e., not an instance of the .NET SortedDictionay. Given that a .NET Dictionary is implemented with the use of Hashes for fast look-up, those who believe it cannot be ordered describe that, and the statements by Microsoft about "no guarantee" of a specific order, as the reasons sorting is not possible.
In this code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace Nov2_CustomShape
{
public class RandomizedDictionary
{
private Dictionary<int, int> randomDictionary;
public Dictionary<int, int> sortByKeyAsc;
public Dictionary<int, int> sortByKeyDesc;
public Dictionary<int, int> sortByValueAsc;
public Dictionary<int, int> sortByValueDesc;
private Random rand1, rand2;
private int i, j;
public RandomizedDictionary(int nKeyValuePairs)
{
randomDictionary = new Dictionary<int, int>();
rand1 = new Random((int)DateTime.Now.Ticks);
Thread.Sleep(100);
rand2 = new Random((int)DateTime.Now.Ticks);
while (randomDictionary.Count < nKeyValuePairs)
{
i = rand1.Next(0, nKeyValuePairs);
j = rand2.Next(0, nKeyValuePairs);
if(randomDictionary.Keys.Contains(i) || randomDictionary.Values.Contains(j)) continue;
randomDictionary.Add(i,j);
}
sortByKeyAsc = randomDictionary.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
sortByKeyDesc = randomDictionary.OrderByDescending(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
sortByValueAsc = randomDictionary.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
sortByValueDesc = randomDictionary.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
}
}
} A Dictionary with a specified number of Key-Value Pairs is created where each Key is taken at random from the range #0 to the number of Key-ValuePairs minus one, and the Values are also randomly assigned from the same range: no duplicates are allowed for the Values.'
If you test this:
RandomizedDictionary testDictionarySort = new RandomizedDictionary(1000); and examine the four sorted Dictionaries exposed by the Class, they appear (so far, in my tests) to be sorted as expected.
I'm curious to know if you agree with the opinion of those that believe you cannot rely on a Generic Dictionary, sorted via Linq, to be, in fact, sorted.
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|