Solved

Dymanically adding an IP address to the end of a shortcut command line

Posted on 2015-01-28
1
117 Views
Last Modified: 2015-02-13
I have a program that runs the command below in the properties section of a shortcut. 10.10.10.1 is the IP address of the PC that the shortcut is running from however, the PCs will no longer have static addresses so I need to find a way to have the current IP address of the PC added to the end of this command dynamically. I was told to replace the IP address with %IP% but, that didn't work. Is there a way that I can have the current IP of the PC appended to this command line. The operating system is Windows 7

C:\dbcsc\dbcsc.exe 10.10.2.2  master -cfg=dbcdxl.cfg SMARTCLIENT DBC_PORT=  DBC_IP=10.10.10.1
0
Comment
Question by:jfholloway
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40575969
You could use a batch to set an environment variable for the local ip and then set the 'DBC_IP=%whateverthevariablenameis%.

Something like:
@cls
echo off
FOR /F "tokens=4 delims= " %%i in ('route print ^| find " 0.0.0.0"') DO SETX LOCALIP %%i /M

Open in new window

In a batch produces the local ip in a system environment variable called LOCALIP.  You could then have the shortcut reference this:
C:\dbcsc\dbcsc.exe 10.10.2.2  master -cfg=dbcdxl.cfg SMARTCLIENT DBC_PORT=  DBC_IP=%LOCALIP%

Open in new window

The batch itself, could be called as part of a Machine Startup script or Login script.

-saige-
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question