Remotely editing text files in Windows WinRM/PSExec/Powershell/cmd

Hi!
How can I remotely edit a text file in Windows?
I am running and administering a number of Windows 7 workstations and Windows Server 2012 machines. I would like to be able to remotely edit text files on any of these machines. I can connect to any of these machines via psexec or powershell remoting. I
can also connect via rdp, but for the workstations I would rather not kick the user off unless I absolutely have to.
For example, we manage state configuration using
Salt. Local configuration files are stored in C:/salt/conf. I would like to be able to edit these config files on the fly.
This question on Stack Overflow covers the same topic, but none of the answers are particularly satisfying. Some of the possible solutions
are:
Remote Desktop: as I say, I would rather not have to kick a user off their workstation
Edit a file over a UNC path: this only works for files on a share, and setting up arbitrary shares for quick edits seems like a bad idea.
Install some manner of ftp or ssh server on all the target computers. This would certainly work, but it is it necessary with WinRM already active? I feel like installing and configuring extra software across all the machines in my organisation would be
a last resort.
Edit with a command line editor (e.g. vim, emacs) over a remote powershell session. This doesn't work. I don't understand the technical details, but a powershell remote session isn't interactive in the same way that ssh connections are.
Edit using powershell's -replace operator, out-file and add-content cmdlets. This works, but is hardly the same as a fully featured text editor.
Retrieve content from the remote, edit locally, and post back to the remote. This works, and is arguably the best solution I've found. Code sample from SO:
PS C:\Users\Meredith> Invoke-Command -Session $ps -ScriptBlock {get-content c:/inetpub/myapp/web.config} > web.config
edit web config
PS C:\Users\Meredith> get-content web.config | Invoke-Command -Session $ps -ScriptBlock {set-content c:/inetpub/myapp/web.config}
The last two options are the workflow that I've been using for now. Regex replacement for very simple changes, and copying to local and editing there for more complicated ones. Neither is ideal, but they work. It just feels incredibly old fashioned.
I'm considering writing a plugin to my editor of choice (vim) to perform the remote fetch and save, to make my workflow a little bit smoother. Before I try that, I just want to know if there's anything that I've missed, or misunderstood.
Cheers

What is the "redirector"?
I posted the same question to Stack Overflow, and was told about administrative shares. I wasn't aware of this, and it's exactly what I wanted. I can open the filetree of a remote machine with the path \\machinename\c$\. Perfectly simple, now that I know
the answer.

Similar Messages

  • How to check authorizations of a text file in windows server while accesing

    hi,
    I have to access a text file from windows server like windows NT/2003 in to SAP server through report program.
    While accessing the file i have to check the authorization of that file access users of windows.And i have to read it into SAP report program.
    Regards,
    Shankar.

    hi,
    Thanks for Immediate reply.
    i have to check this at level of windows login details i.e user name  and file acces permissions to login user.  through abap coding i have to check it  weather the windows login user having authorizations to access that file are not. If he is having authorization to access then that text file has to read in to ABAP report program and it has to be used in program. other wise it has to be raise an error message
    if provide some example with code...it will be very help full to clear my problem.
    Thanks & Regards,
    Shankar.
    Edited by: Shankar  Reddy Chamala on Aug 26, 2008 8:55 AM

  • Difference in reading a text file in Windows & Unix

    I have a code which is working fine in windows but is stopping after reading the first line of a text file in
    Unix. The code is something like below:-
    declare
    file_handle text_io.file_type; /*running form*/
    filename varchar2(60);
    v_line varchar2(200);
    begin
    message('before fopen');
    filename:=:file_name;message(filename);
    file_handle:=text_io.fopen(filename,'R');
    loop
    begin
    text_io.get_line(file_handle,v_line);
    --:line:=v_line;
    exception
    when no_data_found then
    text_io.fclose(file_handle);
    message('NO MORE DATA IS FOUND ');
    temp:='stop';
    exit;
    when others then
    text_io.fclose(file_handle);
    message('ERROR ');
    exit;
    end;
    mob_no:=substr(v_line,1,10);
    begin
    message(' Mobile NO is '||mob_no);
    message(' Mobile NO is '||mob_no);
    exit when temp='stop';
    end loop;
    commit;
    message('File SUCCESSFULLY LOADED........');
    message('File SUCCESSFULLY LOADED........');
    end;
    Is there any difference in reading a text file in Windows & Unix.
    I hope, my question is clear. Please help in solving the doubt as it is urgent.
    Regards.

    There is no difference in reading a file - you use TEXT_IO in the normal way. However there is of course a difference in the format of text files between Unix and Dos so if you had say transferred your test file from Dos to the Unix box for testing strange things might happen if you had not transferred in ASCII mode.

  • Editing text file on application server

    Hello,
    I have created a utility in which I can move files from one folder to another. Now we also need a option by which I can edit text file on the server folders. Is there a function module by which I can edit text from application server ?
    Regards,
    Rajesh.

    With OPEN DATASET and READ you can load them into an internal table. Next put them on screen in lets say the text editor (enjoy SAP Controls). This is one way of doing this, other way would be:
    Upload data with OPEN DATASET into internal table, download file to local drive (cl_gui_frontendservices=>gui_download), open it with notepad (for example) edit it and save. Next upload file into your program (cl_gui_frontendservices=>gui_upload) and download it to server again (OPEN DATASET and TRANSFER).
    If available you can also use transaction CG3Z and CG3Y.

  • Using pico or nano to edit text file in ssh connection to remote osx host

    Hi everybody!
    I can not get thru to a point when I'll be able to edit files on a remote osx comuter with pico or nano editors. When I connect thru ssh and start pico it says
    Error opening terminal: network
    I am a newbie to Unix beast. Vi is too complex for me.
    Thanks,
    Maxim
    PowerBook G4 1GHz 12 40GB SD   Mac OS X (10.4.4)  
    PowerBook G4 1GHz 12 40GB SD   Mac OS X (10.4.4)  

    Maxim,
    The problem appears to be the value of your environment variable TERM. It seems to be set to network. It needs to be set to something that pico and nano will understand. Since I do not know what your shell is I need to give you two methods of setting the TERM variable. One of the methods will fail as it is not appropriate for the shell you are using. If it does, don't worry about it just try the other method.
    The first method has two commands. Note: capitalization is significant here. They are:
    TERM=vt100
    export TERM
    If those commands give an error message, use this command:
    setenv TERM vt100
    You should now be able to edit your files.
    I am using a terminal type of vt100 as it is about the simplest terminal type and is supported by just about every unix you might be using to connect to the mac as you do not provide that information.
    Hope this information helps.
    Curt

  • Editing xmp files in Windows

    Windows XP SP2 Pro
    Just read on another forum that it is possible to edit xmp data in a text editor in Windows. If possible, could someone kindly stear me in the right direction for doing this or post a link.
    I took a few dozen shots the other day and for some reason or other when imported into LR 99% of them showed up with the correct lens being used in the Metadata browser whilst the remaining 1% were indicated as 'Unknown Lens'. I would like to edit this data if possible so if the above is possible as suggested would appreciate some direction in the way to proceed. Thanks.

    Bogdan
    The situtation is this - last weekend I was asked to do a shoot of a friends daughter at her Church Communion. The shoot was a good result and I couldn't be more pleased with what I captured - the family are also :-)
    For the shoot I used a Canon 30D with an EF 17-40 f/4L USM and shot off countless images. There was no camera or lens change throughout the shoot and all images were shot in RAW.
    Upon Import to LR (only import, no editing done up to this point), the Metadata browser in the left hand panel of the Library indicated that 99% of these images were shot with the camera/lens combination above whilst the remaining 1%, whilst showing the correct camera, were indicated as 'Unknown Lens'. This may or may not be a corruption of the impregnated EXIF data within the RAW file itself but in this regard is not important.
    My gaol was to change the 'Unknown Lens' entry in the Metadata entry to reflect the lens actually used. To this end I first Exported an xmp file, opened the file, found where unknown lens was indicated and substituted it for the lens used. I first checked another xmp with the correct info shown to ensure that I typed the correct data in precisely in the format as shown in the referenced file. I then saved the modified xmp file, went back to LR and 'Removed' the RAW image from the Library. Following this I Re-Imported the image and imported the xmp file just in case it hadn't been brought in at the same time as the RAW file.
    Unfortunately, when highlighting this RAW image in the Library the Metadata browser panel still indicated the lens used as being 'Unknown'. I checked back in the xmp file and that still reflected my changes e.g. no mention of unknown lens and the correct lens being shown. I can only assume from this that upon Import of the .CR2 file into LR, LR is giving priority to the EXIF data buried deep within the .CR2 file itself and only takes data from the xmp file that is not contained within the EXIF file. I am no expert in these matters and therefore cannot come up with any other reason as to why when the xmp file has been corrected this is not reflected in the Metadata browser window in LR.
    This is certainly not the end of the world but it is something that would obviously be desirous if this problem keeps on repeating itself. If LR is to show 'statistics' of Cameras and Lenses used etc then for it to have worth it must reflect accurate data. Not that I am suggesting for one moment that this is a failure within LR itself you understand.
    Edit: Forget all references made to Camera model e.g. 30D/20D which may be confusing the issue. It was just that when I failed in my attempts to change the 'Unknown' lens entry to the correct data that I then attempted to see if it was possible to change any other data e.g. Camera model. This too was unsuccessful, but as stated can be dismissed as it is not the important issue here as is the case for the lens used and was only done for experimentation purposes.

  • Read and Edit Text Files

    I wanted to find out if there is a way to read linux
    configuration files, edit parameters in them and save them using
    coldfusion. I know PHP has the capability to do this, but I don't
    know if CF does and how powerful it is.

    If it's plain text, just write it into a textarea and let
    your users edit it there. When they submit, use cffile to overwrite
    the text file.
    There are other ways to allow users to edit text in a web
    app, such as the "contenteditable" attribute in IE, but the basic
    idea remains the same.
    Or do you mean that the app will alter the files
    automatically? If that's the case, then regular expressions would
    likely be the way to go.

  • EDITING TEXT FILE

    anyone here know how to edit a text file
    i can open the file and i try println it adds to the already content of the file
    i was thinking of EDITING THE FILE
    i mean changing some parts of the files
    example i could always change line #2 if it contains data about AGE
    somehing like that

    i was thinking of EDITING THE FILE
    i mean changing some parts of the files
    example i could always change line #2 if it contains
    data about AGE
    somehing like thatThe easiest way is to read the whole file, line by line, and store the lines in a String array. Then change the lines in the array. Finally, overwrite the file with the lines in the array.
    Unfortunately, there is a slight problem with doing that. Suppose you write the first line to your file. That will delete everything in the file. But then suppose your program crashes. Poof! You will lose all your data except the one line you wrote to the file.
    So to be safe, you need to write to a new file, and when you are done, delete the old file and then change the name of the new file to the old file name. Creating File objects for your files will provide the means for doing that.

  • Can load text file in Windows - not on the Mac?

    I have some code that loads a text file into an array that works fine in windows, but fails on the Mac  I'm sure it's a path issue but I've spent several hours trying to work this out.
    Windows code works fine:
        var textPath =  "c:\\temp\\textfile.txt";
         try {
            var myFile = File(textPath);
            var mymenuItems=[];
            var menuItems=[];
            myFile.open('r');
            while(!myFile.eof){
                mymenuItems.push(myFile.readln());
            myFile.close();
    Mac Code Fails
      var textPath = '/User/wizbowes/Desktop/text.txt';
         try {
            var myFile = new File(textPath);  //tried both with and without new - same effect
            var mymenuItems=[];
            var menuItems=[];
           myFile.open('r');
       while(!myFile.eof){
                mymenuItems.push(myFile.readln());
    When debugging on the mac myFile.eof shows true straight after I open the file and therefore never enters the loop to populate the array
    What on earth am I doing wrong?

    1. For files on your desktop you can use a shortcut.
    var textPath = '~/Desktop/text.txt';
    2. Make sure the file object is valid before you open for reading. The new keyword is not really needed it just make clear in the code that you are creating a new file object. However just creating a file object does not means that the file already exists. You could have an invalid path.
    try {
            var myFile = new File(textPath);
            if(myFile.exists){
               // rest of the code
    3. If you don't want to check that the file exists you could check the return of the file.open() method. It should return true if it opened the file when opening an existing file.
    var openSuccess = myFile.open('r');
    if(openSuccess){
        // some code that reads from the file here

  • How to edit Text Files?

    Hi,
    I have a text file with sample data like this.
    Nokia|25
    Motorola|30
    LG|20
    Samsung|50
    Sony|25
    I will get an argument like ‘Nokia’. I need to compare it with the data in the file. If I find a matching record in the file, I need to decrement the quantity, i.e 25 in this case(Nokia) and display a message in the screen.
    Can someone tell me how this can be achieved?
    Thanks.

    Thanks for your reply. You have mentioned "When an update happens flush the list of items back to the file. ". If I am going to write it back to the same file, it will get appended right?. I need to update the file. Do you mean to say that i delete the existing file and re-create it and then flush the contents into the file?
    I have just started coding in Java. So if incase you feel my question is absurd, please excuse me.

  • Quicktime Pro to edit 3g2 files for Windows?

    Hello - I have .3g2 videos that I took with my cell phone camera. These will play on my computer (Windows Vista) with Quicktime player but in Windows Media Player the audio is missing. Will Quicktime Pro allow me to convert these files and also edit them? I cannot edit in Movie Maker (will not open .3g2 files). I have tried some freeware conversion software but nothing works very well. Thanks!
    Steven

    If the files play in the free QuickTime Player then the Pro upgrade can edit and convert them.

  • Editing text files

    Im trying to write a program that opens many files .def and should replace every / with \.
    but I'm encountering problem with the method that has to replace the character in the file.
    first attempt:
    public void changer(String pathFile){
         try{
              RandomAccessFile toEdit = new RandomAccessFile(new File(pathFile), "rw");
              String line = "";
              while(line != null){
                   riga = toEdit.readLine();
                   String newLine;
                   newLine = line.replaceAll("/", "\\");
                   toEdit.writeChars(newLine);
              toEdit.close();
         catch(IOException e){
              System.out.println(e.getMessage);
              System.exit(1);
    }this throws an exception java.lang.StringIndexOutOfBoundException: String index out of range: 1
    exception in thrown by replaceAll method.
    second attempt:
    public void changer(String pathFile){
         try{
              RandomAccessFile toEdit = new RandomAccessFile(new File(pathFile), "rw");
              String line = "";
              while(line != null){
                   riga = toEdit.readLine();
                   String newLine;
                   for(int i = 0; i<line.length(); i++){
                        if(riga.charAt(i) == '/'){
                             newLine = line.replace('/', '\\')
                             toEdit.writeChars(nuovaRiga)
                        else
                             continue;
              toEdit.close();
         catch(IOException e){
              System.out.println(e.getMessage);
              System.exit(1);
    }this throws an exception java.lang.NullPointerException
    thrown by length() method.
    problem 2: both method don't replace line with newLine but just write newLine after line in the text.
    I've read the api documentation for RandomAccessFile but I haven't found a method that really substitute the line or only the char.
    any suggestion?

    No, you are never reading a second line, you read into riga, which you ignore.oh, sorry, that was an error in copying/translating my code.
    here's the correct one.
    public void changer(String pathFile){
         try{
              RandomAccessFile toEdit = new RandomAccessFile(new File(pathFile), "rw");
              String line = "";
              while(line != null){
                   line = toEdit.readLine();
                   String newLine;
                   newLine = line.replaceAll("/", "\\");
                   toEdit.writeChars(newLine);
              toEdit.close();
         catch(IOException e){
              System.out.println(e.getMessage);
              System.exit(1);
    public void changer(String pathFile){
         try{
              RandomAccessFile toEdit = new RandomAccessFile(new File(pathFile), "rw");
              String line = "";
              while(line != null){
                   line = toEdit.readLine();
                   String newLine;
                   for(int i = 0; i<line.length(); i++){
                        if(line.charAt(i) == '/'){
                             newLine = line.replace('/', '\\')
                             toEdit.writeChars(newLine);
                        else
                             continue;
              toEdit.close();
         catch(IOException e){
              System.out.println(e.getMessage);
              System.exit(1);
    }

  • Help about editing text file by QT

    Hi again
    I have faced another problem today >> which is so bad
    see this screenshot to understand the problem : http://qkpic.com/c28fb
    Has anybody an idea about how to solve that ?
    This is a quick review about how to do it : http://www.youtube.com/watch?v=6PS2FOjRCgk
    But it dznt work with me at all !
    i tried it in both ".txt" & "png" files >> it dznt work
    Please if anybody has a solution for this problem ,, i would be grateful a lot
    Thanks in advance
    sc0rpio

    Jon Walker wrote:
    My guess would be, if you tried using a PNG image and this work flow failed, that you neglected to export the PNG file with an alpha channel. You must either create the image file on a transparent background or designate what area of the image is to be made transparent before exporting with the alpha channel.pecifics for doing this depend on the graphic application you use. If using an application like Photoshop, create the image as you normally would and then go to the help menu and follow instructions for exporting a transparent image. Either an PNG or GIF will work.
    @Jon Walker
    Thanks for the reply
    You are right if i am using a picture ,, but let me remind you that i am using a subtitle file ".txt"
    which i opened by Quicktime to merge it with the movie file to get a translated movie.
    Anyway ,, i have converted the subtitle file to a ".mov" file so that i can now open it by photoshop
    it's opened as layers ( about 50 layer ) and i am trying now to edit the first layer and apply then to
    all ,, i hope that it works.
    See this screenshot : http://qkpic.com/32ee6
    i believe that it can be solved directly just by using QT >> i feel there is a simply way

  • Implement the editing text-behavior of window platform via mouse

    Hi,
    I got a JTreeTable. There i want to be able to edit the name of the node. This should work via the same process like in windows where the user click on the node and hover the mouse to the left e.g.
    i know a way to implement it but if there are some "profi"-solutions
    it would be nice to know.
    i would attach a mouse motion and a mouse listener watching for a click on the node and then watching for the direction of moving the mouse...
    is there a nicer way?
    regards
    Olek

    Good thought, I checked this out just to make sure. My table's data is in fact updated upon receipt of network messages, however, all the work is done through an invokeLater() and thus happens on the ED thread.
    Without seeing the code and a process to reproduce the problem, I know I'm not going to get an exact answer, but if anyone else has any ideas of potential causes or places to look, I'm all ears.

  • Keep text edit active when switching windows

    When editing text, switch document windows then return to the original document. The insertion point is gone, or highlighted text is no longer selected. Instead the active text item is selected. If can be quite a nuisance to have to find the text you were editing or had selected. It makes copying/pasting text between documents much harder than it should be.
    This is either a bug or a stupid feature. Illustrator has enough of both.

    I think you mean QuickLook, not Preview. And no, QuickLook is not intended to work that way--it is a way to do just what its name says: provide a quick looksee at the files in an open Finder window.
    As for ideas: why not just open them in iTunes?
    If you don't want to add them to iTunes, you can put the folder with the mp3s into Column View, make sure the box for "show preview column" is checked in View Options, then click directly on the icon for the file in the preview column (as your mouse moves over the icon, you will see the stylish play button appear on top of the icon). It will continue to play no matter what else you are doing.
    Francine
    Francine
    Schwieder

Maybe you are looking for

  • Can no longer WiFi Sync.  iTunes won't connect to devices.

    Since downloading iOS 7 and iTunes 11.1.1 I can no longer WiFi Sync my iPhone5, iPad, or iPod.  Error message states, "iTunes could not connect to this device.  Could not allocate a resource."  What does this mean?  Never had a problem before.

  • Different aspect to extract data from SAP retail.

    Hi Gurus,       I will working on SAP retail system , including SAP retail/POSDM,  please tell me how to extract data from those systems, is it different from  the way to extract data from SAP ECC , eg SD/FICO etc? Many Thanks,

  • Print report.vi for printting the frant panel

    I download a example,now  when i run it ,it can print the frant panel,but there is another dialog .how can i make it disppear . Attachments: dialog.jpg ‏208 KB

  • EC-CS, BPC, BOBJ Financial Consolidation Compare

    What major difference would be there between EPM solutions "BPC" and "Financial Consolidation" as far as consolidation goes? What added advantage do we get compared the original EC-CS in SAP?  How long will EC-CS can be used or supported by SAP?

  • Trying to re install apps

    I had to restore my IPAD and am trying to reinstall some previously purchased apps but they will not install...just say "waiting" I have tried deleting and reinstalling, restarting the iPad...no help..