Conver .bat file to C# application, I m new to C# and i would like to see how this is done.

set x=Folder
xcopy /y /v /e .\%x%\* \\10.0.0.200\d\
for %%y in ( 202 203 204 205) do (
net use \\10.0.0.%%y\e Password1 /user:User1
echo Copying files to \\10.0.0.%%y\e\
xcopy /y /v /e .\%p%\* \\10.0.0.%%y\e\
)

Hi
csharplearner1,
Please refer to this reply from "herenvardo". Here it is a good response.
I am referring from Convert batch file to C#.
<copied>
The answer to your question would be both yes and no. If your goal is to build a C# program that performs the same task as your batch, sure, it can be done and it shouldn't take too much work. If what you're looking for is some kind of "magical"
translator that would do this work for you, I don't know any tool able to do that, and don't even hope such a tool exists.
The main points you need to care about are:
Since batches are by definition console-based, you'll be doing a console application. When you create a new Console Application project, the Visual Studio IDE will take care of some things four you, leading you to a .cs file with some code already on
it. Once you're there, you'll have to add your code inside the Main function (unless you need to create more functions, but in the case of a simple script like yours, I don't think that would be needed).
Instead of invoking DOS commands, such as xcopy, you'll be calling different .NET methods.
Unfortunately, there is no direct equivalent to xcopy: you'll need to iterate the entire directory tree manually. You should take a look at
https://msdn.microsoft.com/en-us/library/cc148994.aspx
to get a glimpse on simple file operations, and at http://msdn.microsoft.com/en-us/library/bb513869.aspx for two different ways to iterate directory trees (I suggest the recursive approach of the first example, unless the volume of files on your dir is
huge enough to make it crash).
For the case of echo, you'll be using Console.WriteLine.
You are using a different language, so the syntax will also be diferent. If you're just starting with C#, don't worry too much if you get a lot of "; expected" error messages (or any other) on your first try: just read the error messages and
correct the mistakes. If the message doesn't help you enough, right-click it on the error list and select "Show Error Help". If still you don't know how to solve it, ask about the specific error on these forums.
If you have some experience in C#, then this conversion shouldn't be much of a challenge. And if you don't, it's a great chance for you to learn a lot without too much effort.
</copied>
In addition, about net use command, I would suggest you could  use WMI and the classes from the System.Management namespace.
ConnectionOptions connection = new ConnectionOptions();
connection.Username = "username";
connection.Password = "password";
connection.Authority = "ntlmdomain:DOMAIN";
ManagementScope scope = new ManagementScope(
"\\\\"+IPAddress1+"\\root\\CIMV2", connection);
scope.Connect();
For more detailed information, please refer to
How To: Connect to a Remote Computer 
Best  regards,
Kristin
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still us

    Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still use Flash Player...
    Is there anyo who can help me with this? I asked in the shop and I was told "yes of course" , but when I contacted Sony directly I was advised to check with Adobe as apparently in the recent months Adobe and Sony haven't been getting along anymore...

    You may be mixing up two entirely different Adobe products.
    1. Adobe Flash Player. Needed to view web pages designed with Flash. Not needed to view PDF files. Not available for Android (not just Sony).
    2. Adobe Reader. Reads PDF files. However, the Android can also read most PDF files without needing Adobe Reader.

  • I just recently downloading a file with xpi and i am not able to open it with windows and i would like to know how do i download the exi onto firefox addon

    I just recently downloaded a xpi and i head that it is an addon for firefox and i couldnt open it and i would like to know wat do i use to open it with.

    Go to Tools -> Add-ons (CTRL+SHIFT+A) -> Click settings button on the top ->
    Select Install Add-on From File... option. Locate your .xpi file and Firefox will automatically install the add-on.

  • HT2506 every time i open an image or PDF file using preview the mac take a long time to load and opens every single file the usually opens with PDF at the same time after a noticeable delay i would like to know why and i would like to know how i can avoid

    every time i try to oppen a file like an image or a PDF it oppens by default using oreview built in appliction
    occasionally this is accompanied by a long delay after wich the preview oppens every file in the downloads  folder and i can navigate through them with ease
    i would like to know why the application has this elay i really want to avoid it
    because every tome i want to oppen an image there is a risk it would take a minnute or two

    In the finder right click on the iPhoto library and show package contents, find the folder named import (or importing) and drag it to the desk top. Do NOT make any other changes of any sort. Launch iPhoto and you will Be fine. Open the import(ing) folder and if there are any photos in it you need import them to iPhoto then trash the imoort(ing) folder.
    LN

  • The bar that says "File, Edit, View, History, Bookmarks, Tools, help" has disappeared and I would like it to appear all the time.

    Near the top of the screen on the left side, the words "File, Edit, View, History, Bookmarks, Tools, help" does not appear consistently. Sometimes if I hit "alt" they will appear. I would like to keep those words to appear constantly. Let me know what I can do. Thanks

    See '''<u>Menu Bar</u>''' below.
    '''<u>Menu Bar</u>''' (File, Edit, View, History, Bookmarks, Tools, Help)<br /> Firefox 3.6.x versions allow the user to hide the Menu Bar.<br />
    *Tap the ALT key or the F10 key, Menu Bar will display, click View, click Toolbars, click Menu Bar to place a check mark next to it, '''''OR'''''
    *Press and hold the ALT key while pressing the letters VTM on your keyboard, then release the ALT key
    *See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missing
    '''<u>Other Toolbars</u>''', see: https://support.mozilla.com/en-US/kb/Back+and+forward+or+other+toolbar+items+are+missing<br />
    '''<u>Status Bar</u>''': click View, click Status Bar to place a check mark<br />
    '''<u>Full Screen Mode</u>''': If you have no Toolbars or Tab Bar: Press F11 (F11 is an on/off toggle). See: http://kb.mozillazine.org/Netbooks#Full_screen<br />
    Also see: http://kb.mozillazine.org/Toolbar_customization_-_Firefox#Restoring_missing_menu_or_other_toolbars
    <br />
    '''Other issues that need your attention'''
    The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post. You can also see your plugins from the Firefox menu, Tools > Add-ons > Plugins.
    *Adobe PDF Plug-In For Firefox and Netscape "9.4.1"
    **New Adobe Reader X (version 10) with Protected Mode was released 2010-11-19
    **See: http://www.securityweek.com/adobe-releases-acrobat-reader-x-protected-mode
    *Next Generation Java Plug-in 1.6.0_16 for Mozilla browsers
    **7 updates behind
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
    #**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
    #***Choose your OS
    #***Choose the latest #.x version (example 9.x, for version 9)
    #***Choose the highest number version listed
    #****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
    #***Choose your language
    #***Download the file, SAVE it to your hard drive, when complete, close Firefox, click on the installer you just downloaded and let it install.
    #***Windows: choose the .exe file; Mac: choose the .dmg file
    #*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
    #**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Just got my Mac air and i would like to make a file to store some web addresses for my new business with rodan and fields and I can't do it. Made the file but i cant copy and paste the web addresses in the file to save them. Please help and thank you.

    Yes - well you have to make the file in a word processing Application.
    You could use TextEdit (it's free) Pages (words only), or Numbers (data base) (they are part of iWorks - and may or may not be free (included) on your machine.  You could use MS Office (it is not free) You could use any Open source word processor that plays well with Office (NeoOffice, StarOffice) they are free.
    That's how you create content and copy/paste URLS. Then you save the file to the desktop. If you are going to make more than one file... you make a folder on the desktop and save, or drag the file(s) into it.
    You attach it to your e-mail client which will compress it and e-mail it. An excellent reference is to use Help, from the menu bar, also from inside any application. From your library or book store the OS X for Dummies has a lot of useful information (you don't read it cover to cover but look up chapters about what you'd like to do)
    You can also make appointments at your local Apple store for individualized help (if a store is nearby)

  • I have recently purchased MacBook Pro with Mac OSX 10.7.3 Lion and I would like to install Final Cut Pro 6 Studio2, and it came up with this error: 'you can't open application FinalCutProStudio.mpkg because PowerPc apps are no longer supported..pls advise

    I have recently purchased MacBook Pro with Mac OSX 10.7.3 Lion and I would like to install Final Cut Pro 6 Studio2, and it came up with this error: 'you can't open application FinalCutProStudio.mpkg because PowerPc apps are no longer supported......Is there a way to run FCP6 on lion withoput this error? Any help would be appreciated.....

    Hi Shane,
    Just one more quesiton re: this topic, I am looking to get rosetta but do not have Leopard or Snow Leopard...
    I read that it is not on Snow Leopard only on Leopard....so do I need to get only Leopard? Can u advise?
    Alternatively I do have Mac OS X Tiger so is it on this and can I install it from here?
    Please excuse my lack of knowledge here, just trying to get my FCP 6 up and running asap....
    Best Rgds.

  • I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?

    Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?

  • How do I get the sync of my 3GS on my computer to transfer everything (files, apps, etc.) to my new iphone4?  And then how do I move the sync to a newer computer so I can sync the new phone with the new computer?

    How do I get the sync of my 3GS on my computer to transfer everything (files, apps, etc.) to my new iphone4?  And then how do I move the sync to a newer computer so I can sync the new phone with the new computer?
    My 3GS is dying and it's synced to an older computer.  I have tons of datafiles as well as apps, music, text messages, etc. that I need to get moved to the new iphone4 I'm getting.  Then I need to move the sync to a newer computer so that I can sync the new phone and new computer.
    I understand how to get my apps to transfer to a new pc.  That's not the issue.  It's getting ALL the data from the 3GS to the 4 and then to a new computer.
    Thanks.

    Thanks much, that's very helpful for step one (getting old phone onto new phone).  Very clear. 
    However, I still have the problem of moving to the new computer.  How do I move the sync to the new computer after the new phone is set up?

  • Trying to install MS Office 2011 for Mac SP 2 on my Macbook Air (Lion 10.7.3). I have to close Microsoft Database Daemon and SyncServicesAgent but can not see how to do so.  I have closed all applications.  Can anyone help? Many thanks

    Trying to install MS Office 2011 for Mac SP 2 (14.2.0) on my Macbook Air (Lion 10.7.3). I have to close Microsoft Database Daemon and SyncServicesAgent but can not see how to do so.  I have closed all applications.  Can anyone help? Many thanks

    Thanks Kurt!  I had tried all that and had tried closing both programmes from the application monitor, but SyncServices Agent refused to close.  I tried closing Launchd which is their mother application, but that just caused the screen go go blank.  In the end the two programmes let themselves be closed next time I tried the installation process so all was well.  Thanks for your help!

  • I recently upgraded to 10.8 from 10.6 and I would like to be able to see the folder/file size for each like in version 10.6

    I recently upgraded to 10.8 from 10.6 and I would like to be able to see the folder/file size for each, like in version 10.6. It used to show the size at the bottom of the "window" for the selected folder,drive etc.

  • I would like to know how i can share my music using an UPnp protocole. I have an Imac but when i'm chosing the option share my file i can connect my mac to another network reader . it seems that the protocole used is not UPnp. I need this to be in UPnp.

    I would like to know how i can share my music using an UPnp protocole. I have an Imac but when i'm chosing the option share my file i can connect my mac to another network reader . it seems that the protocole used is not UPnp. I need this to be in UPnp. does somebody can help ?

    Google "upnp mac"

  • I have just received my Ipod 7th generation. I would like to ask how I can download music and music video.  I have downloaded the Itunes application on my pc which is not a Mac

    I have just received my Ipod Nano 7th Generation and would like to know how to download music and music videos to it. I have downloaded the Itunes application to my Pc which is not a Mac

    See this -> http://support.apple.com/kb/HT1386

  • Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO

    Is there a way to sort a PDF file with multiple pages by a specific field within the PDF? All pages have the same invoice format and i would like to sort by a field within and then print the documents. (Vendor, PO#, Date, ect.)

    When you say field, do you mean specifically a form field, such as a text field? Or is the information regular text on the page?

  • How can I get a ai. file? I've made a drawing for a company who would like to use it on a shirt. But they need the ai file. I made it with adobe illustrator for ipad.

    How can I get the ai. file? I've made a drawing for a company who would like to use it on a shirt. But they need the ai file. I made it with adobe illustrator for ipad.

    Unfortunately logging into your account won't help, because then I don't have access to Illustrator.
    I was just trying around a little if you could share it with me, but unfortunately sharing doesn't seem to work with Draw files. You could try and find someone near you who also has an iPad and Illustrator and then try to send it to them via AirDrop. But I don't know if that actually shares the file or just a PNG.
    Maybe someone on the Draw forum has an idea how you could send the file to someone else.
    Adobe Illustrator Draw

Maybe you are looking for

  • Emails not sending, "stuck" in the outbox and no error message

    I have been trying to send emails for a few days now and they will not send. They go to the outbox file and then the don't leave. There is no error message and my POP account, .mac account, and the smtp.mac.com are all working correctly. I can still

  • Isuue in HCM Process and Forms

    Hi All, Before i mention about the issue i am facing i would like to  brief about my process.  In HCM process and forms i have a form where HRPB will modify the position and submit it. CDT will approve the request, which updates the records in back e

  • Pass values from one Taskflow to another

    JDev 11.1.1.5.0 ADF BC Use case: Need to pass values between two bounded taskflows. There are two different pages on two different taskflows and I need to pass values from one to another.

  • What do you do if you acccidently scratch off the code on the itunes card?

    i was just scratching off the code label thing off my ituns gift card, and some numbers and half numbers were missing. Could i somehow still use the card?

  • DVD-R Auto-ejects and not burn

    I am in the middle of a stack of Mitsui DVD-Rs and now the Pioneer 109 will not burn from an Apple or a Toast disc image, and after several seconds auto-ejects all the remaining discs in my stack. DVDs and CDs of any kind can be read and CDRs can be