1

I currently have a script that uses the following to run the main batch file using a remote CMD application:

cd c:/remoteinstallers & ME_Unavailable_Fix

However when running this remotely it will default to my own user profile as the first line of the batch file contains:

cd/D "%UserProfile%"

Is there any way to cd to the current logged in user and then continue the rest of the script from there instead of it automatically looking for my own profile?

I have tried using the following but do not know if it would be possible to store the UserName variable and then CD to them from here

WMIC /node:"computername/IPAddress" COMPUTERSYSTEM GET USERNAME

1 Answer 1

-1

I have managed to get this working with the following:

@Echo Off
cd /D c:\users
:GetInput
Set "UserProfile="
Rem Request input from the user.
Set /P "UserProfile=Please enter the location of your UserProfile directory: "
If Not Defined UserProfile GoTo GetInput
If Not Exist "%UserProfile%\" GoTo GetInput
Rem Make the UserProfile directory the current directory
CD /D "%UserProfile%"
Echo Your current directory is %CD%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .