Solved

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

Posted on 2015-01-28
1
110 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
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

Do email signature updates give you a headache?

Constantly trying to correctly format email signatures? Spending all of your time at every user’s desk to make updates? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today!

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now