Expanding %1 and other variables from a command

Hi!
I need a simple command to open a specific file (rasphone.pbk) with whatever is the default program for opening text files.
What I have so far:
(Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\txtfile\shell\open\command').'(Default)'
Which gives me this output:
"C:\Program Files\Sublime Text 2\sublime_text.exe" "%1"
It will be executed for different machines/users. Some may only have the default notepad.exe, others may have different editors.
So I now need to replace the %1 with
%AppData%\Microsoft\Network\Connections\Pbk\rasphone.pbk
while also expanding %AppData%. The default command is
%SystemRoot%\system32\NOTEPAD.EXE %1
where I would need to expand %SystemRoot% as well.
It should be a 1-liner if possible because the command is stored in a database. If I need a script file I have to find a way to distribute that file to each client as well... and for simply opening a file that would be a bit too much.
If it's easy in CMD that would be even better, but I thought Powershell is a capable tool for doing stuff like that in a simple way. I just can't wrap my head around it...
thanks for any help! :)

Use Exanded string to  store variable reference in the registry.
You can do the easily with Regedit. You can export the key and import it on any machine with a click of the file.
Indeed I can replace just the %1 and let the other variables be replaced by cmd.
I actually got it working now without a script file (I really want to avoid using a file). this is the UI I have to work with:
(Remote Desktop Manager)
This is what I use now:
cmd /K powershell -Command "((Get-ItemProperty -Path 'Registry::HKEY_CLASSES_ROOT\txtfile\shell\open\command').'(Default)').replace('%1','%AppData%\Microsoft\Network\Connections\Pbk\rasphone.pbk')" | cmd
It is not pretty... calling cmd to call PowerShell and piping the output back to cmd to execute the command.
I just can't find a way to execute the command including the parameters from a single string in PowerShell.
If you can think of a better way please let me know...
Thanks for the help!

Similar Messages

  • StringTokenizer to read in 4 variables from the command point

    Hi,
    I need to set up the Java StringTokenizer to read in 4 variables
    from a command prompt. It should be in the following format:
    X variable1 variable2 variable3where
    (is the command prompt)X (is either +, -, *, /, c, or e)
    variable1 variable2 and variable3 are integers.
    I would appreciate any answers that would help me find the way!
    Thanks in advance.

    Thank you for the code snippet, but the program does not function that way. Ie, it does not accept
    arguments when the program is first run, only after the program has excecuted.
    The program is to enter a simple command prompt, and await instructions in the form X int1 int2 int3
    where X can be c (convert the number int3 from number base int1 to number base int2), e (exit the
    program), +,-,/,* (add, subtract, divide or mutilply int2 to/by int3 in number base int1). Here is an example
    of the what the program execution should look like:
    c:\programming\java nbc
    > + 10 23 45 // Add 23+45 in base10
    68 // Write the answer on a new line and prompt
    - 16 5A 2C // Subtract 5A-2C in base 162E // Write the answer on a new line and prompt
    c 15 7 2E // Convert 2E in base 15 to base 762
    e // End of programc:\programming\
    My problem is, I do not know how to convert the first token to a variable that can be used to carry out one of
    the above mentioned procedures. For example, the first token taken from the command c 15 7 2E is "c".
    As I understand it, "c" is simply a string, and this cannot be used in logical procedures such as:
    int procedure = 0;
    if(operator == "c")
         procedure = 0;  //then use this variable
    }else
    if(operator == "e")
        System.exit(0): //quit the program
    Also, how can I set up a while loop to continuesly
    prompt the user for an instruction until "e" is entered?import java.io.*;
    import java.util.*;
    import java.util.StringTokenizer;
    public class blerk
         public static void main(String[] args) throws IOException
              InputStreamReader stdin = new InputStreamReader(System.in);
              BufferedReader br = new BufferedReader(stdin);
              boolean e = true;
              String str = "";
              String symbol = "";
              int value0 = 0;
              int value1 = 0;
              int value2 = 0;
              System.out.print(">");
              str = br.readLine();
              StringTokenizer st = new StringTokenizer(str, " ");
              int i = 0;
              int option = 0;
              while (st.hasMoreTokens())
                   switch(i)
                        case 0:
                             symbol = st.nextToken();
                             // This part is obviously not correct. How can this be implemented to select and store the operating procedure the user enters?
                             if(symbol = "e")
                                  System.exit(0);
                             }else
                             if(symbol = "c")
                             }else
                             if(symbol = "+")
                                  option =
                        break;
                        case 1:
                             value0 = Integer.parseInt(st.nextToken());
                        break;
                        case 2:
                             value1 = Integer.parseInt(st.nextToken());
                        break;
                        case 3:
                             value2 = Integer.parseInt(st.nextToken());
                        break;
                        default:
                             System.out.println("format: >operator x y z");
                        break;
                   i++;
              System.out.println(symbol + value0 + value1 + value2); //test
    Any advice would be most appreciated.
    Benjamin.

  • Sliders over opacity and other variable slider settings in appearance palette

    just like Photoshop, for a lot of controls, one can hover over the word like "opacity"in layer palette and slide to adjust opacity
    was hoping for the same in AI, for opacity and other variable sliders in AI.
    saves clicking opacity and clicking the slider, then sliding, 3 steps instead of 1.

    This is another feature I miss from CS5. I would request as well that the sliders be put back into the illustrator CS6 palattes as they were in earlier versions. In the general illustrator discussions area there is a stream entitled "AI CS6 took away the opacity sliders" which discusses this and mentions just using the arrow keys but the point is made that sometimes as a designer we are looking for a visual relationship which is much easier and quicker to do with the sliders. (Time is always a factor.)

  • I am considering buying an iPad 3. I have an iMac with OSX 10.6.8. On the iMac I have many photos and work with iPhoto and Photoshop Elements on the computer. Can I interchange or transfer photos and other work from the iMac to the iPad? How?

    I am considering buying an iPad 3. I have an iMac with OSX 10.6.8. On the iMac I have many photos and work with iPhoto and Photoshop Elements on the computer. Can I interchange or transfer photos and other work from the iMac to the iPad? How?

    velma Monreal wrote:
    I am considering buying an iPad 3. I have an iMac with OSX 10.6.8. On the iMac I have many photos and work with iPhoto and Photoshop Elements on the computer. Can I interchange or transfer photos and other work from the iMac to the iPad? How?
    Yes you can. In iPhoto create a Album with the photos you want in it. You can drag them from your Events folder. In iTunes with your iPad connected go to Photos by cliking on your iPad. You can then select the album or events you want.

  • HT3702 Why can't I download my already purchased music and other files from iCloud, even though I owe money to iTunes for my most recent purchases.  Doesn't seem right that they keep me from accessing those files which I've already paid for!

    Why can't I download my already purchased music and other files from iCloud, even though I owe money to iTunes for my most recent purchases.  Doesn't seem right that they keep me from accessing those files which I've already paid for!

    - Are you saying that they are not listed in your Purchased section?
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    - Are they listed in your Puchases history when you log into your account on your computer?
    - Are they still available now for purchase? If not then you are out of luck
    If they are still available and listed in your Puchase History then contact iTunes
    http://www.apple.com/support/itunes/

  • Trying to move my iTunes Music and other media from the main drive on my pc to an external hard drive but iTunes is not recognizing the new file location?  Ideas?

    Trying to move my iTunes Music and other media from the main drive on my pc to an external hard drive but iTunes is not recognizing the new file location?  Ideas?

    Hello there, Underwriter.
    The following Knowledge Base article provides in-depth instructions on how to migrate your content to an external drive:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/ht4527
    Particularly of note for your situation:
    External drive
    This option requires more work than Home Sharing, but it creates a backup of your iTunes library on the external drive in addition to moving your content.
    Notes before you start:
    You can use most iPods as an external drive.
    Windows operating systems don't recognize Mac OS-formatted disks (HFS or HFS Plus formats). Because of this, you can't use a Mac-formatted iPod or external drive to move your music to a Windows PC. See iPod: How to determine iPod's hard disk format if you're not sure how your iPod is formatted.
    Mac OS X can read Windows-formatted iPods and drives. This means there are many ways to migrate your information from your old Windows-based PC to your new Mac.
    Mac OS X: To be sure external drives appear on your desktop, choose Preferences from the Finder menu. Be sure the options for "External disks" and "Hard disks" are enabled.
    Part 1: Locating and consolidating the iTunes Media folder
    Part 2: Copy iTunes folder from the old computer:
    Part 3: Get iTunes ready on your new computer
    Part 4: Back up any music that's already on your new computer
    Part 5: Copy music to your new computer
    Part 6: Add preexisting music that was on the new computer back into the library
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • How do I transfer my photos and other items from the cloude to my Dell desktop

    How do I transfer my photos and other items from the cloud to my Dell
    desktop

    Hello johnfromwildomar,
    Thank you for using Apple Support Communities.
    You can use the following articles to help you set up to share photos from iCloud to your computer.
    iCloud: Set up My Photo Stream
    iCloud" My Photo Stream FAQ
    Regards,
    Jeff D. 

  • Removing address and other functionalities from a window

    Hi,
    I want to remove the address bar and other functionalities from the browser of an external window called from webdynpro. Could you tell me how to do this.
    Regards,
    Jayant.

    Hi,
       Something like this:
    //Do this before opening the window.
    IWDWindow win = wdComponentAPI.getWindowManager().
    createNonModalExternalWindow("url","title");
    win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
    //Check out the WDWindowFeature class for more features.
    Regards,
    Satyajit.

  • I have followed "Importing favorites and other data from Internet Explorer" but although I've worked through the dtages and it says it has worked, the expected internet explorer folder does not appear in bookmarks

    I have installed Firefox today, and like the look of and the speed. But I have an extensive set of foldersin my IE Favorites and remebered passwords I don't want to have to reimput.
    I have now tried twice folowing "Importing favorites and other data from Internet Explorer " which seemed to go smoothly, once with IE open and the other with it closed, and closed down my PC between each attempted installation. Any ideas?

    It usually works better if you export the Favorites in IE to an HTML file and import that file in the Firefox Bookmarks Manager.
    * Export the favorites in IE to an HTML file (bookmarks.html): File > Import and Export
    * Import the HTML file in Firefox: Bookmarks > Organize Bookmarks > Import & Backup > Import HTML: From File
    See also http://kb.mozillazine.org/Import_bookmarks ("Import from another browser" and "Import from file")

  • Hi - I am a new iPad user - I am trying to sync/transfer my iTunes and other things from my PC to my new iPad - I purchased a cable for it today - still stuck on how to do it!  Please HELP! :)

    Hi - I am a new iPad user - I am trying to sync/transfer my iTunes and other things from my PC to my new iPad - I purchased a cable for it today - still stuck on how to do it!  Please HELP!

    Syncing with iTune
    http://support.apple.com/kb/HT1386

  • How to upload pictures, contacts, and other things from my old iPhone

    How to upload all my pictures, contacts, and other things from my old iPhone

    If you want everything copied over then you can copy your iTunes downloads over to your computer's iTunes library by connecting it and doing File > Devices > Transfer Purchases and you can then backup up your old phone via File > Devices > Back Up - you can then restore that backup onto your new phone (or iPad as this is the Using iPad forum).
    Backups and restores : http://support.apple.com/kb/HT4079
    Transfer content to a new device : http://support.apple.com/kb/HT2109 (you can also backup/restore via iCloud, but not all iTunes content is redownloadble, so you might not get all items copied over).

  • I can't transfer music and other files from library to my iphone 4 by dragging it.can anyone help me?is there any other way to transfer files into iphone?

    i can't transfer music and other files from library to my iphone 4 by dragging it.can anyone help me?is there any other way to transfer files into iphone?

    If you want to drag and drop ( don;t know why you would do this), you will have to check manually manage music.
    Why not just sync?
    iPhone User Guide (For iOS 5.0 Software)

  • My friends put cydia on my ipod and other stuff from it like something who slide your apps differently how can i remove the both, plz help ..???

    My friend put cydia on my ipod and other stuff from it like something who slide your apps differently. How can I remove the both, I really want, plz help ...?

    They hacked it and may have caused damage to your device. Jailbreaking also voids your warranty and support from Apple. To restore to a clean state, restore in Recovery Mode: http://support.apple.com/kb/HT1808

  • How to get Mobile number and other information from SIM card

    Hi,
    I like to get mobile number,mobile user name and other information from SIM card using j2me program.Is there is any API for this one.
    Any one give guidelines to me how to get this.
    with regards,
    latchiya

    Please use the search! this topic has come up lots of times already.

  • Removing EXIF and other Metadata from iPhoto 5 Library

    This post is intended for users who have upgraded to iPhoto5 and have suffered extensive slowdowns because of metadata that has accumulated in their iPhoto library, specifically in the Library.iPhoto file.
    This occurs if certain Pentax, Canon, and other digital cameras are used for pictures. Search this forum for "metadata" or "EXIF" or "makernote" (no quotes) for additional information about this issue.
    If you are affected by this issue and want to rid your iPhoto 5 library of this extra garbage, follow the steps below.
    1. Make two copies of your complete iPhoto Library folder and put them someplace else other than in the normal location. If something goes wrong, you'll have the backups. In any event, understand that if you follow these instructions, you are responsible for any problems, errors, or loss of photos. If you aren't prepared to take that responsibility, then do not read any further.
    2. Go to http://www.versiontracker.com and search for and download the free SmallImage application. Install it in your Applications folder.
    3. In your original iPhoto library, trash the Library.iPhoto file.
    4. Launch SmallImage by dragging your entire (ORIGINAL) iPhoto Library folder on top of SmallImage.
    5. There are 5 categories (checkboxes) of metadata (called profiles) that you can eliminate. I selected them all. Uncheck the "Recompress at quality:" checkbox. You don't want your photos altered. Uncheck the "Add Suffix" checkbox so that SmallImage will overwrite your photos with ones without the metadata. Select whether you want keep any custom file icons or not. Then, hold your breath and push the "Process Files" button in the SmallImage toolbar. If you have thousands of photos and/or a slow computer, it might take many hours.
    6. When SmallImage is finished, lauch iPhoto5, holding down the command/apple, option and shift keys. Before iPhoto fully loads, you'll be presented with the library rebuilding dialog box. Check ALL 4 options (especially the last one) and then allow iPhoto to rebuild the library. This also can take a very long time, depending on computer speed and the number of photos you have. When iPhoto is finished rebuilding the libary and reloading your photos, you'll have an iPhoto library without any the metadata that seems to be slowing it down. If you hold down the wrong keys and don't get the library rebuilding dialog box, don't panic. Quit iPhoto, and try it again. Your photos are still there.
    7. If you stay with your current camera (that is generating the metadata), manually transfer your picture files to your computer (but not directly into iPhoto) and use SmallImage to remove the metadata BEFORE you manually import them into iPhoto5.
    Hopefully, future versions of iPhoto5 will include an import option to strip metadata from photo files. If SmallImage can do it, why can't our favorite fruit company?
    Best of luck.
    12 inch 1.5Ghz Powerbook Mac OS X (10.4.3)
    12 1.5Ghz Powerbook   Mac OS X (10.3.9)  

    Link the two Macs together and use iPhoto Library Manager
    Regards
    TD

Maybe you are looking for

  • How to dynamically enable or disable a control's runtime shortcut menu?

    Is there a way to do it?   I need to disable a control's runtime menu while my VI is running and then enable it at other point of time.  All the way, I can make use of the default menu items (Reinitialize to default values, Copy data etc..,) for the

  • ISE 1.2 and ACL's with multiple ports

    When creating a DACL for my groups I used the Syntax " permit tcp any 192.168.20.0 0.0.0.255 eq 22 443" for one of my acl's inside the DACL and the syntax check validated it. When I pushed it to my groups it also worked but I have heard that this typ

  • What modification is required?

    class TemperatureConversion     public static void main (String args [ ] )        double x ;        for ( x = 212 ; x > 200 ; x = x - 1 )        double y = ( x - 32) * 5/ 9  ;        System.out.print ( " x = " + x ) ;        System.out.print ( " y =

  • Vba-excel crashes ???  SAPBEX.XLA ?

    Hi Experts, I am trying to code again in VBA for my workbook.  I have got a piece of code which is for a push button.  Everytime I refresh the query in the workbook, the whole thing crashes.   Although, what I am confused is, everytime I click on SAP

  • Problem in stopping tomcat

    Hi I have a client program which creates a socket on some port and a server program that has a server socket on the same port. I have a servlet program that starts when tomcat starts as i used load on startup option in tomcat. This servlet program cr